Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp138887lqi; Wed, 6 Mar 2024 12:20:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuZRQ7aDjdE1BVuTOeO9XUjDqsD7kbA5kupQ9xKMVcig0CVjkECqf6zQXslsuNlnN+wysXoWo7UOBY6Qvhcx8TGhbAgUP35XDZxl+a1w== X-Google-Smtp-Source: AGHT+IGFbYvZsZG/f9YHKfgkIc0VZg+jMLo7AUgc4hCZ7s0FnclofYcvG++Md05iiZzylQ68Ylzh X-Received: by 2002:a05:622a:2d3:b0:42e:e0df:aec3 with SMTP id a19-20020a05622a02d300b0042ee0dfaec3mr6987403qtx.31.1709756441208; Wed, 06 Mar 2024 12:20:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709756441; cv=pass; d=google.com; s=arc-20160816; b=uUe+FBtLl36+Tm8/FH1yvQCbFWLA1V4UJWsVvsugXu8udZ8631pn9dxailhIeDlwyT c32AbCnoAKuwiInMy540+NObQz3iW6DiBbZ3Q/wWLM+uIk8DIzVHZBU89k9uFfriMqCT gyHsY0RTJGD+CwhghxHqXldMRFSgR7ewdkoPqeuA7u51COE11Bvws9eSXeq+Je+qYJNu laATZu2rvX5+TpZR3Eac+d6/f2Bd85ZdWXoTVnmMFPyGvncc6aP3wY4I3I74LtNfbXcZ y9sfOIapjzfKnIHqGmmd6Tqi0Ngrq7vrZ17+gr0DvBWEX7lB9im6zQ5Hl/3+ECSem1LY I7Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=3eBM56IgKWK3xhe9y5Rbhoc/hv2ZNbpBXfMCabxfGGA=; fh=sZSMCriFQ42ckROk0FQg4XZZLXjRF4WQhfBGnI90MKY=; b=eCorTPLxbqhzfDDpfAGvFI/3nyE83lHzhkcJKqLNV5dLSZKr1Rw1awccgx/t1PRa+F tiXpDCZnAyHmUvzGmcKW4CbzIFmC1UL+gXlSbsd8EaJ7437G8MFejgj2wooCbmVBmEgC A4y7+TG5QpOG5gfn4Soo50/ITLFb6Hg+2O5VVQPwny/CTsjCoYF7IcuAYXD0D80h7dpY x68znI4b10j7EOgmc0oedhBkK2HbklOc4hy7xJscmEtr8K3SvPZ+CuAom/aSxTZjKy7p UdrMVPwqVaqYT0262zrNB/nZ5c3eW6/LIsZ07cELa34O+lOQE2qm/84zzlRQeibuv78N o4TQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O9ahK6Rr; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-94556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94556-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g6-20020ac85806000000b0042f00f6a311si4761257qtg.161.2024.03.06.12.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:20:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O9ahK6Rr; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-94556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94556-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E3D301C22005 for ; Wed, 6 Mar 2024 20:20:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EE1E1419A2; Wed, 6 Mar 2024 20:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="O9ahK6Rr" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CDA137C29 for ; Wed, 6 Mar 2024 20:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709756434; cv=none; b=MFQCLWRMF6sgc8G/RgYRUyvT5ihw9DaASZigP1Y4yAhu4KiT+1hzVlTckYV+N1XyDfnkVhHFlR5BRho05Ckno8O9VZ9Lq/0ti4QruCKdm4OQozZ3M7BubklinS8o3F/F5VWY8Q6cpvzvPwv56sGXBOWW8UM5iQHn3ogJukp81qQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709756434; c=relaxed/simple; bh=1fMRZLipMrytyIL2P/bemn1/S7ehcHXKbZQM+j1zbmE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FECUYGW9PvP/Wj/2FoEPMIiKS33/rgFwXhki+Rt2ZUo1lq//s4ypFygnSEHyIafNOXdr1xnmY4oiT1ShDm6Zl2a33A92XioiAlNK1pk1HQ3+ApffhM9pRVA3TP0j0di9BPJ1rbxqpgO4G7cFv+hSchzejfC2+y2n76gkqw9ohr4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=O9ahK6Rr; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a45bdf6e9c2so22819366b.0 for ; Wed, 06 Mar 2024 12:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1709756431; x=1710361231; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3eBM56IgKWK3xhe9y5Rbhoc/hv2ZNbpBXfMCabxfGGA=; b=O9ahK6RrMAIhZ2N5wgmD/QXizmks9/fuI0hz5LNa/8PXh840Z7Vc0u22ld0JuRy6QY hoH/+7eRnhB6qXxu3JITOjBZZECVWpMxJDfyFHH9Ve4tfPgrJuk1a3vrQtQBdPSrkMlI upzR/v6cSEcEItSAGlVWUk9PbelvR/sJaFi1I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709756431; x=1710361231; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3eBM56IgKWK3xhe9y5Rbhoc/hv2ZNbpBXfMCabxfGGA=; b=T3g2PzdPo7prWJnWrfVwMuB2YRb3DMJaAjkDeCeqm+KjR20V/LG9e6NZOfPiEHpSGu c63pya3TIIvhxzLK27U8uiA55re/XmpECBqN12h7OzrMg2KTPtLMgc627OqXJkNPrVBN /RTBc0j5j7YkUwzp4FDkrJfUswIdvTBxzSjwwFUqspaDG/9IWORdq7j1uKrDznXSXmu6 LQR6DvxW31b56hSh3HcYYMw342rEuu2PfitVTEMkY3nm1B0BjTS5Jwto7fT92xuJnNy2 PPTySyE5S33CdVPMLUWZnJNNGpHq44yHE9Uv0IWmGYlJrf6gCmfb+Mi7hhsJhxifK9Np Jdzw== X-Forwarded-Encrypted: i=1; AJvYcCWmTr7ltdSerIaq1vyi+mUVO6EhkwdvJ6P6ImJJwyCPFlSq1+fMRX8bXk1S7IqtAvDwrkuMrDroYuWHoWL1Gqg29Es0sN2ZUT9YZhXD X-Gm-Message-State: AOJu0YwNekVBVKYAOGCx+gRKVNBPcrpcQWwB6Fzo8uRGH3kYBr4RyBvY dh74EhYXje9jDa6EloeQq32ex8fiOrRWSrgLkg0E6OxddYIKeTcSJqlkGqkIgPdLoKNkyDbgFwz X64ilWg== X-Received: by 2002:a17:906:a2c7:b0:a45:b84f:7ad8 with SMTP id by7-20020a170906a2c700b00a45b84f7ad8mr1948002ejb.13.1709756430980; Wed, 06 Mar 2024 12:20:30 -0800 (PST) Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com. [209.85.208.42]) by smtp.gmail.com with ESMTPSA id j23-20020a170906279700b00a45a62e0ed0sm2244670ejc.98.2024.03.06.12.20.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Mar 2024 12:20:29 -0800 (PST) Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-563b7b3e3ecso209023a12.0 for ; Wed, 06 Mar 2024 12:20:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWQPvi10DQdRS/7D+TD+Tox+qwSz7oKHBgUNL5VWFoaZnG+Uz/aci6jF3sLHAuY9w7NQg6e7RCfbwhFHb11bJ3vvLFr0XsAcX3bsjhs X-Received: by 2002:a17:906:5fd3:b0:a45:ac0f:38e4 with SMTP id k19-20020a1709065fd300b00a45ac0f38e4mr3620090ejv.38.1709756429144; Wed, 06 Mar 2024 12:20:29 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306103719.1d241b93@gandalf.local.home> <27665890-8314-4252-8622-1e019fee27e4@paulmck-laptop> <20240306130103.6da71ddf@gandalf.local.home> <20240306135504.2b3872ef@gandalf.local.home> <20240306142738.7b66a716@rorschach.local.home> In-Reply-To: From: Linus Torvalds Date: Wed, 6 Mar 2024 12:20:12 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] rcutorture: Fix rcu_torture_pipe_update_one()/rcu_torture_writer() data race and concurrency bug To: Steven Rostedt 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 Content-Type: text/plain; charset="UTF-8" On Wed, 6 Mar 2024 at 11:46, Linus Torvalds wrote: > > That 'rtort_pipe_count' should be an atomic_t, and the "add one and > return the old value" should be an "atomic_inc_return()-1" (the "-1" > is because "inc_return" returns the *new* value). Bah. I am lost in a twisty maze of operations, all the same. One final correction to myself: if you want the old value, the nicer thing to use is probably just "atomic_fetch_inc()". It generates the same result as "atomic_inc_return()-1", but since we do have that native "return old value" variant of this, let's just use it. So the rules are "atomic_op_return()" returns the new value after the op, and "atomic_fetch_op()" returns the old value. For some ops, this matters more than for others. For 'add' like operations, it's you can deduce the old from the new (and vice versa). But for bitwise ops, only the 'fetch" version makes much sense, because you can see the end result from that, but you can't figure out the original value from the final one. And to *really* confuse things, as with the memory ordering variants, we don't always have the full complement of operations. So we have atomic_fetch_and() (returns old version) and atomic_and() (doesn't return any version), but we don't have "atomic_and_return()" because it's less useful. But for 'inc' we have all three. Linus