是否应该仅在SMP系统中的一个内核上调用do_timer()? [英] Is do_timer() supposed to be called on only one core in SMP systems?

查看:88
本文介绍了是否应该仅在SMP系统中的一个内核上调用do_timer()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道do_timer负责更新jiffies计数器.因此,我的问题是,它可以在发生计时器滴答的不同内核上执行还是始终在同一内核上执行?

I understand that do_timer is responsible for updating jiffies counter. Therefore my question, can it be executed on different cores or always on the same core on which the timer tick occurred?

推荐答案

在谷歌搜索和阅读代码后,让我回答自己的问题.

Let me answer my own question after googling and reading code.

do_timer() 应该被称为在ID保留在 tick_do_timer_cpu 中的CPU上变量.

do_timer() is supposed to be called on cpu with ID kept in tick_do_timer_cpu variable.

kernel/time/tick-common.c

/*
* tick_do_timer_cpu是一个计时器核心内部变量,用于保存CPU NR
*负责调用do_timer(),即计时内容.This
*变量具有两个功能:
*
* 1)防止大量的CPU试图抢夺雷电群的问题.
*计时锁定全部一次.仅分配给CPU的处理器
*更新正在处理.
*
* 2)通过将值设置为
来切换NOHZ空闲情况下的占空比 * TICK_DO_TIMER_NONE,即不存在的CPU.因此,下一个看起来像
的CPU *它将接管并保持活动的时间.移交
*该过程还涵盖了CPU热插拔.
*/

/*
* tick_do_timer_cpu is a timer core internal variable which holds the CPU NR
* which is responsible for calling do_timer(), i.e. the timekeeping stuff.This
* variable has two functions:
*
* 1) Prevent a thundering herd issue of a gazillion of CPUs trying to grab the
* timekeeping lock all at once. Only the CPU which is assigned to do the
* update is handling it.
*
* 2) Hand off the duty in the NOHZ idle case by setting the value to
* TICK_DO_TIMER_NONE, i.e. a non existing CPU. So the next cpu which looks
* at it will take over and keep the time keeping alive. The handover
* procedure also covers cpu hotplug.
*/

根据中的当前CPU ID检查

tick_do_timer_cpu tick_periodic() tick_sched_do_timer() .如果当前CPU相同,则调用do_timer(),否则调用.

tick_do_timer_cpu is checked against current CPU ID in tick_periodic() or in tick_sched_do_timer(). If current CPU is the same do_timer() is called otherwise not.

static void tick_periodic(int cpu)
 {
      if (tick_do_timer_cpu == cpu) {
              write_seqlock(&jiffies_lock);

              /* Keep track of the next tick event */
              tick_next_period = ktime_add(tick_next_period, tick_period);

              do_timer(1);
              write_sequnlock(&jiffies_lock);
              update_wall_time();
      }

      update_process_times(user_mode(get_irq_regs()));
      profile_tick(CPU_PROFILING);
  }`

通过这种方式,Jiffies管理在SMP系统的一个核心上完成.

This way jiffies management is done on one core in SMP systems.

这篇关于是否应该仅在SMP系统中的一个内核上调用do_timer()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆