请考虑以下代码:
typedef void (*Fn)();
volatile long sum = 0;
inline void accu() {
sum+=4;
}
static const Fn map[4] = {&accu, &accu, &accu, &accu};
int main(int argc, char** argv) {
static const long N = 10000000L;
if (argc == 1)
{
for (long i = 0; i < N; i++)
{
accu();
accu();
accu();
accu();
}
}
else
{
for (long i = 0; i < N; i++)
{
for (int j = 0; j < 4; j++)
(*map[j])();
} …Run Code Online (Sandbox Code Playgroud) 我刚刚用新的3.11内核安装了Ubuntu 13.10.在3.10中,它具有无滴漏功能,我可以在不受本地定时器中断的情况下运行进程,而不像以前那么多.我关注此链接http://www.breakage.org/2013/11/nohz_fullgodmode/
我计划在cpu 3上运行我的应用程序,所以我在grub中设置以下内容:
isolcpus=3 nohz_full=3 rcu_nocbs=3
Run Code Online (Sandbox Code Playgroud)
重新启动后,似乎cpu 3上的本地定时器中断确实比其他cpu要少很多.
我也跑了:
# for i in `pgrep rcu` ; do taskset -pc 0 $i ; done
Run Code Online (Sandbox Code Playgroud)
但是当我开始运行我的应用程序时,本地计时器中断的计数跳了起来.我的应用程序只做无限循环.
int main() {
while (true) {
}
}
Run Code Online (Sandbox Code Playgroud)
那我错过了什么?当我运行时,为什么时间中断会回来?我认为nohz_full意味着当只有一个进程在运行时,它将停止中断.
以下是/ proc/sched_debug的输出,当我没有运行应用程序时,显然在该cpu上没有其他进程.那我错过了什么?
cpu#3, 2492.071 MHz
.nr_running : 0
.load : 0
.nr_switches : 45818
.nr_load_updates : 11165
.nr_uninterruptible : -1
.next_balance : 4295.674289
.curr->pid : 0
.clock : 3127610.519188
.cpu_load[0] : 0
.cpu_load[1] : 0
.cpu_load[2] : 0
.cpu_load[3] : 0
.cpu_load[4] : 0
.yld_count …Run Code Online (Sandbox Code Playgroud) c++ ×1
disassembly ×1
g++ ×1
inline ×1
interrupt ×1
latency ×1
linux ×1
linux-kernel ×1
performance ×1
timer ×1