• Peter Zijlstra's avatar
    sched/core: Introduce SM_IDLE and an idle re-entry fast-path in __schedule() · 3dcac251
    Peter Zijlstra authored
    Since commit b2a02fc4 ("smp: Optimize
    send_call_function_single_ipi()") an idle CPU in TIF_POLLING_NRFLAG mode
    can be pulled out of idle by setting TIF_NEED_RESCHED flag to service an
    IPI without actually sending an interrupt. Even in cases where the IPI
    handler does not queue a task on the idle CPU, do_idle() will call
    __schedule() since need_resched() returns true in these cases.
    
    Introduce and use SM_IDLE to identify call to __schedule() from
    schedule_idle() and shorten the idle re-entry time by skipping
    pick_next_task() when nr_running is 0 and the previous task is the idle
    task.
    
    With the SM_IDLE fast-path, the time taken to complete a fixed set of
    IPIs using ipistorm improves noticeably. Following are the numbers
    from a dual socket Intel Ice Lake Xeon server (2 x 32C/64T) and
    3rd Generation AMD EPYC system (2 x 64C/128T) (boost on, C2 disabled)
    running ipistorm between CPU8 and CPU16:
    
    cmdline: insmod ipistorm.ko numipi=100000 single=1 offset=8 cpulist=8 wait=1
    
       ==================================================================
       Test          : ipistorm (modified)
       Units         : Normalized runtime
       Interpretation: Lower is better
       Statistic     : AMean
       ======================= Intel Ice Lake Xeon ======================
       kernel:				time [pct imp]
       tip:sched/core			1.00 [baseline]
       tip:sched/core + SM_IDLE		0.80 [20.51%]
       ==================== 3rd Generation AMD EPYC =====================
       kernel:				time [pct imp]
       tip:sched/core			1.00 [baseline]
       tip:sched/core + SM_IDLE		0.90 [10.17%]
       ==================================================================
    
    [ kprateek: Commit message, SM_RTLOCK_WAIT fix ]
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Not-yet-signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Signed-off-by: default avatarK Prateek Nayak <kprateek.nayak@amd.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
    Link: https://lore.kernel.org/r/20240809092240.6921-1-kprateek.nayak@amd.com
    3dcac251
core.c 267 KB