Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug:getTopology will be failed on Arm platform #2114

Merged
merged 1 commit into from
Dec 6, 2018

Conversation

lubinszARM
Copy link
Contributor

On Arm platform, no 'core id' and 'physical id' in '/proc/cpuinfo'.
So we should search sysfs cpu path directly to get the data of
'thread_id' &'core_id' & 'node_id'.
This method can also be used on other platforms, such as x86, ppc64le...
/sys/bus/cpu/devices/cpu%d contains the information of 'core_id' & 'node_id'.
Such as:
cat /sys/bus/cpu/devices/cpu0/topology/core_id
ls /sys/bus/cpu/devices/cpu0/node0

Signed-off-by: Bin Lu bin.lu@arm.com

@k8s-ci-robot
Copy link
Collaborator

Hi @lubinszARM. Thanks for your PR.

I'm waiting for a google or kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lubinszARM
Copy link
Contributor Author

@dashpole
Hi, I have fixed the CLA issue.
Any comments on this?

@dashpole
Copy link
Collaborator

dashpole commented Dec 3, 2018

/ok-to-test

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any testing for this change?

@lubinszARM lubinszARM force-pushed the cpuinfo branch 2 times, most recently from fdf02ed to 1cc33d2 Compare December 4, 2018 08:24
@lubinsz
Copy link

lubinsz commented Dec 4, 2018

@dashpole
Hi,
Test cases for getCoreIdFromCpuBus/getNodeIdFromCpuBus were added into "machine/topology_test.go"
Please check it.
Thanks.

@lubinsz
Copy link

lubinsz commented Dec 4, 2018

/retest

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more edge case


num, err := ioutil.ReadFile(file)
if err != nil {
// report threadId if no NUMA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this failure always indicate there is no NUMA? Maybe only return threadId if the error is os.IsNotExist(err).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I have removed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting

if os.IsNotExist(err) {
    // report threadId if no NUMA
    return threadId, nil
} else if err != nil {
    return 0, err
}

I don't have enough context on the change to know if that is actually the right thing to do here, but whatever you think the correct behavior is works for me.

On Arm platform, no 'core id' and 'physical id' in '/proc/cpuinfo'.
So we should search sysfs cpu path directly to get the data of
'thread_id' &'core_id' & 'node_id'.
This method can also be used on other platforms, such as x86, ppc64le...
/sys/bus/cpu/devices/cpu%d contains the information of 'core_id' & 'node_id'.
Such as:
cat /sys/bus/cpu/devices/cpu0/topology/core_id
ls /sys/bus/cpu/devices/cpu0/node0

Signed-off-by: Bin Lu <bin.lu@arm.com>
@lubinsz
Copy link

lubinsz commented Dec 5, 2018

/retest

@dashpole
Copy link
Collaborator

dashpole commented Dec 5, 2018

let me know about the os.IsNotExist(err); otherwise lgtm

@lubinsz
Copy link

lubinsz commented Dec 6, 2018

@dashpole
Hi,
The old comment of "report threadId if no NUMA" is inappropriate.
This file is exist even on machines that do not support numa.
So I removed it.
We can confirm it in a VM that don't support numa.

Another problem is that the kernel is starting to support numa from version 2.5.
So it means the file does not exit on the old kernel (<2.5).
I think we can report the error and let user to check the error and decide to use the same threadId or not.
Thanks.

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants