Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1099911ybp; Wed, 9 Oct 2019 08:48:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwolevTiM+cEpynjlPDjgKaRkdn01mDEelrEcPgote4e7PurK75aTHfr51Nfj6aHT20B4NW X-Received: by 2002:a05:6402:21c7:: with SMTP id bi7mr3614569edb.205.1570636137296; Wed, 09 Oct 2019 08:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570636137; cv=none; d=google.com; s=arc-20160816; b=oUz1fh2kWdmdueT19ISygYvWh++d+Vi0dzwBn/pXHg2Db1KZrCIgGkjfYzqWYz0WN1 ygxtw9pVCRSawThLDNhv9t9fnbdmpgvr7wjZuZM/0PWOKkHFFzILWaVXjsLiQNd0fYjq pM0ABocMdPStfwpxGLhLmZPp4cTCMm2QqQn892WXPViSBwJdR5+iViX1JOlSb+Nc0C/S NFh8YCnwjk+QaTQ3dDC86/7QZ00+JloFFBqWX6a64gFVOtrV9u/FslAnGvGecuvGn8X1 74gGnUkStpSqMFX71vydyMBTRgb1F3sDV3S+Xya8ReQU2jCZEf17jH2CE0LNKs2bEnLB XtBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=LfiWtlrJOe48YJ1egCn4pCd1KZhSZBQodUxKMjmM7Qg=; b=h7mvvKZ6ng898zS4ArH6bFpjmgjLQWaF3Y5HxK8doGTrsU4GqJpVDUqSb8DzC5N2aZ pabO9L4cIRnGDVhQ4deg54TjB6I+oWz77tpM/ilAvpLpAz8GfsBpz2zqZfWw+5iX26q2 XNZgEmS4aNEQP0FY+hdwjGUa6a2hrl+xd+TKheyAJj460b1s4eJDclJ6WzVAgs2cbQIi 50qKO+iMYMRK9c0IYOhJ6LF56CcOw+W52O0Xhcx5WGFbaAy6pCkR1hZfka2/AXrUkR8Q uzUwJr2RBd6JgPhb6kxTbzz1lhx+MTS2Ee4ox2LldBoQjegkVQxie7crS/j8D6NsWw8i Xquw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v7CCczIw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si1360897eja.5.2019.10.09.08.48.33; Wed, 09 Oct 2019 08:48:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v7CCczIw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731442AbfJIPpy (ORCPT + 99 others); Wed, 9 Oct 2019 11:45:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:44496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729644AbfJIPpy (ORCPT ); Wed, 9 Oct 2019 11:45:54 -0400 Received: from paulmck-ThinkPad-P72 (mobile-166-177-250-63.mycingular.net [166.177.250.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA7642053B; Wed, 9 Oct 2019 15:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570635953; bh=6VNczijm7dR3WIsRcl2V0xeLyKxkwaweQslIMAwrUNg=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=v7CCczIwHTfOtyskNZ9whMMqCgEuT6J742xrfO3eWKtCAeGyj/PFDBQSHQArMVL7H gSHa1HZbPwxI9yp+yeHsi7W8Xem7m4u8shw59SwThvyQbxe3JGCYTZL+fNo6/E7KlU jgIXuqhP1hHxTObV1SjeKahIO69NH+UWtERbQ95g= Date: Wed, 9 Oct 2019 08:45:48 -0700 From: "Paul E. McKenney" To: Marco Elver Cc: Joel Fernandes , Boqun Feng , LKML , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , rcu@vger.kernel.org Subject: Re: [PATCH] rcu: Avoid to modify mask_ofl_ipi in sync_rcu_exp_select_node_cpus() Message-ID: <20191009154548.GB2689@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20191008050145.4041702-1-boqun.feng@gmail.com> <20191008163028.GA136151@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 08, 2019 at 06:35:45PM +0200, Marco Elver wrote: > On Tue, 8 Oct 2019 at 18:30, Joel Fernandes wrote: > > > > On Tue, Oct 08, 2019 at 01:01:40PM +0800, Boqun Feng wrote: > > > "mask_ofl_ipi" is used for iterate CPUs which IPIs are needed to send > > > to, however in the IPI sending loop, "mask_ofl_ipi" along with another > > > variable "mask_ofl_test" might also get modified to record which CPU's > > > quiesent state can be reported by sync_rcu_exp_select_node_cpus(). Two > > > variables seems to be redundant for such a propose, so this patch clean > > > things a little by solely using "mask_ofl_test" for recording and > > > "mask_ofl_ipi" for iteration. This would improve the readibility of the > > > IPI sending loop in sync_rcu_exp_select_node_cpus(). > > > > > > Signed-off-by: Boqun Feng > > > --- > > > > Reviewed-by: Joel Fernandes (Google) > > > > thanks, > > > > - Joel > > Acked-by: Marco Elver > > If this is the official patch for the fix to the KCSAN reported > data-race, it'd be great to include the tag: > Reported-by: syzbot+134336b86f728d6e55a0@syzkaller.appspotmail.com > so the bot knows this was fixed. I applied your Acked-by to both patches, but please let me know if you intended something else. Either way, thank you both for finding this and for your testing! Thanx, Paul > Thanks! > -- Marco > > > > kernel/rcu/tree_exp.h | 13 ++++++------- > > > 1 file changed, 6 insertions(+), 7 deletions(-) > > > > > > diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h > > > index 69c5aa64fcfd..212470018752 100644 > > > --- a/kernel/rcu/tree_exp.h > > > +++ b/kernel/rcu/tree_exp.h > > > @@ -387,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 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) && > > > @@ -401,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 to pass GP. */ > > > + 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); > > > } > > > -- > > > 2.23.0 > > >