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

cpu topology: fix numa_nodes format #201

Merged
merged 1 commit into from
Mar 29, 2024
Merged

Conversation

Yujie-Liu
Copy link
Contributor

The grep command may give different format of output when the system has one node or multiple nodes.

one node system:

$ grep . /sys/devices/system/node/node*/cpulist
0-35

two nodes system:

$ grep . /sys/devices/system/node/node*/cpulist
/sys/devices/system/node/node0/cpulist:0-25,52-77
/sys/devices/system/node/node1/cpulist:26-51,78-103

If the system has only one node, subsequent code cannot parse noma_nodes correctly, causing wrong test result. Add -H option for grep command to unify the output format no matter how many nodes the system has.

== before fix ==

$ numa_nodes=$(grep . /sys/devices/system/node/node*/cpulist 2>&1) $ echo "$numa_nodes"
0-35
$ node_cpu_list=$(echo "$numa_nodes" | sed -n "1, 1p" | awk -F ":" '{print $2}') $ echo "$node_cpu_list"
<-- nothing

== after fix ==

$ numa_nodes=$(grep -H . /sys/devices/system/node/node*/cpulist 2>&1) $ echo "$numa_nodes"
/sys/devices/system/node/node0/cpulist:0-35
$ node_cpu_list=$(echo "$numa_nodes" | sed -n "1, 1p" | awk -F ":" '{print $2}') $ echo "$node_cpu_list"
0-35

Reported-by: kernel test robot [email protected]

The grep command may give different format of output when the system has
one node or multiple nodes.

one node system:

  $ grep . /sys/devices/system/node/node*/cpulist
  0-35

two nodes system:

  $ grep . /sys/devices/system/node/node*/cpulist
  /sys/devices/system/node/node0/cpulist:0-25,52-77
  /sys/devices/system/node/node1/cpulist:26-51,78-103

If the system has only one node, subsequent code cannot parse noma_nodes
correctly, causing wrong test result. Add -H option for grep command to
unify the output format no matter how many nodes the system has.

== before fix ==

$ numa_nodes=$(grep . /sys/devices/system/node/node*/cpulist 2>&1)
$ echo "$numa_nodes"
0-35
$ node_cpu_list=$(echo "$numa_nodes" | sed -n "1, 1p" | awk -F ":" '{print $2}')
$ echo "$node_cpu_list"
<-- nothing

== after fix ==

$ numa_nodes=$(grep -H . /sys/devices/system/node/node*/cpulist 2>&1)
$ echo "$numa_nodes"
/sys/devices/system/node/node0/cpulist:0-35
$ node_cpu_list=$(echo "$numa_nodes" | sed -n "1, 1p" | awk -F ":" '{print $2}')
$ echo "$node_cpu_list"
0-35

Reported-by: kernel test robot <[email protected]>
Signed-off-by: Yujie Liu <[email protected]>
@qwang59
Copy link
Contributor

qwang59 commented Mar 28, 2024

Thanks Yujie for the fix patch, appreciate!

@ysun ysun merged commit b07d44a into intel:main Mar 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants