Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp872480iog; Mon, 13 Jun 2022 15:02:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1syVQNw8W+mtQ88/o0Egr6mmB5Wbl5TvcxJz3TwRbvfUffyDJ/PDxYZ9UznAdNNZc1ujPWk X-Received: by 2002:a17:90a:bb97:b0:1ea:667b:15bd with SMTP id v23-20020a17090abb9700b001ea667b15bdmr839899pjr.215.1655157722379; Mon, 13 Jun 2022 15:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655157722; cv=none; d=google.com; s=arc-20160816; b=Kb3mzo2yf8MgP42SJRQOrmGQtGH/nCHxORbl/TFs2llpWKH65SBSlxBiniNx2XUk2S Ek49LXFmNZ5qJIUxCCRMyUF1BmtMt8kfov7M8sK8XWEswRuYvK7A3G9OrvWIM8HMQcYB L1T2MgmNTkg7aKja7lJAh8CiFPGZif5IlN1GXuwwv1AI4ENVPkMJ3/xGApLzIqdSrwtQ SmkK4J+qcLWvcYFFXdJwPrYmceeJifP905pY0Pc/CL8E0PAm19lR3maVfWl/r60x7VT7 lfKQLfuZ7SwopkyTo4LPLvxNRzwSWhNKHH814MUPOI8k3ogXWAMCRG3OeoOWxDrE2zc2 ug/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=G4iopq3IS0Fg+YgPcnHTIpUYqzyq81TdTIDsujX/Aro=; b=LKfYrBcFzAvRgrsI7ztMGyk86DOw+jtofxg2sTTVIari6v5eIt/yHDDFJ3qdYGu6QC VhFi7sTIezmREcQOKVZ64xyq6FAJ+SQ7/l3QKZ2uGj22DEKwgwx+UP2EvBVFkEF3rBG6 MwPmrg6nj2iQE4hfH2G5Y+wIgaDBCiVF6569Iymrv3rRU+C5AK1aG4bDIUHiT9E09QVS Qx4C+754ivxthNH9BPCvTyI2ln3rtEuPpwkbbeIxikFjP7KClyOdfAZecK5NUrNsiBDR Cg2nKXvVtSf5oGC0pHKvdBYooaSXluvoKmYPtAwfJsUuzk1ONr3gDDi+JfNXx+vHKZKD PfIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a63ce4a000000b003fdc5a65a32si11921394pgi.406.2022.06.13.15.01.47; Mon, 13 Jun 2022 15:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241786AbiFMVbt convert rfc822-to-8bit (ORCPT + 99 others); Mon, 13 Jun 2022 17:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352120AbiFMVaJ (ORCPT ); Mon, 13 Jun 2022 17:30:09 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BFCBF192 for ; Mon, 13 Jun 2022 14:29:50 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-170-9N43S4nTPaqalKCbtLkcWA-1; Mon, 13 Jun 2022 22:29:47 +0100 X-MC-Unique: 9N43S4nTPaqalKCbtLkcWA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Mon, 13 Jun 2022 22:29:46 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.036; Mon, 13 Jun 2022 22:29:46 +0100 From: David Laight To: "'Luck, Tony'" , "Lobakin, Alexandr" , Marco Elver CC: Andy Shevchenko , Arnd Bergmann , Yury Norov , Mark Rutland , Matt Turner , Brian Cain , Geert Uytterhoeven , "Yoshinori Sato" , Rich Felker , "David S. Miller" , Kees Cook , "Peter Zijlstra (Intel)" , Borislav Petkov , "Greg Kroah-Hartman" , "linux-alpha@vger.kernel.org" , "linux-hexagon@vger.kernel.org" , "linux-ia64@vger.kernel.org" , "linux-m68k@lists.linux-m68k.org" , "linux-sh@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2 2/6] bitops: always define asm-generic non-atomic bitops Thread-Topic: [PATCH v2 2/6] bitops: always define asm-generic non-atomic bitops Thread-Index: AQHYfL4xWJEoq3eTcEeKREBjFjjrHK1JHg2A//+t5kCAAH9LAIAEkeOA//+tDzCAAFKXkA== Date: Mon, 13 Jun 2022 21:29:46 +0000 Message-ID: <5d65491caf6249c8b72c7a6ced95614c@AcuMS.aculab.com> References: <20220610113427.908751-1-alexandr.lobakin@intel.com> <20220610113427.908751-3-alexandr.lobakin@intel.com> <22042c14bc6a437d9c6b235fbfa32c8a@intel.com> <20220613141947.1176100-1-alexandr.lobakin@intel.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luck, Tony > Sent: 13 June 2022 17:27 > > >> It's listed in Documentation/atomic_bitops.txt. > > > > Oh, so my memory was actually correct that I saw it in the docs > > somewhere. > > WDYT, should I mention this here in the code (block comment) as well > > that it's atomic and must not lose `volatile` as Andy suggested or > > it's sufficient to have it in the docs (+ it's not underscored)? > > I think a comment that the "volatile" is required to prevent re-ordering > is enough. > > But maybe others are sufficiently clear on the meaning? I once wasted > time looking for the non-atomic __test_bit() version (to use in some code > that was already protected by a spin lock, so didn't need the overhead > of an "atomic" version) before realizing there wasn't a non-atomic one. Does it make any sense for 'test bit' to be atomic? I'm not even sure is needs any ordering constraints either. The result is always stale - the value can be changed by another cpu at any time. The set/clear atomic bit-ops require a RMW bus cycle - which has to be locked (or similar) to avoid corruption. The atomic 'test and set' (etc) are RMW and return a valid state. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)