Re: [PATCH 2/5] sched: dynamic: Simplify {cond,might}_resched()
From: Mark Rutland
Date: Fri Jul 17 2026 - 07:33:51 EST
On Mon, Jul 06, 2026 at 10:29:26AM +0530, Shrikanth Hegde wrote:
> On 7/3/26 7:03 PM, Mark Rutland wrote:
> > PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models.
> > In either model, both cond_resched() and might_resched() are always
> > disabled and do nothing.
> >
> > Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected.
> >
> > Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> > Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: John Stultz <jstultz@xxxxxxxxxx>
> > Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> > Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > ---
> > include/linux/kernel.h | 20 -------------------
> > include/linux/sched.h | 31 +++--------------------------
> > kernel/sched/core.c | 44 +-----------------------------------------
> > 3 files changed, 4 insertions(+), 91 deletions(-)
> >
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index e5570a16cbb1a..533ee1e6e1cb7 100644
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -43,30 +43,10 @@ struct completion;
> > struct user;
> > #ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD
>
> Would it make sense to move this block under CONFIG_PREEMPT_VOLUNTARY_BUILD
> to include/linux/sched.h so they all in one header?
That sounds reasonable, but please see comments below -- I'm not sure
it's a win overall.
>
> this builds. I meant something like below.
> ---
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 533ee1e6e1cb..49495eb754d5 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -42,13 +42,6 @@
> struct completion;
> struct user;
> -#ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD
> -extern int __cond_resched(void);
> -# define might_resched() __cond_resched()
> -#else
> -# define might_resched() do { } while (0)
> -#endif /* CONFIG_PREEMPT_* */
> -
> #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
> extern void __might_resched(const char *file, int line, unsigned int offsets);
> extern void __might_sleep(const char *file, int line);
There's no explicit include of <linux/sched.h> in <linux/kernel.h>, so
this change means later usage of __cond_resched() (via might_resched())
relies on that occurring by coincidence, which is fragile. We could add
an include to handle that, but then we're adding another include to
kernel.h....
I'm not sure whether it's best to move this now, or to just wait until
VOLUNTARY preemption is truly dead, and delete this entirely.
For the moment I'm going to err to the latter.
[...]
> Other than that, rest looks good to me.
>
> Reviewed-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
Thanks!
Mark.