[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wix=nrfi2LkSXBvBSrTHgEAMYQebUfWXq8Q-PtH0x_SdQ@mail.gmail.com>
Date: Thu, 21 Sep 2023 09:00:54 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ankur Arora <ankur.a.arora@...cle.com>,
linux-kernel@...r.kernel.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, rostedt@...dmis.org,
jon.grimm@....com, bharata@....com, raghavendra.kt@....com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com,
jgross@...e.com, andrew.cooper3@...rix.com,
Frederic Weisbecker <fweisbec@...il.com>
Subject: Re: [PATCH v2 7/9] sched: define TIF_ALLOW_RESCHED
Ok, I like this.
That said, this part of it:
On Wed, 20 Sept 2023 at 16:58, Thomas Gleixner <tglx@...utronix.de> wrote:
>
> -void resched_curr(struct rq *rq)
> +static void __resched_curr(struct rq *rq, int nr_bit)
> [...]
> - set_tsk_need_resched(curr);
> - set_preempt_need_resched();
> + set_tsk_thread_flag(curr, nr_bit);
> + if (nr_bit == TIF_NEED_RESCHED)
> + set_preempt_need_resched();
feels really hacky.
I think that instead of passing a random TIF bit around, it should
just pass a "lazy or not" value around.
Then you make the TIF bit be some easily computable thing (eg something like
#define TIF_RESCHED(lazy) (TIF_NEED_RESCHED + (lazy))
or whatever), and write the above conditional as
if (!lazy)
set_preempt_need_resched();
so that it all *does* the same thing, but the code makes it clear
about what the logic is.
Because honestly, without having been part of this thread, I would look at that
if (nr_bit == TIF_NEED_RESCHED)
set_preempt_need_resched();
and I'd be completely lost. It doesn't make conceptual sense, I feel.
So I'd really like the source code to be more directly expressing the
*intent* of the code, not be so centered around the implementation
detail.
Put another way: I think we can make the compiler turn the intent into
the implementation, and I'd rather *not* have us humans have to infer
the intent from the implementation.
That said - I think as a proof of concept and "look, with this we get
the expected scheduling event counts", that patch is perfect. I think
you more than proved the concept.
Linus
Powered by blists - more mailing lists