Re: [patch 07/12] rseq: Implement syscall entry work for time slice extensions

Thomas Gleixner
2025-09-10T07:49:09Z

On Wed, Sep 10 2025 at 10:52, K. Prateek Nayak wrote:
> On 9/9/2025 4:30 AM, Thomas Gleixner wrote:
>> +static inline void rseq_slice_set_need_resched(struct task_struct *curr)
>> +{
>> + /*
>> + * The interrupt guard is required to prevent inconsistent state in
>> + * this case:
>> + *
>> + * set_tsk_need_resched()
>> + * --> Interrupt
>> + * wakeup()
>> + * set_tsk_need_resched()
>> + * set_preempt_need_resched()
>> + * schedule_on_return()
>> + * clear_tsk_need_resched()
>> + * clear_preempt_need_resched()
>> + * set_preempt_need_resched() <- Inconsistent state
>> + *
>> + * This is safe vs. a remote set of TIF_NEED_RESCHED because that
>> + * only sets the already set bit and does not create inconsistent
>> + * state.
>> + */
>> + scoped_guard(irq)
>> + set_need_resched_current();
>
> nit. any specific reason for using a scoped_guard() instead of just a
> guard() here (and in rseq_cancel_slice_extension_timer()) other than to
> prominently highlight what is being guarded?

Yes, the intention was to highlight it and scoped_guard() really
does. From a code generation perspective it's the same outcome.

Thanks,

tglx