All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 4/5] xen: RCU: don't let a CPU with a callback go idle.
Date: Thu, 27 Jul 2017 10:01:31 +0200	[thread overview]
Message-ID: <150114249133.22910.6287911784333237605.stgit@Solace> (raw)
In-Reply-To: <150114201043.22910.12807057883146318803.stgit@Solace>

If a CPU has a callback queued, it must be ready to invoke
it, as soon as all the other CPUs involved in the grace period
has gone through a quiescent state.

But if we let such CPU go idle, we can't really tell when (if!)
it will realize that it is actually time to invoke the callback.
To solve this problem, a CPU that has a callback queued (and has
already gone through a quiescent state itself) will stay online,
until the grace period ends, and the callback can be invoked.

This is similar to what Linux does, and is the second and last
step for fixing the overly long (or infinite!) grace periods.
The problem, though, is that, within Linux, we have the tick,
so, all that is necessary is to not stop the tick for the CPU
(even if it has gone idle). In Xen, there's no tick, so we must
avoid for the CPU to go idle entirely, and let it spin on
rcu_pending(), consuming power and causing overhead.

In this commit, we implement the above, using rcu_needs_cpu(),
in a way similar to how it is used in Linux. This it correct,
useful and not wasteful for CPUs that participate in grace
period, but have not a callback queued. For the ones that
has callbacks, an optimization that avoids having to spin is
introduced in next commit.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/include/xen/sched.h |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 6673b27..df93a86 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -842,7 +842,8 @@ uint64_t get_cpu_idle_time(unsigned int cpu);
 
 /*
  * Used by idle loop to decide whether there is work to do:
- *  (1) Run softirqs; or (2) Play dead; or (3) Run tasklets.
+ *  (1) Deal with RCU; (2) or run softirqs; or (3) Play dead;
+ *  or (4) Run tasklets.
  *
  * About (3), if a tasklet is enqueued, it will be scheduled
  * really really soon, and hence it's pointless to try to
@@ -850,7 +851,8 @@ uint64_t get_cpu_idle_time(unsigned int cpu);
  * the tasklet_work_to_do() helper).
  */
 #define cpu_is_haltable(cpu)                    \
-    (!softirq_pending(cpu) &&                   \
+    (!rcu_needs_cpu(cpu) &&                     \
+     !softirq_pending(cpu) &&                   \
      cpu_online(cpu) &&                         \
      !per_cpu(tasklet_work_to_do, cpu))
 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-07-27  8:01 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27  8:01 [PATCH 0/5] xen: RCU: x86/ARM: Add support of rcu_idle_{enter, exit} Dario Faggioli
2017-07-27  8:01 ` [PATCH 1/5] xen: in do_softirq() sample smp_processor_id() once and for all Dario Faggioli
2017-07-27  8:01 ` [PATCH 2/5] xen: ARM: suspend the tick (if in use) when going idle Dario Faggioli
2017-07-31 20:59   ` Stefano Stabellini
2017-08-01  8:53     ` Julien Grall
2017-08-01  9:26       ` Dario Faggioli
2017-07-27  8:01 ` [PATCH 3/5] xen: RCU/x86/ARM: discount CPUs that were idle when grace period started Dario Faggioli
2017-07-31 21:17   ` Stefano Stabellini
2017-08-07  8:35   ` Jan Beulich
2017-08-09  8:48     ` Dario Faggioli
2017-08-09  8:57       ` Jan Beulich
2017-08-09  9:20         ` Dario Faggioli
2017-08-09  9:26           ` Jan Beulich
2017-08-09 11:38   ` Tim Deegan
2017-08-11 17:25     ` Dario Faggioli
2017-08-14 10:39       ` Tim Deegan
2017-08-14 13:24         ` Dario Faggioli
2017-08-14 13:54           ` Tim Deegan
2017-08-14 16:21             ` Dario Faggioli
2017-08-14 16:47               ` Tim Deegan
2017-08-14  9:19     ` Dario Faggioli
2017-07-27  8:01 ` Dario Faggioli [this message]
2017-08-07  8:38   ` [PATCH 4/5] xen: RCU: don't let a CPU with a callback go idle Jan Beulich
2017-07-27  8:01 ` [PATCH 5/5] xen: RCU: avoid busy waiting until the end of grace period Dario Faggioli
2017-07-31 21:20   ` Stefano Stabellini
2017-07-31 22:03     ` Dario Faggioli
2017-07-31 23:58       ` Stefano Stabellini
2017-08-01  0:47         ` Dario Faggioli
2017-08-01 19:13           ` Stefano Stabellini
2017-08-02 10:14             ` Dario Faggioli
2017-08-01  8:45         ` Julien Grall
2017-08-01  8:54   ` Julien Grall
2017-08-01  9:17     ` Dario Faggioli
2017-08-01 10:22       ` Julien Grall
2017-08-01 10:33         ` Dario Faggioli
2017-08-07  8:54   ` Jan Beulich
2017-08-09 17:34     ` Dario Faggioli
2017-08-10 13:55       ` 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=150114249133.22910.6287911784333237605.stgit@Solace \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --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.