From: Oleg Nesterov <oleg@redhat.com>
To: Nikolay Borisov <kernel@kyup.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: BUG_ON in rcu_sync_func triggered
Date: Tue, 13 Sep 2016 15:18:52 +0200 [thread overview]
Message-ID: <20160913131852.GA4112@redhat.com> (raw)
In-Reply-To: <57D7B6F5.4040106@kyup.com>
On 09/13, Nikolay Borisov wrote:
>
>
> I just re-run the test with kernel 4.4.14 and PROVE_RCU and DEBUG_RCU_OBJECTS
> enabled and here is what I got:
Thanks again!
Damn. This reminds me that I forgot to send the patch which reworks rcu/sync.c.
Will do this week. But we need to investigate anyway, and I see nothing wrong
in the current code.
What did you do to reproduce?
> The bug on is this one: BUG_ON(need_wait && need_sync);
OK... perhaps the unbalanced up_write... I'll try to look at freeze/thaw code,
could test the debugging patch below meanwhile?
Oleg.
--- a/kernel/rcu/sync.c
+++ b/kernel/rcu/sync.c
@@ -82,6 +82,12 @@ void rcu_sync_init(struct rcu_sync *rsp, enum rcu_sync_type type)
rsp->gp_type = type;
}
+static void xxx(struct rcu_sync *rsp)
+{
+ pr_crit("XXX: %p gp=%d cnt=%d cb=%d\n",
+ rsp, rsp->gp_state, rsp->gp_count, rsp->cb_state);
+}
+
/**
* rcu_sync_enter() - Force readers onto slowpath
* @rsp: Pointer to rcu_sync structure to use for synchronization
@@ -102,13 +108,14 @@ void rcu_sync_enter(struct rcu_sync *rsp)
bool need_wait, need_sync;
spin_lock_irq(&rsp->rss_lock);
+ if (WARN_ON(rsp->gp_count < 0)) xxx(rsp);
need_wait = rsp->gp_count++;
need_sync = rsp->gp_state == GP_IDLE;
if (need_sync)
rsp->gp_state = GP_PENDING;
spin_unlock_irq(&rsp->rss_lock);
- BUG_ON(need_wait && need_sync);
+ if (WARN_ON(need_wait && need_sync)) xxx(rsp);
if (need_sync) {
gp_ops[rsp->gp_type].sync();
@@ -122,7 +129,7 @@ void rcu_sync_enter(struct rcu_sync *rsp)
* Nobody has yet been allowed the 'fast' path and thus we can
* avoid doing any sync(). The callback will get 'dropped'.
*/
- BUG_ON(rsp->gp_state != GP_PASSED);
+ if (WARN_ON(rsp->gp_state != GP_PASSED)) xxx(rsp);
}
}
@@ -149,8 +156,9 @@ static void rcu_sync_func(struct rcu_head *rcu)
struct rcu_sync *rsp = container_of(rcu, struct rcu_sync, cb_head);
unsigned long flags;
- BUG_ON(rsp->gp_state != GP_PASSED);
- BUG_ON(rsp->cb_state == CB_IDLE);
+ if (WARN_ON(rsp->gp_count < 0)) xxx(rsp);
+ if (WARN_ON(rsp->gp_state != GP_PASSED)) xxx(rsp);
+ if (WARN_ON(rsp->cb_state == CB_IDLE)) xxx(rsp);
spin_lock_irqsave(&rsp->rss_lock, flags);
if (rsp->gp_count) {
@@ -189,6 +197,7 @@ static void rcu_sync_func(struct rcu_head *rcu)
void rcu_sync_exit(struct rcu_sync *rsp)
{
spin_lock_irq(&rsp->rss_lock);
+ if (WARN_ON(rsp->gp_count <= 0)) xxx(rsp);
if (!--rsp->gp_count) {
if (rsp->cb_state == CB_IDLE) {
rsp->cb_state = CB_PENDING;
@@ -208,7 +217,7 @@ void rcu_sync_dtor(struct rcu_sync *rsp)
{
int cb_state;
- BUG_ON(rsp->gp_count);
+ if (WARN_ON(rsp->gp_count)) xxx(rsp);
spin_lock_irq(&rsp->rss_lock);
if (rsp->cb_state == CB_REPLAY)
@@ -218,6 +227,6 @@ void rcu_sync_dtor(struct rcu_sync *rsp)
if (cb_state != CB_IDLE) {
gp_ops[rsp->gp_type].wait();
- BUG_ON(rsp->cb_state != CB_IDLE);
+ if (WARN_ON(rsp->cb_state != CB_IDLE)) xxx(rsp);
}
}
next prev parent reply other threads:[~2016-09-13 13:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <57D69CEC.5010103@kyup.com>
2016-09-12 13:01 ` BUG_ON in rcu_sync_func triggered Oleg Nesterov
2016-09-13 8:21 ` Nikolay Borisov
2016-09-13 13:18 ` Oleg Nesterov [this message]
2016-09-13 13:43 ` Oleg Nesterov
2016-09-13 14:35 ` Nikolay Borisov
2016-09-13 14:38 ` Nikolay Borisov
2016-09-13 14:39 ` Nikolay Borisov
2016-09-13 15:20 ` Oleg Nesterov
2016-09-14 6:30 ` Nikolay Borisov
2016-09-14 12:58 ` Oleg Nesterov
2016-09-23 13:35 ` Nikolay Borisov
2016-09-23 13:52 ` Oleg Nesterov
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=20160913131852.GA4112@redhat.com \
--to=oleg@redhat.com \
--cc=kernel@kyup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
/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).