From: Dario Faggioli <dario.faggioli@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Tim Deegan <tim@xen.org>, Julien Grall <julien.grall@arm.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH 1/3] xen: timers: don't miss a timer event because of stop_timer()
Date: Tue, 26 Sep 2017 20:11:00 +0200 [thread overview]
Message-ID: <1506449460.27663.37.camel@citrix.com> (raw)
In-Reply-To: <59CA8789020000780017FDDC@prv-mh.provo.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 4592 bytes --]
On Tue, 2017-09-26 at 08:59 -0600, Jan Beulich wrote:
> > > > On 15.09.17 at 20:01, <dario.faggioli@citrix.com> wrote:
> > --- a/xen/common/timer.c
> > +++ b/xen/common/timer.c
> > @@ -217,7 +217,7 @@ static inline void activate_timer(struct timer
> > *timer)
> > timer->status = TIMER_STATUS_invalid;
> > list_del(&timer->inactive);
> >
> > - if ( add_entry(timer) )
> > + if ( add_entry(timer) || timer->expires <= NOW() )
> > cpu_raise_softirq(timer->cpu, TIMER_SOFTIRQ);
> > }
>
> I'm not convinced of this change - it's unrelated to what title and
> description say,
>
You're right. This should either be mentioned, or dropped (or live in
another patch).
> > @@ -326,7 +326,17 @@ void stop_timer(struct timer *timer)
> > return;
> >
> > if ( active_timer(timer) )
> > - deactivate_timer(timer);
> > + {
> > + /*
> > + * If the timer is expired already, 'call' the softirq
> > handler to
> > + * execute it (it will leave it inactive after that). If
> > not, just
> > + * deactivate it.
> > + */
> > + if ( timer->expires <= NOW() )
> > + cpu_raise_softirq(timer->cpu, TIMER_SOFTIRQ);
> > + else
> > + deactivate_timer(timer);
> > + }
>
> Isn't it reasonable to expect current behavior, i.e. the timer not
> raising any events other than those already in progress?
>
Well, if we managed to get to here, with the timer that is both:
- active,
- with its expiry time in the past,
it means there is an event that *is* in progress right now (i.e., we're
stopping the timer on the path that goes from the interrupt that raised
TIMER_SOFTIRQ, and the timer softirq handler).
So, basically, I'm trying to achieve exactly what you call reasonable:
servicing an event which is in progress. :-)
The alternative is that the event happened, but we somehow managed to
miss running the timer handler for it, and we realize this only now,
potentially a long time after the miss. This scenario, as far as I can
tell, can't happen, but if it could/does, I'd still say running the
handler late is better than not running it at all.
> Additionally I'm not convinced the changed actually does what you
> want: What if NOW() becomes equal to timer->expires immediately
> after you've managed to obtain its value, before execution makes
> it into deactivate_timer()? IOW you're shrinking a time window which
> (I think) you really mean to eliminate.
>
Well, I certainly don't like the window to be there, and closing it
would be ideal, IMO.
However, in this patch, I'm addressing the specific situation of when
we are stopping a timer for which an interrupt has already fired, the
interrupt's ISR has already raised TIMER_SOFTIRQ, and yet we don't run
the handler.
Yes, if an interrupt is about to be raised, and/or it arrives _while_
we are inside this function (after the check), or already in
deactivate_timer(), we also end up not running the handler.
I guess these can be seen as two aspects of the same problem, or as
conceptually different issues, but whatever you consider them, getting
rid of the former is something I consider an improvement.
I certainly can try to state the problem better, and describe the
situation more clearly in the changelog.
> Furthermore, taking both changes together: What if the same
> you try to address in stop_timer() happens in set_timer()? Wouldn't
> it then be only consistent to also require a timer even to fire for
> the
> old expiry value, before the new one is being set?
>
Yes, personally, I think that, whenever it is that we figure out that
we missed handling a timer interrupt, we should run it then.
Unfortunately, for achieving this, e.g., in the set_timer() case, I
don't see much alternatives to call execute_timer() right in there. But
that would violate the current invariant that execute_timer() only run
from the TIMER_SOFTIRQ handler... which is probably doable, but is at
the same time unrelated to the problem I'm tackling here, and I would
rather do it in a dedicated series.
Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-09-26 18:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 18:01 [PATCH 0/3] xen: RCU: Improve the idle timer handling Dario Faggioli
2017-09-15 18:01 ` [PATCH 1/3] xen: timers: don't miss a timer event because of stop_timer() Dario Faggioli
2017-09-26 14:59 ` Jan Beulich
2017-09-26 18:11 ` Dario Faggioli [this message]
2017-09-27 8:20 ` Jan Beulich
2017-09-27 10:18 ` Dario Faggioli
2017-09-27 10:30 ` Jan Beulich
2017-09-27 13:39 ` Dario Faggioli
2017-09-28 9:51 ` Dario Faggioli
2017-09-15 18:01 ` [PATCH 2/3] xen: RCU: make the period of the idle timer configurable Dario Faggioli
2017-09-26 15:14 ` Jan Beulich
2017-09-26 17:48 ` Dario Faggioli
2017-09-27 8:26 ` Jan Beulich
2017-09-15 18:01 ` [PATCH 3/3] xen: RCU: make the period of the idle timer adaptive Dario Faggioli
2017-09-26 15:24 ` Jan Beulich
2017-09-26 17:50 ` Dario Faggioli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506449460.27663.37.camel@citrix.com \
--to=dario.faggioli@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.