Re: [PATCH 05/30] sched: *_tsk_need_resched() now takes resched_t as param

From: Thomas Gleixner
Date: Wed Feb 21 2024 - 12:10:53 EST


On Tue, Feb 20 2024 at 14:37, Ankur Arora wrote:
> Thomas Gleixner <tglx@xxxxxxxxxxxxx> writes:
>> On Mon, Feb 12 2024 at 21:55, Ankur Arora wrote:
>>
>> The subject line reads odd...
>>
>>> -static inline bool test_tsk_need_resched(struct task_struct *tsk)
>>> +static inline bool test_tsk_need_resched(struct task_struct *tsk, resched_t rs)
>>> {
>>> - return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
>>> + if (IS_ENABLED(CONFIG_PREEMPT_AUTO) || rs == NR_now)
>>> + return unlikely(test_tsk_thread_flag(tsk, tif_resched(rs)));
>>> + else
>>> + return false;
>>> }
>>
>> Same like the others. This wants wrappers with now/lazy.
>
> So, when working on the scheduler changes, I found the simplest
> implementation was to define a function that takes into account
> current preemption mode, checks for idle, tick etc and returns
> the rescheduling policy, which __resched_curr() carries out.
>
> So, it would be useful to just pass the resched_t as a parameter
> instead of having now/lazy wrappers.

That's fine for specific functions which really need to handle the
rescheduling mode, but for all other random places having a nice wrapper
makes the code more readable.

Thanks,

tglx