cpu topology: fix numa_nodes format #201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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]