Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp469818lqr; Wed, 5 Jun 2024 11:05:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfSlTzrzUXAn+L0QVRV87LJrmK3GUxY7UKfEUKyV1463chucPhIWkCEMcK040BFSOj5LhV8ZmR5IUQfmNINeBucf+RQKBv5/se+vj2aQ== X-Google-Smtp-Source: AGHT+IEoDbdAz/vriIt95d1EaeDb92eXomACSHbdv/723lb9eNvLc45P586wMqfgkdhXjtdol8vS X-Received: by 2002:a05:6871:8a4:b0:250:8060:8cd0 with SMTP id 586e51a60fabf-2512275199emr3846121fac.34.1717610708438; Wed, 05 Jun 2024 11:05:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717610708; cv=pass; d=google.com; s=arc-20160816; b=UF+t5B69dVX4flpoF4jIzUYkCa9V3V0Fkj7/QB8KBIVB+fxcIIX/HSfuKfQOlE1LnL Cs2PoVxDe3IGVrGjyV7i+SHSiJSY4gj7nnRq5T6RqPwc1GNzVQzwG7gc8bJPCDge6gW2 l+ALa3HuCOWNW7+NelqGSvPt2MPa3s2NkPoAu5reY1uR6iDsUdyZdaZ5Uw12oM3eiNXI Wgu//GZaEzzemWeRvh4fTIdDbXWMt5EFih9GqsuD/4Wcb4U7WSAPBc76tio4mmrZHK1Q WJHIMfRoGLOQhNTsbMalhSe9uvMIwRAGr6rjmnj8mNBnGSsS3nFSnxjKOZiTK+Qc06SN grAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=72XRH3fs16colXDnarHCupgoVHglpLyASO/xR+1nDMk=; fh=LToqKqEk+yzgCvOsxFtHwPCoP5FGiohf+vfJvPaMjsE=; b=kvsWDMqFt/3pEw5JgcVjWsC3pS9UamNUgnsHE8IrhNvA1DypqFcsuNDpSJ8KzFZjVc lQ/n0g+BUkskMCOY+9I580NNvg+Y6KL48FB3qP0hpwNOmhCPJCtnlGj90zWmnhKDQXRn sj/aZNPSZwV+oEAVXEzLu+upEgpXEO7P6Jzt2Me6RhCmIRMxAEccyZn6BMNPwCUTIL/W hXGjASDtj3ldMkTa6XjvF1ZGdFzOW0Lzt4nLKJeX/+zZMp46wHCwP+CfmJLWX2HDEuRo q+1it1lrdWRSBMi/1EhJiyWzRuOPQ+fQLEL1lFK8qXQmMGjQ/zdmPwevK0Y/OqqZx0U+ DMig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k2FCUM3j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 71dfb90a1353d-4eafedbea33si211546e0c.56.2024.06.05.11.05.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 11:05:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k2FCUM3j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E1FF61C2174A for ; Wed, 5 Jun 2024 18:04:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFC01C152; Wed, 5 Jun 2024 18:02:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k2FCUM3j" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B86B2E3FE; Wed, 5 Jun 2024 18:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717610545; cv=none; b=nayqmzWzithe4rSuVLph3QKYfgzJQ/gQC4w7eGB1WuXDzb2H11AwobVrrbAQeCKCshDbTLv+Kcmbb1Hr/JOIzqkW5asstzgsaYwlTwUiMPxZGTn1eT9sBs7dc4xeTjc8wAZc85ufcknnsQFLLPB59wDbBYwVdisRVf3TEc9nmwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717610545; c=relaxed/simple; bh=Zk9QKYEwZkkHtEEFpKV+IP3hrfb4VZMRuIpGpAa5ek0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JWkMtdaNG0sveQtlWPHllKeshcqOylteanTn0hsGQaIfwCDRqXTow05MWhJJ1gJFlSuu+Kl0ORFiBopEll7fG+loOt41E/bC+ZshKSqHP9Fi/objT2Ee+XgcF0S43DKQW5//nzAr5YokNyoXkPW8u3ejPMf4AmRG/6esDXZ6f5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k2FCUM3j; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3F80C2BD11; Wed, 5 Jun 2024 18:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717610544; bh=Zk9QKYEwZkkHtEEFpKV+IP3hrfb4VZMRuIpGpAa5ek0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=k2FCUM3jalLFrx4q1Dz4Y71KSsrp27/0f/AUvryeI7Y2fZ7VXpaxfprSz6/Nm1wzZ Fgpg7W7DShjGOBtmuKFUWYE38fL218nUc9wmHx3JXIWLOBEjNRpOECz1LtJopr+vFp 3fN29SczD+nJ+ucuneXxYdQKJGRAy+h16Lf2Z2UdQz5riS3q3eooxlMSQ0f6/ySgUR S/+vLkWftdUptaZWO2Mfy6K/1sMeLLSDJsV/jbX6EMJ1fg2rOtvcEiWZozDvgg57zu YM7bvVsIzL0XcONWffVdY02teFfz78ZIO64fNY2sAyjSRwlQ3N6BKbm+qSdx/BH0q+ JJqA/DcPw4DBA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 56D38CE0A72; Wed, 5 Jun 2024 11:02:24 -0700 (PDT) Date: Wed, 5 Jun 2024 11:02:24 -0700 From: "Paul E. McKenney" To: Marco Elver Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Andrey Konovalov , kasan-dev@googlegroups.com Subject: Re: [PATCH rcu 2/4] rcutorture: Fix rcu_torture_fwd_cb_cr() data race Message-ID: <35f27cc8-85b5-4b30-8f7e-cbd29d3adb48@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240604223633.2371664-2-paulmck@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jun 05, 2024 at 09:56:41AM +0200, Marco Elver wrote: > On Wed, 5 Jun 2024 at 00:36, Paul E. McKenney wrote: > > > > On powerpc systems, spinlock acquisition does not order prior stores > > against later loads. This means that this statement: > > > > rfcp->rfc_next = NULL; > > > > Can be reordered to follow this statement: > > > > WRITE_ONCE(*rfcpp, rfcp); > > > > Which is then a data race with rcu_torture_fwd_prog_cr(), specifically, > > this statement: > > > > rfcpn = READ_ONCE(rfcp->rfc_next) > > > > KCSAN located this data race, which represents a real failure on powerpc. > > > > Signed-off-by: Paul E. McKenney > > Cc: Marco Elver > > Cc: Andrey Konovalov > > Cc: > > Nice find - was this found by KCSAN's weak memory modeling, i.e. the > report showed you that a reordered access resulted in a data race? If I remember correctly, yes. Even on x86, the compiler is free to reorder that WRITE_ONCE() with unmarked accesses, so one can argue that this bug is not specific to powerpc. > Acked-by: Marco Elver I will apply on my next rebase, thank you! Thanx, Paul > > --- > > kernel/rcu/rcutorture.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c > > index 44cc455e1b615..cafe047d046e8 100644 > > --- a/kernel/rcu/rcutorture.c > > +++ b/kernel/rcu/rcutorture.c > > @@ -2630,7 +2630,7 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp) > > spin_lock_irqsave(&rfp->rcu_fwd_lock, flags); > > rfcpp = rfp->rcu_fwd_cb_tail; > > rfp->rcu_fwd_cb_tail = &rfcp->rfc_next; > > - WRITE_ONCE(*rfcpp, rfcp); > > + smp_store_release(rfcpp, rfcp); > > WRITE_ONCE(rfp->n_launders_cb, rfp->n_launders_cb + 1); > > i = ((jiffies - rfp->rcu_fwd_startat) / (HZ / FWD_CBS_HIST_DIV)); > > if (i >= ARRAY_SIZE(rfp->n_launders_hist)) > > -- > > 2.40.1 > >