Re: [PATCH V6 7/7] Introduce a config option for scheduler time slice extension feature

From: Prakash Sangappa
Date: Tue Jul 01 2025 - 13:47:50 EST




> On Jun 30, 2025, at 8:12 PM, K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello Prakash,
>
> Couple of nits. inlined below.
>
> On 7/1/2025 6:07 AM, Prakash Sangappa wrote:
>> Add a config option to enable schedule time slice extension.
>> Signed-off-by: Prakash Sangappa <prakash.sangappa@xxxxxxxxxx>
>> ---
>> include/linux/entry-common.h | 2 +-
>> include/linux/sched.h | 8 ++++----
>> init/Kconfig | 7 +++++++
>> kernel/rseq.c | 5 ++++-
>> kernel/sched/core.c | 12 ++++++------
>> kernel/sched/debug.c | 2 +-
>> kernel/sched/syscalls.c | 3 ++-
>> 7 files changed, 25 insertions(+), 14 deletions(-)
>> diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
>> index d4fa952e394e..351c9dc159bc 100644
>> --- a/include/linux/entry-common.h
>> +++ b/include/linux/entry-common.h
>> @@ -402,7 +402,7 @@ static __always_inline void syscall_exit_to_user_mode_work(struct pt_regs *regs)
>> CT_WARN_ON(ct_state() != CT_STATE_KERNEL);
>> /* reschedule if sched delay was granted */
>> - if (IS_ENABLED(CONFIG_RSEQ) && current->sched_time_delay)
>> + if (IS_ENABLED(CONFIG_SCHED_PREEMPT_DELAY) && current->sched_time_delay)
>
> A wrapper around this would be nice. Something like
> sched_delay_resched()? It can also be reused in do_sched_yield() then.
> Thoughts?
>

Ok, will do that.

>> set_tsk_need_resched(current);
>> if (IS_ENABLED(CONFIG_PROVE_LOCKING)) {
>
> [..snip..]
>
>> diff --git a/init/Kconfig b/init/Kconfig
>> index ce76e913aa2b..2f5f603d175a 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -1130,6 +1130,13 @@ config SCHED_MM_CID
>> def_bool y
>> depends on SMP && RSEQ
>> +config SCHED_PREEMPT_DELAY
>> + def_bool y
>> + depends on SMP && RSEQ
>
> && SCHED_HRTICK
>
> and then you can avoid the ugly "!IS_ENABLED(CONFIG_SCHED_HRTICK)"
> checks and keep all the SCHED_PREEMPT_DELAY bits in one place
> without the need to put them in the "#ifdef CONFIG_SCHED_HRTICK"
> block.

Sure, I should have included SCHED_HRTICK.
Will make that change.

>
> Also, are we settling for 30us delay for PREEMPT_RT too or should
> this also include "&& !PREEMPT_RT"?

Yes, 30us is the default. This needs to be decided.
If we decide that scheduler time slice extension should be disabled for PREEMPT_RT
then I will include !PREEMPT_RT.

>
>> + help
>> + This feature enables a thread to request extending its time slice on
>> + the cpu by delaying preemption.
>> +
>> config UCLAMP_TASK_GROUP
>> bool "Utilization clamping per group of tasks"
>> depends on CGROUP_SCHED
>
>

Thanks for looking into it.
-Prakash

> Thanks and Regards,
> Prateek
>