[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87fs0zy5pu.fsf@oracle.com>
Date: Mon, 20 Nov 2023 22:34:53 -0800
From: Ankur Arora <ankur.a.arora@...cle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ankur Arora <ankur.a.arora@...cle.com>,
linux-kernel@...r.kernel.org, tglx@...utronix.de,
torvalds@...ux-foundation.org, paulmck@...nel.org,
linux-mm@...ck.org, x86@...nel.org, akpm@...ux-foundation.org,
luto@...nel.org, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, mingo@...hat.com, juri.lelli@...hat.com,
vincent.guittot@...aro.org, willy@...radead.org, mgorman@...e.de,
jon.grimm@....com, bharata@....com, raghavendra.kt@....com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com,
jgross@...e.com, andrew.cooper3@...rix.com, mingo@...nel.org,
bristot@...nel.org, mathieu.desnoyers@...icios.com,
geert@...ux-m68k.org, glaubitz@...sik.fu-berlin.de,
anton.ivanov@...bridgegreys.com, mattst88@...il.com,
krypton@...ich-teichert.org, rostedt@...dmis.org,
David.Laight@...lab.com, richard@....at, mjguzik@...il.com
Subject: Re: [RFC PATCH 41/86] sched: handle resched policy in resched_curr()
Peter Zijlstra <peterz@...radead.org> writes:
> On Wed, Nov 08, 2023 at 02:26:37AM -0800, Ankur Arora wrote:
>>
>> Peter Zijlstra <peterz@...radead.org> writes:
>>
>> > On Tue, Nov 07, 2023 at 01:57:27PM -0800, Ankur Arora wrote:
>> >
>> >> --- a/kernel/sched/core.c
>> >> +++ b/kernel/sched/core.c
>> >> @@ -1027,13 +1027,13 @@ void wake_up_q(struct wake_q_head *head)
>> >> }
>> >>
>> >> /*
>> >> - * resched_curr - mark rq's current task 'to be rescheduled now'.
>> >> + * __resched_curr - mark rq's current task 'to be rescheduled'.
>> >> *
>> >> - * On UP this means the setting of the need_resched flag, on SMP it
>> >> - * might also involve a cross-CPU call to trigger the scheduler on
>> >> - * the target CPU.
>> >> + * On UP this means the setting of the need_resched flag, on SMP, for
>> >> + * eager resched it might also involve a cross-CPU call to trigger
>> >> + * the scheduler on the target CPU.
>> >> */
>> >> -void resched_curr(struct rq *rq)
>> >> +void __resched_curr(struct rq *rq, resched_t rs)
>> >> {
>> >> struct task_struct *curr = rq->curr;
>> >> int cpu;
>> >> @@ -1046,17 +1046,77 @@ void resched_curr(struct rq *rq)
>> >> cpu = cpu_of(rq);
>> >>
>> >> if (cpu == smp_processor_id()) {
>> >> - set_tsk_need_resched(curr, RESCHED_eager);
>> >> - set_preempt_need_resched();
>> >> + set_tsk_need_resched(curr, rs);
>> >> + if (rs == RESCHED_eager)
>> >> + set_preempt_need_resched();
>> >> return;
>> >> }
>> >>
>> >> - if (set_nr_and_not_polling(curr, RESCHED_eager))
>> >> - smp_send_reschedule(cpu);
>> >> - else
>> >> + if (set_nr_and_not_polling(curr, rs)) {
>> >> + if (rs == RESCHED_eager)
>> >> + smp_send_reschedule(cpu);
>> >
>> > I think you just broke things.
>> >
>> > Not all idle threads have POLLING support, in which case you need that
>> > IPI to wake them up, even if it's LAZY.
>>
>> Yes, I was concerned about that too. But doesn't this check against the
>> idle_sched_class in resched_curr() cover that?
>
> I that's what that was. Hmm, maybe.
>
> I mean, we have idle-injection too, those don't as FIFO, but as such,
> they can only get preempted from RT/DL, and those will already force
> preempt anyway.
Aah yes, of course those are FIFO. Thanks missed that.
> The way you've split and structured the code makes it very hard to
> follow. Something like:
>
> if (set_nr_and_not_polling(curr, rs) &&
> (rs == RESCHED_force || is_idle_task(curr)))
> smp_send_reschedule();
>
> is *far* clearer, no?
Nods. I was trying to separate where we decide whether we do things
eagerly or lazily. But this is way clearer.
--
ankur
Powered by blists - more mailing lists