Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp111525lqi; Wed, 6 Mar 2024 11:28:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/v85bjRHCGmkUct6rBCtJh2p9tfrITwPiAe+K2jwcJSuRqHHq5j11CpzP0evfBT6HHDMfBv4UvabReZmzdXWy+cS7G6y4ubDhRLT1Lg== X-Google-Smtp-Source: AGHT+IFNJt1RscfeW+t/Hg3NERSV2A3KYOyUlNRc2uBT1h1pfH6l5lz+QTEqYfs8IslR5HvK5ZNA X-Received: by 2002:a17:906:1c8d:b0:a44:415d:fa39 with SMTP id g13-20020a1709061c8d00b00a44415dfa39mr8704935ejh.37.1709753289571; Wed, 06 Mar 2024 11:28:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709753289; cv=pass; d=google.com; s=arc-20160816; b=WGcoplpKd4Riz5gHQkZhNi0lElXPnhXzZ8gciuasYfKoWjHmZEY7uf8Eow1fveUyvR n9H9HJxmudciv4sCJ74hcUME9r/t/zGsLODmKpCAWrYKhEPj+zszYdAT5V9AN+keOqHT E9s1uclGGKAIySU0sdLkuP8eJpDHDVxYiOwgOIMDOSuiDYg9ZBE3UDVd51Xsi8olThj0 9RfbMW8WPb+T+utSRRomG8rpoi5aqxZhEuK+sBTICvoigs0bIY7YgPtYGPwv0hu4X1OJ zyYM31urfTUZ6HDlbPfVS0yA0B9COEKQeuwW4VEXfSO+tHl9rlmLXaMhQa+yDweXxwhG AMQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=sSWavJMB9d4aLRH09TteNl2v0yYQP6/hpk2ycnyQaLE=; fh=4dU+JhieUHr/RI05mehfCLNhp2+1Zi8phVAoV5qYL6U=; b=rJULw7+Njfl9v1hpzoPnw0OE33fgrYzyCjq14D7viwFq+01+bPtbZZrm6z8vNNde0l S5X+FmqBOvqKlziDAUpcD+KQmQTyR7gsTeGwlgQ81w1mPyncXDXEa2hcK6cxfTngjf3B zAsh32G5I8DtRShq+c3ygMMMz2RjBWMiNtrVTtzWudnJe3dz6Gw3Ruy64bDXhDGMEH00 xa1TeHe7dFzovE79RDidC6yE5L/uKuDB18M2prnKjPoP7WyT3WdLt/q6CN/ZIKX9V8gp HbtDcsOAlxbvA+ddGehpa9WNDtPzgmKd2uQQQKrw2jr1rCD1gN7G7jihM19uJz8oP4Wx 6P6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-94478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94478-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f12-20020a17090624cc00b00a45c11d6102si504954ejb.866.2024.03.06.11.28.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 11:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-94478-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94478-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id A9FCF1F2534A for ; Wed, 6 Mar 2024 19:27:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25B8D13F45A; Wed, 6 Mar 2024 19:27:42 +0000 (UTC) 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 9C1E313E7F8; Wed, 6 Mar 2024 19:27:41 +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=1709753261; cv=none; b=AP7V9MBnqENoyLvdgoeFIi1OIsuWIrvq7TTl4EAtERGN4i5zJBk6WvZHiUCe47+FCSQQix60+VWMA8K5qrCwIYAnD1duZvXEfEPcDPQk6u8T1E4fTl4NbngCx98nwW26aHWwQhv0ymLRh5EhFGmuxLiYmvmK7ZztYmgUAiq9V3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709753261; c=relaxed/simple; bh=HTU+jL9vOuCHuBXKseXN19zfCWcmKm8VdJ5lvTYj6QM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=it9nPQb5MyiTXwEtOoq19ld/9m2geaBiYeybUW3jvmB3OYNSUOhtz9bxlCfBCOnDAKfok7VS4BkgcuF5AxXidRnWV/k4tgv0KqfS7Su2Jx9XG2NpvBzS9AJlx57WbkSIT1TTMordPUvXPF+BRtWHfup7Yc0cKiC5LgGXo77KoR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B192C433F1; Wed, 6 Mar 2024 19:27:39 +0000 (UTC) Date: Wed, 6 Mar 2024 14:27:38 -0500 From: Steven Rostedt To: Linus Torvalds Cc: "Paul E. McKenney" , linke li , joel@joelfernandes.org, boqun.feng@gmail.com, dave@stgolabs.net, frederic@kernel.org, jiangshanlai@gmail.com, josh@joshtriplett.org, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, qiang.zhang1211@gmail.com, quic_neeraju@quicinc.com, rcu@vger.kernel.org Subject: Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug Message-ID: <20240306142738.7b66a716@rorschach.local.home> In-Reply-To: References: <20240306103719.1d241b93@gandalf.local.home> <27665890-8314-4252-8622-1e019fee27e4@paulmck-laptop> <20240306130103.6da71ddf@gandalf.local.home> <20240306135504.2b3872ef@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Wed, 6 Mar 2024 11:01:55 -0800 Linus Torvalds wrote: > On Wed, 6 Mar 2024 at 10:53, Steven Rostedt wrote: > > > > Now, are you OK with an addition of ADD_ONCE() and/or INC_ONCE()? So that we > > don't have to look at: > > > > WRITE_ONCE(a, READ_ONCE(a) + 1); > > > > ? > > In a generic header file under include/linux/? > > Absolutely not. The above is a completely broken operation. There is > no way in hell we should expose it as a general helper. > > So there is no way we'd add that kind of sh*t-for-brains operation in > (for example) our header file next to the normal > READ/WRITE_ONCE defines. > > In some individual tracing C file where it has a comment above it how > it's braindamaged and unsafe and talking about why it's ok in that > particular context? Go wild. Note this has nothing to do with tracing. This thread is in RCU. I just happen to receive the same patch "fix" for my code. > > But honestly, I do not see when a ADD_ONCE() would ever be a valid > thing to do, and *if* it's a valid thing to do, why you'd do it with > READ_ONCE and WRITE_ONCE. > > If you don't care about races, just do a simple "++" and be done with > it. The end result is random. That was my feeling. But when I saw this going into RCU, I was thinking there was a more fundamental problem here. > > Adding a "ADD_ONCE()" macro doesn't make it one whit less random. It > just makes a broken concept even uglier. > > So honestly, I think the ADD_ONCE macro not only needs to be in some > tracing-specific C file, the comment needs to be pretty damn big too. > Because as a random number generator, it's not even a very good one. > So you need to explain *why* you want a particularly bad random number > generator in the first place. Again, this has nothing to do with tracing. The code here is solely in RCU. I did receive a patch in the tracing code, but that had to deal with wakeups of readers with respect to writers which is a common thing across the kernel and is not anything tracing specific. I wasn't about to take the patch to my code, but when I saw the same changes in RCU, then I thought this might be something I need to worry about. -- Steve