[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190604062931.GC15459@xz-x1>
Date: Tue, 4 Jun 2019 14:29:31 +0800
From: Peter Xu <peterx@...hat.com>
To: Marcelo Tosatti <mtosatti@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-rt-users@...r.kernel.org,
Thomas Gleixner <tglx@...utronix.de>,
Anna-Maria Gleixner <anna-maria@...utronix.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Luiz Capitulino <lcapitulino@...hat.com>,
Haris Okanovic <haris.okanovic@...com>
Subject: Re: [patch 2/3] timers: do not raise softirq unconditionally
(spinlockless version)
On Mon, Apr 15, 2019 at 05:12:15PM -0300, Marcelo Tosatti wrote:
> Check base->pending_map locklessly and skip raising timer softirq
> if empty.
>
> What allows the lockless (and potentially racy against mod_timer)
> check is that mod_timer will raise another timer softirq after
> modifying base->pending_map.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@...hat.com>
>
> ---
> kernel/time/timer.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> Index: linux-rt-devel/kernel/time/timer.c
> ===================================================================
> --- linux-rt-devel.orig/kernel/time/timer.c 2019-04-15 14:21:02.788704354 -0300
> +++ linux-rt-devel/kernel/time/timer.c 2019-04-15 14:22:56.755047354 -0300
> @@ -1776,6 +1776,24 @@
> if (time_before(jiffies, base->clk))
> return;
> }
> +
> +#ifdef CONFIG_PREEMPT_RT_FULL
> +/* On RT, irq work runs from softirq */
> + if (irq_work_needs_cpu())
> + goto raise;
> +#endif
> + base = this_cpu_ptr(&timer_bases[BASE_STD]);
> + if (!housekeeping_cpu(base->cpu, HK_FLAG_TIMER)) {
> + if (!bitmap_empty(base->pending_map, WHEEL_SIZE))
> + goto raise;
> + base++;
Shall we check against CONFIG_NO_HZ_COMMON? Otherwise the base could
point to something else rather tha the deferred base (NR_BASES==1 if
without nohz-common).
I see that run_local_timers() has similar pattern, actually I'm
thinking whether we can put things like "base++" to be inside some
"if"s of CONFIG_NO_HZ_COMMON to be clear.
Thanks,
--
Peter Xu
Powered by blists - more mailing lists