Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5881441ybp; Tue, 8 Oct 2019 09:37:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDjvz+nQlz9isZ+tPz5sWAhrjnhrljCtsWvZC5rxQYZoOedtxd5BHYybP7KkGhYpb4xL9V X-Received: by 2002:a50:95c1:: with SMTP id x1mr34483931eda.180.1570552630797; Tue, 08 Oct 2019 09:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570552630; cv=none; d=google.com; s=arc-20160816; b=CGxqlpjkWfR/VYNvJX850GGEmHhHAJmM/KVCCAKS2QtNc4Un8Zlk49kr+IculcYq7s GpKb7K/77uCJjD6PTBOUEk88k6qTCub4c+cIFJw8vLnofLKczx+yw7HvwQSQXpVWGWXo oTh5o3cR2X+DX+FDKYw0/yJmF93ZoZgf0LnpOdcfbBn2vuEo0TevFoN9kJwhbenvYtYF cdYuL20lZbzNBgx/jAzQWKIvx6GtfTbvxOKcPMUcAQ+AOkMPNaVQEDYlSzkdrcONuRdi 0dtg7maUmuGK7J1Wr4s3pzmgP4sgrQE+MuhAJ4plsHmLhsXBNZxnmwZqcpUO45xLC09S F0Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GZeF9+x7oA1LkT60KPu6aRKTIGksyJ9mdpR8n367HKI=; b=IzCnmaVG9gfQPjnLl9wOMDZYZ/6LcapFz+o8khqgFFF/11sO7L2v7OQoFj2PKCi4Ek /oc8NfDfeaPzn1UV3DVoYMBZeYr5udKAUsWUq/Svt9UpYCUKjArvySZmYtiOBhLnnvgc TjDt5eERFgB5/vbzmZckwWFhWVAvF5/WWk37E/lwKM+c6HJGFHioS/0/qOwBB7eOxE8u CLtUEz/mTf0Yzgr1dopJwFteR7wD5OrnVkqgTBaCg9DEykjL+tG8Xx4ddto/KaodsdVY oxczaztY0NkYhLMcUsfpcxjTG4yNVo9TWTOg/97COoBYRrN+JTTRLdtTtqJ79/yKPik2 HbLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jCEpS9kZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si9181400eja.290.2019.10.08.09.36.46; Tue, 08 Oct 2019 09:37:10 -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=@google.com header.s=20161025 header.b=jCEpS9kZ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbfJHQf6 (ORCPT + 99 others); Tue, 8 Oct 2019 12:35:58 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45050 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbfJHQf5 (ORCPT ); Tue, 8 Oct 2019 12:35:57 -0400 Received: by mail-ot1-f66.google.com with SMTP id 21so14545568otj.11 for ; Tue, 08 Oct 2019 09:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GZeF9+x7oA1LkT60KPu6aRKTIGksyJ9mdpR8n367HKI=; b=jCEpS9kZZoxfVWjoZh+93nUsTUTlU358yVr8bpGo3tSg7PHOrbIkUuF6i4hwfUtpSg o7+43jzDmAIjU5KF78mIrOGAE6WVYVblEsABdznS7UHciO5aF9oxXCE3GXpgMIKCsgWO Nu0JSU95/DwEb1RIN4vgAupU7Af0eycfAW5vRFe8zHcUwnLPvFjShPoJ/HVNqs38c9iu jM0CrtMBuJwIDv86gU+LEquR+Pj+ZxZUcS9klCO6VbfEqQTEJ3qFv9t1JzrWuYms4w+B aibsOHRD3JvWJwJo+IsbO3iM3vIYG500Nh59c5rA3jIOsFFJi9bXHh14AeU4Ved+jNGz XaCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GZeF9+x7oA1LkT60KPu6aRKTIGksyJ9mdpR8n367HKI=; b=KuMzaG0WxK3lDc8WanjpwM8b8RFvt5+MmbrahNVwQjDNSYy7D2W6KOnPnm3k7Ix4e5 9ckvQGIYU2ElSfLpVSJZCcXhewgg4dZhHv5ETzD8oj64vXDbEeKwu1STr+c3reXxt6kY pkprSsZYK1tNtGcN/Z7fClg1KOW28lR4joXWqBRvnMQ/OCPFocXXKS+96Z6JBrKWpITy 4RqrsG6UlVqZVc1oddzJZTDPAeW0zop6UELDFaLTrdeFrX4JkXuCY1PLW9Ln+n+E6Hw8 JCQ+XYoq9gvn5IpYnFFd5i2AAKbudUQAXZyV8S8o6Fmb+CfWOVFLusgx0pnEWdOZYxoY Ad+Q== X-Gm-Message-State: APjAAAXsXEiLM4eVo2/o8U/6HGPpPSQu5Mwo0dIf4DSblNMufrR/2Fk5 pDrUs0EWCEy/jOcV5d1IUFA8Im9TKPLpsVCevFF2so+TmjFfsA== X-Received: by 2002:a9d:68d7:: with SMTP id i23mr26631718oto.23.1570552556380; Tue, 08 Oct 2019 09:35:56 -0700 (PDT) MIME-Version: 1.0 References: <20191008050145.4041702-1-boqun.feng@gmail.com> <20191008163028.GA136151@google.com> In-Reply-To: <20191008163028.GA136151@google.com> From: Marco Elver Date: Tue, 8 Oct 2019 18:35:45 +0200 Message-ID: Subject: Re: [PATCH] rcu: Avoid to modify mask_ofl_ipi in sync_rcu_exp_select_node_cpus() To: Joel Fernandes Cc: Boqun Feng , LKML , "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , rcu@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 > >