xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
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 v2 1/3] xen: RCU: let the RCU idle timer handler run
Date: Thu, 28 Sep 2017 16:08:50 +0200	[thread overview]
Message-ID: <1506607730.5001.9.camel@citrix.com> (raw)
In-Reply-To: <59CD0E420200007800180815@prv-mh.provo.novell.com>


[-- Attachment #1.1: Type: text/plain, Size: 3028 bytes --]

On Thu, 2017-09-28 at 06:59 -0600, Jan Beulich wrote:
> > > > On 28.09.17 at 12:15, <dario.faggioli@citrix.com> wrote:
> > --- a/xen/common/rcupdate.c
> > +++ b/xen/common/rcupdate.c
> > @@ -465,7 +465,21 @@ void rcu_idle_timer_stop()
> >          return;
> >  
> >      rdp->idle_timer_active = false;
> > -    stop_timer(&rdp->idle_timer);
> > +
> > +    /*
> > +     * In general, as the CPU is becoming active again, we don't
> > need the
> > +     * idle timer, and so we want to stop it.
> > +     *
> > +     * However, in case we are here because idle_timer has (just)
> > fired and
> > +     * has woken up the CPU, we skip stop_timer() now. In fact, if
> > we stop
> > +     * it, then the TIMER_SOFTIRQ handler wouldn't find idle_timer
> > among the
> > +     * active timers any longer, and hence won't call
> > rcu_idle_timer_handler().
> 
> I think it would help if you said explicitly that the softirq run
> necessarily happens after this code ran.
> 
Ok.

> > --- a/xen/common/timer.c
> > +++ b/xen/common/timer.c
> > @@ -332,6 +332,23 @@ void stop_timer(struct timer *timer)
> >  }
> >  
> >  
> > +bool timer_is_expired(struct timer *timer, s_time_t now)
> 
> If you call the parameter now, why is it needed? Wouldn't it be
> even more accurate if you instead used ...
> 
> > +{
> > +    unsigned long flags;
> > +    bool ret = false;
> > +
> > +    if ( !timer_lock_irqsave(timer, flags) )
> > +        return ret;
> > +
> > +    if ( active_timer(timer) && timer->expires <= now )
> 
> ... NOW() here?
> 
So, the cases where you happen to need the current time multiple times,
and you expect the difference between calling NOW() repeatedly, and
using a value sampled at the beginning is small enough, or does not
matter (and therefore you decide to save the overhead).

foo()
{
 s_time_t now = NOW();
 ...
 bar(now);
 ...
 bar2(barbar, now);
 ...
 if ( timer_is_expired(timer, now) )
 {
  ...
 }
}

This is something we do, some of the times. And a function that takes a
'now' parameter, allows both use cases: the (more natural?) one, where
you pass it NOW(), and the least-overhead one, where you pass it a
cached value of NOW().

But I don't feel like arguing too much about this (especially now that
this is patch is the only use case).

If the problem is "just" the parameter (or maybe both the parameter's
and the function's) name(s), I 'd be happy to change the parameter name
to 't', or 'time' (and the function to 'timer_expires_before()'), and
this is my preference.

But if you strongly prefer it to just use NOW() inside, I'll go for it.

Thanks and 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

  reply	other threads:[~2017-09-28 14:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 10:15 [PATCH v2 0/3] xen: RCU: Improve the idle timer handling Dario Faggioli
2017-09-28 10:15 ` [PATCH v2 1/3] xen: RCU: let the RCU idle timer handler run Dario Faggioli
2017-09-28 12:59   ` Jan Beulich
2017-09-28 14:08     ` Dario Faggioli [this message]
2017-09-28 15:35       ` Jan Beulich
2017-09-28 10:16 ` [PATCH v2 2/3] xen: RCU: make the period of the idle timer configurable Dario Faggioli
2017-09-28 13:06   ` Jan Beulich
2017-09-28 14:58     ` Dario Faggioli
2017-09-28 15:35       ` Jan Beulich
2017-09-28 17:16     ` Dario Faggioli
2017-10-04  5:45       ` Jan Beulich
2017-09-28 10:16 ` [PATCH v2 3/3] xen: RCU: make the period of the idle timer adaptive Dario Faggioli
2017-09-28 13:08   ` Jan Beulich

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=1506607730.5001.9.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).