Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 910BCC54E94 for ; Thu, 26 Jan 2023 11:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237024AbjAZLPx (ORCPT ); Thu, 26 Jan 2023 06:15:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236972AbjAZLPv (ORCPT ); Thu, 26 Jan 2023 06:15:51 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E6E410CD; Thu, 26 Jan 2023 03:15:50 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33988C14; Thu, 26 Jan 2023 03:16:31 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.10.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 402733F71E; Thu, 26 Jan 2023 03:15:40 -0800 (PST) Date: Thu, 26 Jan 2023 11:15:37 +0000 From: Mark Rutland To: Jules Maselbas Cc: Yann Sionneau , Arnd Bergmann , Jonathan Corbet , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Will Deacon , Peter Zijlstra , Boqun Feng , Eric Biederman , Kees Cook , Oleg Nesterov , Ingo Molnar , Waiman Long , "Aneesh Kumar K.V" , Andrew Morton , Nick Piggin , Paul Moore , Eric Paris , Christian Brauner , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guillaume Thouvenin , Clement Leger , Vincent Chardon , Marc =?utf-8?B?UG91bGhpw6hz?= , Julian Vetter , Samuel Jones , Ashley Lesdalons , Thomas Costis , Marius Gligor , Jonathan Borne , Julien Villette , Luc Michel , Louis Morhet , Julien Hascoet , Jean-Christophe Pince , Guillaume Missonnier , Alex Michon , Huacai Chen , WANG Xuerui , Shaokun Zhang , John Garry , Guangbin Huang , Bharat Bhushan , Bibo Mao , Atish Patra , "Jason A. Donenfeld" , Qi Liu , Jiaxun Yang , Catalin Marinas , Mark Brown , Janosch Frank , Alexey Dobriyan , Benjamin Mugnier , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-audit@redhat.com, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Subject: Re: [RFC PATCH v2 11/31] kvx: Add atomic/locking headers Message-ID: References: <20230120141002.2442-1-ysionneau@kalray.eu> <20230120141002.2442-12-ysionneau@kalray.eu> <20230126095720.GF5952@tellis.lin.mbt.kalray.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230126095720.GF5952@tellis.lin.mbt.kalray.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jules, On Thu, Jan 26, 2023 at 10:57:20AM +0100, Jules Maselbas wrote: > Hi Mark, > > On Fri, Jan 20, 2023 at 03:18:48PM +0000, Mark Rutland wrote: > > On Fri, Jan 20, 2023 at 03:09:42PM +0100, Yann Sionneau wrote: > > > +#define ATOMIC64_RETURN_OP(op, c_op) \ > > > +static inline long arch_atomic64_##op##_return(long i, atomic64_t *v) \ > > > +{ \ > > > + long new, old, ret; \ > > > + \ > > > + do { \ > > > + old = v->counter; \ > > > > This should be arch_atomic64_read(v), in order to avoid the potential for the > > compiler to replay the access and introduce ABA races and other such problems. > Thanks for the suggestion, this will be into v3. > > > For details, see: > > > > https://lore.kernel.org/lkml/Y70SWXHDmOc3RhMd@osiris/ > > https://lore.kernel.org/lkml/Y71LoCIl+IFdy9D8@FVFF77S0Q05N/ > > > > I see that the generic 32-bit atomic code suffers from that issue, and we > > should fix it. > I took a look at the generic 32-bit atomic, but I am unsure if this > needs to be done for both the SMP and non-SMP implementations. But I > can send a first patch and we can discuss from there. Sounds good to me; thanks! [...] > > > +static inline int arch_atomic_add_return(int i, atomic_t *v) > > > +{ > > > + int new, old, ret; > > > + > > > + do { > > > + old = v->counter; > > > > Likewise, arch_atomic64_read(v) here. > ack, this will bt arch_atomic_read(v) here since this is not atomic64_t > here. Ah, yes, my bad! Thanks, Mark.