# @name SMP CPU Affinity
# @desc Check that processes assigned to multiple CPUs complete without errors
# @requires smp
# @setup_requires
SMP_S_FUNC_CPUAFFINITY_NO-LB_CORE1 source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 10 -a 0x1 -d 0"
SMP_S_FUNC_CPUAFFINITY_NO-LB_CORE2 source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 10 -a 0x2 -d 0"
SMP_S_FUNC_CPUAFFINITY_LB source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 20 -a 0xFFFFFFFF -d 0"
# @desc Check that processes assigned to multiple CPUs complete without errors
# @requires smp
# @setup_requires
SMP_S_FUNC_CPUAFFINITY_NO-LB_CORE1 source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 10 -a 0x1 -d 0"
SMP_S_FUNC_CPUAFFINITY_NO-LB_CORE2 source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 10 -a 0x2 -d 0"
SMP_S_FUNC_CPUAFFINITY_LB source 'common.sh'; num_cores=`cat /sys/devices/system/cpu/online`; echo $num_cores | grep -E '[[:digit:]]+-' > /dev/null && multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 20 -a 0xFFFFFFFF -d 0"
multi_run_processes.sh -s "dd if=/dev/urandom of=/dev/null bs=1M count=10" -l "-n 10 -a 0x1 -d 0"
# usage:
# multi_run_processes.sh <process list> [<process list2> ...] -v
# where -v is an optional flag and when present indicates that priority
# of two processes has to be verified using time taken
# for process execution
#
# process_list= -s "#-separated commands" -l "-n <num_instances>
# -a <cpu affinity mask> -d <inter-process start delay>
# -p <priority> -r <realtime priority>"
# multi_run_processes.sh <process list> [<process list2> ...] -v
# where -v is an optional flag and when present indicates that priority
# of two processes has to be verified using time taken
# for process execution
#
# process_list= -s "#-separated commands" -l "-n <num_instances>
# -a <cpu affinity mask> -d <inter-process start delay>
# -p <priority> -r <realtime priority>"
-s "dd if=/dev/urandom of=/dev/null bs=1M count=10"
-l "-n 10 -a 0x1 -d 0"
run_processes.sh -c "dd if=/dev/urandom of=/dev/null bs=1M count=10" -n 10 -a 0x1 -d 0
# usage: run_processes.sh -c <"#-separated commands">
# [-n <num_of_instances> ]
# [-a <cpu_affinity_mask>]
# [-d <delay_in_sec> ]
# [-p <priority> ]
# [-r <realtime priority> ]
# [-w] On first failure, wait for all processes
# if cpu affinity is set, then taskset is used to spawn the processes
# [-n <num_of_instances> ]
# [-a <cpu_affinity_mask>]
# [-d <delay_in_sec> ]
# [-p <priority> ]
# [-r <realtime priority> ]
# [-w] On first failure, wait for all processes
# if cpu affinity is set, then taskset is used to spawn the processes
[-a <cpu_affinity_mask>]
在哪个CPU上运行,二进制就在哪一个上赋值为1
那么例如出现pid 8987's current affinity mask: ff ff是16进制,转换二进制:11111111,意思就是在8个CPU上运行!
比如说16进制的40,那么转换二进制01000000,意思就是在第7块CPU上运作