【发布时间】:2016-06-30 12:02:01
【问题描述】:
我在 grub.conf 中添加了“isolcpus=3 nohz_full=3 rcu_nocbs=3” RedHat 7.1,内核:linux 3.10.0-229 内核和根据http://www.breakage.org/2013/11/15/nohz_fullgodmode/ 我还执行以下命令:
cat /sys/bus/workqueue/devices/writeback/cpumask
f
echo 1 > /sys/bus/workqueue/devices/writeback/cpumask
cat /sys/bus/workqueue/devices/writeback/numa
1
echo 0 > /sys/bus/workqueue/devices/writeback/numa
盒子只有4个cpu核心,我运行以下shell:
watch -d 'cat /proc/interrupts'
看起来工作完美,只有 cpu0 本地定时器中断每 2 秒有 2000 个, else cpu 1 到 cpu 3 每 2 秒少于 10 个。
然后我测试以下来源:
void *Thread2(void *param)
{
pthread_detach(pthread_self());
while( 1 ){
sleep( 100000 ) ;
}
}
void *Thread1(void *param)
{
pthread_detach(pthread_self());
while( 1 ){
;
}
}
int main(int argc, char** argv)
{
pthread_t tid ;
pthread_create(&tid , NULL, Thread1, (void*)(long)3);
pthread_create(&tid , NULL, Thread2, (void*)(long)3);
while( 1 )
sleep( 5 ) ;
}
然后运行它:
taskset -c 3 ./x1.exe
观看输出:
watch -d 'cat /proc/interrupts'
这一次,cpu 3 每 2 秒获得 10~30 次本地定时器中断,看起来不错, 然后我尝试运行 2 thread1 :
pthread_create(&tid , NULL, Thread1, (void*)(long)3);
pthread_create(&tid , NULL, Thread1, (void*)(long)3);
然后再次运行它:
taskset -c 3 ./x1.exe
然后我看到核心 3 与核心 0 具有相同的本地计时器中断, 每 2 秒 2000 次中断。
请问,为什么2个很忙的thread1会导致core 3有 更多定时器中断?!这是什么原因发生的?! 如果可以的话怎么修改?!
【问题讨论】:
标签: linux linux-kernel interrupt