From mboxrd@z Thu Jan 1 00:00:00 1970 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 3146EC7EE2F for ; Thu, 1 Jun 2023 10:35:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232777AbjFAKfE (ORCPT ); Thu, 1 Jun 2023 06:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232191AbjFAKep (ORCPT ); Thu, 1 Jun 2023 06:34:45 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9087A8E; Thu, 1 Jun 2023 03:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1685615570; i=deller@gmx.de; bh=G2fVWfFa8Mg7zk8fckBtVkE46aW59z85USR51MF7qtA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=FmEhh+g+1DMt5R00VGwoA6elCJBKz5sYnrCS4k8pbs4FebbObsTMoS8ilG3++VVdP gNj+IpkiOmplBoLThMFtiF09gwNBcv0lLa3SddmTzCjnQAcAsEV+gQ4IBtia3VTe0q tAzyoTc4yp1UsMYHpvORsVDA4Z0vtf1JD1mZWgh9ltZBLhSBiHmnraCm4wJ38oQfL1 uPtjeboQwb5+cNsLX86hk7wLs9t+iTGic+maNc4YnIU/GKSF9v4CUlwOTClbhL7HfT GkEVVU9TosKjG0dG5Lplx/pL7aKB6FeDQbKeezr5taz3oH5M4y6JrWRaSXYSXLdHbS 3tntj4pI5wyMQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.56.61] ([109.43.49.30]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mqb1W-1qQkp02L1k-00mYV1; Thu, 01 Jun 2023 12:32:50 +0200 Message-ID: <14c50e58-fecc-e96a-ee73-39ef4e4617c7@gmx.de> Date: Thu, 1 Jun 2023 12:32:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 07/12] parisc/percpu: Work around the lack of __SIZEOF_INT128__ Content-Language: en-US To: Peter Zijlstra , Arnd Bergmann Cc: Linus Torvalds , Jonathan Corbet , Will Deacon , Boqun Feng , Mark Rutland , Catalin Marinas , dennis@kernel.org, Tejun Heo , Christoph Lameter , Heiko Carstens , gor@linux.ibm.com, Alexander Gordeev , borntraeger@linux.ibm.com, Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Joerg Roedel , suravee.suthikulpanit@amd.com, Robin Murphy , David Woodhouse , Baolu Lu , Herbert Xu , "David S . Miller" , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, iommu@lists.linux.dev, Linux-Arch , linux-crypto@vger.kernel.org, Stephen Rothwell , Michael Ellerman , "James E . J . Bottomley" , linux-parisc@vger.kernel.org, John David Anglin , Sam James References: <20230531130833.635651916@infradead.org> <20230531132323.722039569@infradead.org> <70a69deb-7ad4-45b2-8e13-34955594a7ce@app.fastmail.com> <20230601101409.GS4253@hirez.programming.kicks-ass.net> From: Helge Deller In-Reply-To: <20230601101409.GS4253@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:qA5DnM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DfP2o anH6ZPyfZQ6d4BLKrKYuyEVPj6FtGAUtN+xLNu0C1FQJFgpdr1j6Txfz7cmh2SG1zaEyeKXQ4 oXiPN6V3C8LedVzp/tvsi0kHrOtlI6iXIoTkBTy9WR2wsc3i777kCVAftkQkqBuYnkgkQ/rue 3QqTKVV3MwstFz1j8XAvezd2tOQ= Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org On 6/1/23 12:14, Peter Zijlstra wrote: > On Wed, May 31, 2023 at 04:21:22PM +0200, Arnd Bergmann wrote: > >> It would be nice to have the hack more localized to parisc >> and guarded with a CONFIG_GCC_VERSION check so we can kill >> it off in the future, once we drop either gcc-10 or parisc >> support. > > I vote for dropping parisc -- it's the only 64bit arch that doesn't have > sane atomics. Of course I'm against dropping parisc. > Anyway, the below seems to work -- build tested with GCC-10.1 I don't think we need to care about gcc-10 on parisc. Debian and Gentoo are the only supported distributions, while Debian requires gcc-12 to build > 6.x kernels, and I assume Gentoo uses at least gcc-12 as well. So raising the gcc limit for parisc only (at least temporarily for now) should be fine and your workaround below wouldn't be necessary, right? Helge > --- > Subject: parisc/percpu: Work around the lack of __SIZEOF_INT128__ > From: Peter Zijlstra > Date: Tue May 30 22:27:40 CEST 2023 > > HPPA64 is unique in not providing __SIZEOF_INT128__ across all > supported compilers, specifically it only started doing this with > GCC-11. > > Since the per-cpu ops are universally availably, and > this_cpu_{,try_}cmpxchg128() is expected to be available on all 64bit > architectures a wee bodge is in order. > > Sadly, while C reverts to memcpy() for assignment of POD types, it does > not revert to memcmp() for for equality. Therefore frob that manually. > > Signed-off-by: Peter Zijlstra (Intel) > --- > arch/parisc/include/asm/percpu.h | 77 ++++++++++++++++++++++++++++++= +++++++++ > 1 file changed, 77 insertions(+) > > --- /dev/null > +++ b/arch/parisc/include/asm/percpu.h > @@ -0,0 +1,77 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_PARISC_PERCPU_H > +#define _ASM_PARISC_PERCPU_H > + > +#include > + > +#if defined(CONFIG_64BIT) && CONFIG_GCC_VERSION < 1100000 > + > +/* > + * GCC prior to 11 does not provide __SIZEOF_INT128__ on HPPA64 > + * as such we need to provide an alternative implementation of > + * {raw,this}_cpu_{,try_}cmpxchg128(). > + * > + * This obviously doesn't function as u128 should, but for the purpose > + * of per-cpu cmpxchg128 it might just do. > + */ > +typedef struct { > + u64 a, b; > +} u128 __attribute__((aligned(16))); > + > +#define raw_cpu_generic_try_cmpxchg_memcmp(pcp, ovalp, nval) \ > +({ \ > + typeof(pcp) *__p =3D raw_cpu_ptr(&(pcp)); \ > + typeof(pcp) __val =3D *__p, __old =3D *(ovalp); \ > + bool __ret; \ > + if (!__builtin_memcmp(&__val, &__old, sizeof(pcp))) { \ > + *__p =3D nval; \ > + __ret =3D true; \ > + } else { \ > + *(ovalp) =3D __val; \ > + __ret =3D false; \ > + } \ > + __ret; \ > +}) > + > +#define raw_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) \ > +({ \ > + typeof(pcp) __old =3D (oval); \ > + raw_cpu_generic_try_cmpxchg_memcpy(pcp, &__old, nval); \ > + __old; \ > +}) > + > +#define raw_cpu_cmpxchg128(pcp, oval, nval) \ > + raw_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) > +#define raw_cpu_try_cmpxchg128(pcp, ovalp, nval) \ > + raw_cpu_generic_try_cmpxchg_memcmp(pcp, ovalp, nval) > + > +#define this_cpu_generic_try_cmpxchg_memcmp(pcp, ovalp, nval) \ > +({ \ > + bool __ret; \ > + unsigned long __flags; \ > + raw_local_irq_save(__flags); \ > + __ret =3D raw_cpu_generic_try_cmpxchg_memcmp(pcp, ovalp, nval); \ > + raw_local_irq_restore(__flags); \ > + __ret; \ > +}) > + > +#define this_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) \ > +({ \ > + typeof(pcp) __ret; \ > + unsigned long __flags; \ > + raw_local_irq_save(__flags); \ > + __ret =3D raw_cpu_generic_cmpxchg_memcmp(pcp, oval, nval); \ > + raw_local_irq_restore(__flags); \ > + __ret; \ > +}) > + > +#define this_cpu_cmpxchg128(pcp, oval, nval) \ > + this_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) > +#define this_cpu_try_cmpxchg128(pcp, ovalp, nval) \ > + this_cpu_generic_try_cmpxchg_memcmp(pcp, ovalp, nval) > + > +#endif /* !__SIZEOF_INT128__ */ > + > +#include > + > +#endif /* _ASM_PARISC_PERCPU_H */