[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877cfb7jlo.fsf@oracle.com>
Date: Thu, 30 May 2024 02:08:19 -0700
From: Ankur Arora <ankur.a.arora@...cle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ankur Arora <ankur.a.arora@...cle.com>, linux-kernel@...r.kernel.org,
tglx@...utronix.de, torvalds@...ux-foundation.org, paulmck@...nel.org,
rostedt@...dmis.org, mark.rutland@....com, juri.lelli@...hat.com,
joel@...lfernandes.org, raghavendra.kt@....com, sshegde@...ux.ibm.com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com,
Ingo Molnar
<mingo@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH v2 07/35] sched: define *_tsk_need_resched_lazy() helpers
Peter Zijlstra <peterz@...radead.org> writes:
> On Mon, May 27, 2024 at 05:34:53PM -0700, Ankur Arora wrote:
>
>> static inline void clear_tsk_need_resched(struct task_struct *tsk)
>> {
>> - clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
>> + clear_tsk_thread_flag(tsk, tif_resched(RESCHED_NOW));
>> +
>> + if (IS_ENABLED(CONFIG_PREEMPT_AUTO))
>> + clear_tsk_thread_flag(tsk, tif_resched(RESCHED_LAZY));
>> +}
>
> (using tif_resched() here is really uncalled for)
>
> So this will generate rather sub-optimal code, namely 2 atomics that
> really should be one.
>
> Ideally we'd write this something like:
>
> unsigned long mask = _TIF_NEED_RESCHED;
> if (IS_ENABLED(CONFIG_PREEMPT_AUTO))
> mask |= _TIF_NEED_RESCHED_LAZY;
>
> atomic_long_andnot(mask, (atomic_long_t *)task_thread_info(tsk)->flags);
>
> Which will clear both bits with a single atomic.
Much better. Will fix.
--
ankur
Powered by blists - more mailing lists