Patch "sched/core: Prevent wakeup of ksoftirqd during idle load balance" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sched/core: Prevent wakeup of ksoftirqd during idle load balance

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sched-core-prevent-wakeup-of-ksoftirqd-during-idle-l.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 75b03fdc8dab8e64d761c690fa62dcc38e12d891
Author: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Date:   Tue Nov 19 05:44:32 2024 +0000

    sched/core: Prevent wakeup of ksoftirqd during idle load balance
    
    [ Upstream commit e932c4ab38f072ce5894b2851fea8bc5754bb8e5 ]
    
    Scheduler raises a SCHED_SOFTIRQ to trigger a load balancing event on
    from the IPI handler on the idle CPU. If the SMP function is invoked
    from an idle CPU via flush_smp_call_function_queue() then the HARD-IRQ
    flag is not set and raise_softirq_irqoff() needlessly wakes ksoftirqd
    because soft interrupts are handled before ksoftirqd get on the CPU.
    
    Adding a trace_printk() in nohz_csd_func() at the spot of raising
    SCHED_SOFTIRQ and enabling trace events for sched_switch, sched_wakeup,
    and softirq_entry (for SCHED_SOFTIRQ vector alone) helps observing the
    current behavior:
    
           <idle>-0   [000] dN.1.:  nohz_csd_func: Raising SCHED_SOFTIRQ from nohz_csd_func
           <idle>-0   [000] dN.4.:  sched_wakeup: comm=ksoftirqd/0 pid=16 prio=120 target_cpu=000
           <idle>-0   [000] .Ns1.:  softirq_entry: vec=7 [action=SCHED]
           <idle>-0   [000] .Ns1.:  softirq_exit: vec=7  [action=SCHED]
           <idle>-0   [000] d..2.:  sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=ksoftirqd/0 next_pid=16 next_prio=120
      ksoftirqd/0-16  [000] d..2.:  sched_switch: prev_comm=ksoftirqd/0 prev_pid=16 prev_prio=120 prev_state=S ==> next_comm=swapper/0 next_pid=0 next_prio=120
           ...
    
    Use __raise_softirq_irqoff() to raise the softirq. The SMP function call
    is always invoked on the requested CPU in an interrupt handler. It is
    guaranteed that soft interrupts are handled at the end.
    
    Following are the observations with the changes when enabling the same
    set of events:
    
           <idle>-0       [000] dN.1.: nohz_csd_func: Raising SCHED_SOFTIRQ for nohz_idle_balance
           <idle>-0       [000] dN.1.: softirq_raise: vec=7 [action=SCHED]
           <idle>-0       [000] .Ns1.: softirq_entry: vec=7 [action=SCHED]
    
    No unnecessary ksoftirqd wakeups are seen from idle task's context to
    service the softirq.
    
    Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()")
    Closes: https://lore.kernel.org/lkml/fcf823f-195e-6c9a-eac3-25f870cb35ac@xxxxxxxx/ [1]
    Reported-by: Julia Lawall <julia.lawall@xxxxxxxx>
    Suggested-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
    Signed-off-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20241119054432.6405-5-kprateek.nayak@xxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 8abd1bf31864e..da14c7450156b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1183,7 +1183,7 @@ static void nohz_csd_func(void *info)
 	rq->idle_balance = idle_cpu(cpu);
 	if (rq->idle_balance) {
 		rq->nohz_idle_balance = flags;
-		raise_softirq_irqoff(SCHED_SOFTIRQ);
+		__raise_softirq_irqoff(SCHED_SOFTIRQ);
 	}
 }
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux