Skip to content

Commit

Permalink
Fix example error_injection_tool
Browse files Browse the repository at this point in the history
I got a "sched_setaffinity:: Invalid argument" error when using
err_injection_tool to inject error on a system with over 32 cpus.

Error information when injecting an error on a system with over 32 cpus:
$ ./err_injection_tool -i
/sys/devices/system/cpu/cpu0/err_inject//err_type_info
Begine at Tue Mar 26 11:20:08 2013
Configurations:
On cpu32: loop=10, interval=5(s) err_type_info=4101,err_struct_info=95
Error sched_setaffinity:: Invalid argument
All done

This because there is overflow when calculating the cpumask: the
type of (1<<k) is int, while mask[j] is unsigned long. When k > 31,
(1<<k) is truncated to ZERO, resulting in a unexpected cpumask.

Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Xie XiuQi authored and aegl committed Apr 2, 2013
1 parent eee46b3 commit 83d435d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Documentation/ia64/err_inject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ int err_inj()
cpu=parameters[i].cpu;
k = cpu%64;
j = cpu/64;
mask[j]=1<<k;
mask[j] = 1UL << k;

if (sched_setaffinity(0, MASK_SIZE*8, mask)==-1) {
perror("Error sched_setaffinity:");
Expand Down

0 comments on commit 83d435d

Please sign in to comment.