Re: [patch 2/3] timers: do not raise softirq unconditionally (spinlockless version)

Anna-Maria Gleixner
2019-05-31T11:56:10Z

On Thu, 30 May 2019, Marcelo Tosatti wrote:

> On Wed, May 29, 2019 at 04:53:26PM +0200, Anna-Maria Gleixner wrote:
> > On Mon, 15 Apr 2019, Marcelo Tosatti wrote:
> >
> > > --- 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;
> >
> > So with this patch and the change you made in the patch before, timers on
> > RT are expired only when there is pending irq work or after modifying a
> > timer on a non housekeeping cpu?
>
> Well, run_timer_softirq execute only if pending_map contains a bit set.
>
> > With your patches I could create the following problematic situation on RT
> > (if I understood everything properly): I add a timer which should expire in
> > 50 jiffies to the wheel of a non housekeeping cpu. So it ends up 50 buckets
> > away form now in the first wheel. This timer is the only timer in the wheel
> > and the next timer softirq raise is required in 50 jiffies. After adding
> > the timer, the timer interrupt is raised, and no timer has to be expired,
> > because there is no timer pending.
>
> But the softirq will be raised, because pending_map will be set:
>
> + if (!bitmap_empty(base->pending_map, WHEEL_SIZE))
> + goto raise;
>
> No?

I'm sorry! I read the #endif of the CONFIG_PREEMPT_RT_FULL section as an
#else... This is where my confusion comes from. I will think about the
problem and your solution a little bit more and give you feedback hopefully
on monday.

Thanks,
Anna-Maria