From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [Xen-devel] [PATCH v7 3/5] xen: don't process rcu callbacks when holding a rcu_read_lock()
Date: Wed, 25 Mar 2020 11:55:09 +0100 [thread overview]
Message-ID: <20200325105511.20882-4-jgross@suse.com> (raw)
In-Reply-To: <20200325105511.20882-1-jgross@suse.com>
Some keyhandlers are calling process_pending_softirqs() while holding
a rcu_read_lock(). This is wrong, as process_pending_softirqs() might
activate rcu calls which should not happen inside a rcu_read_lock().
For that purpose modify process_pending_softirqs() to not allow rcu
callback processing when a rcu_read_lock() is being held.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
V3:
- add RCU_SOFTIRQ to ignore in process_pending_softirqs_norcu()
(Roger Pau Monné)
V5:
- block rcu processing depending on rch_read_lock() being held or not
(Jan Beulich)
---
xen/common/softirq.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/xen/common/softirq.c b/xen/common/softirq.c
index b83ad96d6c..00d676b62c 100644
--- a/xen/common/softirq.c
+++ b/xen/common/softirq.c
@@ -29,6 +29,7 @@ static void __do_softirq(unsigned long ignore_mask)
{
unsigned int i, cpu;
unsigned long pending;
+ bool rcu_allowed = !(ignore_mask & (1ul << RCU_SOFTIRQ));
for ( ; ; )
{
@@ -38,7 +39,7 @@ static void __do_softirq(unsigned long ignore_mask)
*/
cpu = smp_processor_id();
- if ( rcu_pending(cpu) )
+ if ( rcu_allowed && rcu_pending(cpu) )
rcu_check_callbacks(cpu);
if ( ((pending = (softirq_pending(cpu) & ~ignore_mask)) == 0)
@@ -53,9 +54,16 @@ static void __do_softirq(unsigned long ignore_mask)
void process_pending_softirqs(void)
{
+ unsigned long ignore_mask = (1ul << SCHEDULE_SOFTIRQ) |
+ (1ul << SCHED_SLAVE_SOFTIRQ);
+
+ /* Block RCU processing in case of rcu_read_lock() held. */
+ if ( preempt_count() )
+ ignore_mask |= 1ul << RCU_SOFTIRQ;
+
ASSERT(!in_irq() && local_irq_is_enabled());
/* Do not enter scheduler as it can preempt the calling context. */
- __do_softirq((1ul << SCHEDULE_SOFTIRQ) | (1ul << SCHED_SLAVE_SOFTIRQ));
+ __do_softirq(ignore_mask);
}
void do_softirq(void)
--
2.16.4
next prev parent reply other threads:[~2020-03-25 10:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 10:55 [Xen-devel] [PATCH v7 0/5] xen/rcu: let rcu work better with core scheduling Juergen Gross
2020-03-25 10:55 ` [Xen-devel] [PATCH v7 1/5] xen: introduce smp_mb__[after|before]_atomic() barriers Juergen Gross
2020-03-25 13:17 ` Jan Beulich
2020-03-25 16:20 ` Julien Grall
2020-03-25 10:55 ` [Xen-devel] [PATCH v7 2/5] xen/rcu: don't use stop_machine_run() for rcu_barrier() Juergen Gross
2020-03-25 13:19 ` Jan Beulich
2020-03-25 16:13 ` Julien Grall
2020-03-26 6:58 ` Jan Beulich
2020-03-26 7:24 ` Jürgen Groß
2020-03-26 8:49 ` Jan Beulich
2020-03-26 8:50 ` Jürgen Groß
2020-03-26 9:14 ` Julien Grall
2020-03-25 10:55 ` Juergen Gross [this message]
2020-03-25 10:55 ` [Xen-devel] [PATCH v7 4/5] xen/rcu: add assertions to debug build Juergen Gross
2020-03-25 10:55 ` [Xen-devel] [PATCH v7 5/5] xen/rcu: add per-lock counter in debug builds Juergen Gross
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=20200325105511.20882-4-jgross@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@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).