Skip to contentSkip to conversation

ia64: Fix example error_injection_tool

PATCH Superseded Xie XiuQi 2 participants 3 messages Mar 28, 2013 – Mar 29, 2013 Documentation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xie XiuQi

author
#0 lore raw

PATCH 1/1 ia64: Fix example error_injection_tool

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.

---
 Documentation/ia64/err_inject.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/ia64/err_inject.txt +1 -1
index 223e4f0..ec61ac1 100644
@@ -882,7 +882,7 @@ int err_inj()
 			cpu=parameters[i].cpu;
 			k = cpu%64;
 			j = cpu/64;
-			mask[j]=1<<k;
+			mask[j] = (unsigned long)1<<k;
 
 			if (sched_setaffinity(0, MASK_SIZE*8, mask)==-1) {
 				perror("Error sched_setaffinity:");
Signature · 1 line
1.6.0.2
#1 lore raw

Nice catch.

- mask[j]=1<<k;
+ mask[j] = (unsigned long)1<<k;

Could use

			mask[j] = 1ul << k;

to avoid the verbose cast.

-Tony

author
#2 lore raw
Quoted 8 lines · Tony

Nice catch.

Documentation/ia64/err_inject.txt +1 -1
-			mask[j]=1<<k;
+			mask[j] = (unsigned long)1<<k;

Could use

			mask[j] = 1ul << k;

to avoid the verbose cast.

Thank you for your suggestion, Tony.
I'll modify it in next version.

Quoted 4 lines

-Tony