[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200716225034.GK5523@worktop.programming.kicks-ass.net>
Date: Fri, 17 Jul 2020 00:50:34 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
Oleg Nesterov <oleg@...hat.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Frederic Weisbecker <frederic@...nel.org>,
John Stultz <john.stultz@...aro.org>,
Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [patch V2 3/5] posix-cpu-timers: Provide mechanisms to defer
timer handling to task_work
On Thu, Jul 16, 2020 at 10:19:26PM +0200, Thomas Gleixner wrote:
> @@ -1096,6 +1099,12 @@ static void __run_posix_cpu_timers(struc
> check_process_timers(tsk, &firing);
>
> /*
> + * Allow new work to be scheduled. The expiry cache
> + * is up to date.
> + */
> + posix_cpu_timers_enable_work(tsk);
> +
> + /*
> * We must release these locks before taking any timer's lock.
> * There is a potential race with timer deletion here, as the
> * siglock now protects our private firing list. We have set
I think I would feel more comfortable if this was done at the very
beginning of that function, possibly even with:
> +static void __run_posix_cpu_timers(struct task_struct *tsk)
> +{
> + struct posix_cputimers *pct = &tsk->posix_cputimers;
> +
> + if (!test_and_set_bit(CPUTIMERS_WORK_SCHEDULED, &pct->flags))
> + task_work_add(tsk, &pct->task_work, true);
> +}
> +
> +static inline void posix_cpu_timers_enable_work(struct task_struct *tsk)
> +{
> + clear_bit(CPUTIMERS_WORK_SCHEDULED, &tsk->posix_cputimers.flags);
/*
* Ensure we observe everything before a failing test_and_set()
* in __run_posix_cpu_timers().
*/
smp_mb__after_atomic();
> +}
Such that when another timer interrupt happens while we run this, we're
guaranteed to either see it, or get re-queued and thus re-run the
function.
Powered by blists - more mailing lists