Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2885776ybz; Sun, 19 Apr 2020 12:04:34 -0700 (PDT) X-Google-Smtp-Source: APiQypJSyL4EYojOUNdPRDowBcW9iOldqfDtXZGVxGSIqnPxamSnK2m4fnHQ3R1PLQEzSjqvZwqC X-Received: by 2002:a05:6402:684:: with SMTP id f4mr11653000edy.240.1587323074227; Sun, 19 Apr 2020 12:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587323074; cv=none; d=google.com; s=arc-20160816; b=PE5fe8rtdckJ3GQ32PgWhqcBvgdXvP2gQIt+C1sHc2hmLSPAbEMK5i7YjTPKEImsgC +Jy7zaGwLRy5pgNJ5o57jykEerHZzeNUDi5rSFIQ2MWNAHOKKeXrka881vwsKeDK1Fec +1N0AmMtYde7fqBanlFLY4AP7YRCh2V3aHjnynQXM1Fyj27FOAkNwSySglqJcbW6PQF2 dnPYsyoTGvWffIM/4wK+K1qznroikbbZvaiPsnWxri2ulcu2hvB6R9A+hDk7IRJfiWOm lHnf8lpsX39FruJoF+4/Ds/JC5VRQhH9dNFohqAHShMREGe+DH7JLOHuiHYC7Cmn041q oLnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=CmcqOEObTFQdLOt2UGQJN9HJojqis9n0w6pP7bmFv/M=; b=Fc4r6S/U/XUYrDwfkkQT8hO858sJY9k1opjnTdwKkw1/FtogehlimsNMQrYwz+isfA fP6jVn9VtueRn4BuCg5z0nlOoPZGP0dLQjRXWO9A2ZY1thY9l5CUeYJ6cuItKTGHJafC tr5SAJgAQDyhn0DNzfm0gdpJx4SDHuFhu46u9c+vJl8YGuotCp2q6PV3P83a2hq+0mi5 8+xFRZITU8gpRsykcK/C9eyQEKI6e0sX7LexFBY7yLlgK0vftPNnM2Mom/CqCdvYF5d9 IfpVvilw5CReJ4nCHojPEqEOnmXGBGMRp+jakZlwMDeYgies86C8T9LcMzPM9xmNRGd1 6Kmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=kipdzsx0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si10697200edx.256.2020.04.19.12.04.11; Sun, 19 Apr 2020 12:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@konsulko.com header.s=google header.b=kipdzsx0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726522AbgDSSaC (ORCPT + 99 others); Sun, 19 Apr 2020 14:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725969AbgDSSaB (ORCPT ); Sun, 19 Apr 2020 14:30:01 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5128EC061A0C for ; Sun, 19 Apr 2020 11:30:00 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id k1so9348618wrx.4 for ; Sun, 19 Apr 2020 11:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=CmcqOEObTFQdLOt2UGQJN9HJojqis9n0w6pP7bmFv/M=; b=kipdzsx0Tpo/fTLe0XupzLUeI/oipi7lAyUTe7Y9vl8IL3yRx3Kj4woQduhVdMCQ8P /tg8obAXM2Ht88W3vGlUrStq0nlnlr9RjSZmJlg5F0sXwdApOR3KjWvb71oGDb4VkOOK Viqg5ARaRMi/83TWN/42CotoZfmdWP7vP5HXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=CmcqOEObTFQdLOt2UGQJN9HJojqis9n0w6pP7bmFv/M=; b=HiyK6JBVEO3uJEGPfTDZYByu++vMGiamTHgpX3x69rFbfAm3j0juEkBVl9+8bWEVQs hZvWF1GbXwsjRFhbmBKcrmf+yDdSneK2rPNmdMCONSFrf9OM4RaUbE0MJmI3NtcE90WQ ajObuv8cLCrEf6Xz5U+1VaxGttNBiVFIzKGZ8EzWH5cCzjb6pTaLhhG7EMCYKEfWju2B dGDsIBTNmagB+vcTCsogTJf2dHB3ZIZmlZPqbKzgHPvCt75wSJgpfRy0EitQw65z+oda GhcT8YYW3rbPvDm8EHlgDoi28PcPwpIGsn6iStp/DanUbV5kT3EWz1UN0iYGkA39tu9O 4aRQ== X-Gm-Message-State: AGi0Pua+qxjaIcn/KjdiJl29U+1Koh7fg8mUOBApiTCMZzA8MAXlL6h9 LjUdMV5nVSoIvaGWwwe6nh3srQ== X-Received: by 2002:adf:e58d:: with SMTP id l13mr15268746wrm.187.1587320999047; Sun, 19 Apr 2020 11:29:59 -0700 (PDT) Received: from carbon ([94.26.108.4]) by smtp.gmail.com with ESMTPSA id 5sm16653274wmg.34.2020.04.19.11.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 11:29:58 -0700 (PDT) Date: Sun, 19 Apr 2020 21:29:57 +0300 From: Petko Manolov To: David Laight Cc: "Paul E . McKenney" , LKML Subject: Re: [RFC] WRITE_ONCE_INC() and friends Message-ID: <20200419182957.GA36919@carbon> Mail-Followup-To: David Laight , "Paul E . McKenney" , LKML References: <20200419094439.GA32841@carbon> <491f0b0bc9e4419d93a78974fd7f44c7@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <491f0b0bc9e4419d93a78974fd7f44c7@AcuMS.aculab.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-04-19 18:02:50, David Laight wrote: > From: Petko Manolov > > Sent: 19 April 2020 10:45 > > Recently I started reading up on KCSAN and at some point I ran into stuff like: > > > > WRITE_ONCE(ssp->srcu_lock_nesting[idx], ssp->srcu_lock_nesting[idx] + 1); > > WRITE_ONCE(p->mm->numa_scan_seq, READ_ONCE(p->mm->numa_scan_seq) + 1); > > If all the accesses use READ/WRITE_ONCE() why not just mark the structure > field 'volatile'? This is a bit heavy. I guess you've read this one: https://lwn.net/Articles/233479/ And no, i am not sure all accesses are through READ/WRITE_ONCE(). If, for example, all others are from withing spin_lock/unlock pairs then we _may_ not need READ/WRITE_ONCE(). I merely proposed the _INC() variant for better readability. Petko