共享LLC来减少ipi中断

linux kernel唤醒进程的步骤:

select task rq,enqueue,active task。

对于enqueue调用链是:try_to_wake_up->ttwu_queue->ttwu_queue_wakelist

static bool ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags)
{
    if (sched_feat(TTWU_QUEUE) && ttwu_queue_cond(cpu, wake_flags)) {
        if (WARN_ON_ONCE(cpu == smp_processor_id()))
            return false;

        sched_clock_cpu(cpu); /* Sync clocks across CPUs */
        __ttwu_queue_wakelist(p, cpu, wake_flags);
        return true;
    }

    return false;
}

__ttwu_queue_wakelist会给选择到的cpu发ipi中断,但是要先满足一些条件,包括ttwu_queue_cond。

static inline bool ttwu_queue_cond(int cpu, int wake_flags)
{
    /*
     * If the CPU does not share cache, then queue the task on the
     * remote rqs wakelist to avoid accessing remote data.
     */
    if (!cpus_share_cache(smp_processor_id(), cpu))
        return true;
...
  return false; }

这个函数表明,如果当前cpu和选择的target cpu是共享llc则返回false。这样__ttwu_queue_wakelist就不会执行,ipi也不会发送。这在vm上的意义是共享llc可以减少ipi中断带来的vm exit。

posted @ 2024-09-02 15:59  半山随笔  阅读(1)  评论(0编辑  收藏  举报