[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240529082530.GJ26599@noisy.programming.kicks-ass.net>
Date: Wed, 29 May 2024 10:25:30 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ankur Arora <ankur.a.arora@...cle.com>
Cc: 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
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.
Powered by blists - more mailing lists