All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Joel Fernandes <joel@joelfernandes.org>,
	Marco Elver <elver@google.com>,
	syzbot <syzbot+134336b86f728d6e55a0@syzkaller.appspotmail.com>,
	josh@joshtriplett.org, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
	rcu@vger.kernel.org, a@unstable.cc,
	b.a.t.m.a.n@lists.open-mesh.org, davem@davemloft.net,
	LKML <linux-kernel@vger.kernel.org>,
	mareklindner@neomailbox.ch, netdev@vger.kernel.org,
	sw@simonwunderlich.de, syzkaller-bugs@googlegroups.com
Subject: Re: KCSAN: data-race in find_next_bit / rcu_report_exp_cpu_mult
Date: Tue, 8 Oct 2019 11:58:34 +0800	[thread overview]
Message-ID: <20191008035834.GB2609633@tardis> (raw)
In-Reply-To: <20191008033353.GK2689@paulmck-ThinkPad-P72>

[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]

On Mon, Oct 07, 2019 at 08:33:53PM -0700, Paul E. McKenney wrote:
[...]
> > ---
> >  kernel/rcu/tree_exp.h | 17 +++++++----------
> >  1 file changed, 7 insertions(+), 10 deletions(-)
> > 
> > diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h
> > index af7e7b9c86af..fb51752ac9a6 100644
> > --- a/kernel/rcu/tree_exp.h
> > +++ b/kernel/rcu/tree_exp.h
> > @@ -372,12 +372,10 @@ static void sync_rcu_exp_select_node_cpus(struct work_struct *wp)
> >  	raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
> >  
> >  	/* IPI the remaining CPUs for expedited quiescent state. */
> > -	for_each_leaf_node_cpu_mask(rnp, cpu, rnp->expmask) {
> > +	for_each_leaf_node_cpu_mask(rnp, cpu, mask_ofl_ipi) {
> >  		unsigned long mask = leaf_node_cpu_bit(rnp, cpu);
> >  		struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
> >  
> > -		if (!(mask_ofl_ipi & mask))
> > -			continue;
> >  retry_ipi:
> >  		if (rcu_dynticks_in_eqs_since(rdp, rdp->exp_dynticks_snap)) {
> >  			mask_ofl_test |= mask;
> 
> This part I have already on -rcu branch "dev".
> 
> > @@ -389,10 +387,10 @@ static void sync_rcu_exp_select_node_cpus(struct work_struct *wp)
> >  		}
> >  		ret = smp_call_function_single(cpu, rcu_exp_handler, NULL, 0);
> >  		put_cpu();
> > -		if (!ret) {
> > -			mask_ofl_ipi &= ~mask;
> > +		/* the CPU responses the IPI, and it will report QS itself */
> > +		if (!ret)
> >  			continue;
> > -		}
> > +
> >  		/* Failed, raced with CPU hotplug operation. */
> >  		raw_spin_lock_irqsave_rcu_node(rnp, flags);
> >  		if ((rnp->qsmaskinitnext & mask) &&
> > @@ -403,13 +401,12 @@ static void sync_rcu_exp_select_node_cpus(struct work_struct *wp)
> >  			schedule_timeout_uninterruptible(1);
> >  			goto retry_ipi;
> >  		}
> > -		/* CPU really is offline, so we can ignore it. */
> > -		if (!(rnp->expmask & mask))
> > -			mask_ofl_ipi &= ~mask;
> > +		/* CPU really is offline, and we need its QS. */
> > +		if (rnp->expmask & mask)
> > +			mask_ofl_test |= mask;
> >  		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
> >  	}
> >  	/* Report quiescent states for those that went offline. */
> > -	mask_ofl_test |= mask_ofl_ipi;
> >  	if (mask_ofl_test)
> >  		rcu_report_exp_cpu_mult(rnp, mask_ofl_test, false);
> >  }
> 
> Would you be willing to port this optimization on top of current -rcu
> branch "dev" with an suitably modified commit message?
> 

Sure, will do ;-)

Regards,
Boqun

> 							Thanx, Paul

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-10-08  3:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 10:01 KCSAN: data-race in find_next_bit / rcu_report_exp_cpu_mult syzbot
2019-10-07 10:04 ` Marco Elver
2019-10-07 13:22   ` Paul E. McKenney
2019-10-07 13:34   ` Steven Rostedt
2019-10-07 13:43   ` Boqun Feng
2019-10-08  0:11     ` Joel Fernandes
2019-10-08  2:12       ` Paul E. McKenney
2019-10-08  2:50         ` Boqun Feng
2019-10-08  3:33           ` Paul E. McKenney
2019-10-08  3:58             ` Boqun Feng [this message]
2019-10-08  1:47   ` Paul E. McKenney
2020-01-25 10:42   ` [tip: core/rcu] rcu: Use *_ONCE() to protect lockless ->expmask accesses tip-bot2 for Paul E. McKenney

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=20191008035834.GB2609633@tardis \
    --to=boqun.feng@gmail.com \
    --cc=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=elver@google.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mareklindner@neomailbox.ch \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sw@simonwunderlich.de \
    --cc=syzbot+134336b86f728d6e55a0@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 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.