Message ID | 20230601101409.GS4253@hirez.programming.kicks-ass.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp203424vqr; Thu, 1 Jun 2023 03:35:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zvxK2I5C39S+YkYEN5aAb8qNrgVMCogzUr96A8apWzw3Sa+1DU9Jwy2auDj7qlDU6yaoV X-Received: by 2002:a92:d08a:0:b0:33b:94d:b60b with SMTP id h10-20020a92d08a000000b0033b094db60bmr5762424ilh.14.1685615745059; Thu, 01 Jun 2023 03:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685615745; cv=none; d=google.com; s=arc-20160816; b=irP8bSEhPv8sDiyWw2j9jkxpI3VKHESvgFuB8ZSmp2DcjKJgdXnVUlUwiTXD5d6PDn lonAIOfoYTcphZ5HxYXy+PJdg6PHHvPpxMTnPU2Hd1ZbGDblAKLj/37x9EfdTrIidyZj hLP21EUgFEAmluhDKPrPqadRm0LEQ6OCJj5H1Ietg1qSNVRtln0ai0ucYMTzOyZ7lKEK eLpyY04UdDSDtfGfW8kiy45MZBfxz3o9shv1mpDqtdGj/hRONGnBzJUjypYZ04bbgBT7 zKqncqZ2nv1u3us7M4ZPGKmy0g3RRzFEnFWCQgjlDI8SvqUxZo1rjZQpbPAvYOJwBJll 33Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=G1trJdY7ybtDfb34YzOEZVtQJ+4O7zYES3kMJ7sRdCU=; b=wXVqIG1Z2AV70ns+295cx7uUCd3VGvG2Dva2t+XwOk1yt/aYE2ZNV0QVCNKCp7MYZy XO/UrHcy61LBI8VY7DIVksGADNDZQ1wmvxp0yDxXeS6ThBhRA/hI/2HKdxqG4iwde1QN OB7p7lVOrv3sSGUfCv+06NLRY0ydDW5XXnCP/Bm5HFFxZQUbVge/nUvf2/mpZSfHYG7f KmP5wBp7UIcYn+ovOkj4qJr5Eaqw6HA7z497TlrffkvybUJrkdQ/AH+f1o2cX5dPORdC H7FY7NrZ/aJswWBKHPH2lIZ3+bZ2WTpMAlXpvsKT8OLX6FDKlrjHFjr+zDKL5yWzGxSL Zpbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pytfcabS; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g64-20020a636b43000000b00528d1d9c7b3si2663016pgc.732.2023.06.01.03.35.30; Thu, 01 Jun 2023 03:35:45 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pytfcabS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbjFAKSl (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Thu, 1 Jun 2023 06:18:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbjFAKSG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Jun 2023 06:18:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF58A1FDB; Thu, 1 Jun 2023 03:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=G1trJdY7ybtDfb34YzOEZVtQJ+4O7zYES3kMJ7sRdCU=; b=pytfcabSQbAioNogqcJyIjWxkb I3OIRz0nPyGAHQCouHiezAZ3WYDnbr+0H5ASElPr4+OfQuPcqSEVXUzQNdmNT0vDCq0lYth70hxc+ nIxwWeL5rSBkZoelbLSxxySFndCPqg76D3wq86BEGZ1gkD10CrGs9NABCiAJPJkEv81csRGvvoVja EaBwzktB36vi1XtuFtdCEjY2KE+yJjTGMIB4mjx3jEx3iBh0aM1LDhfieu9IZABiemcJgKbkPFNuq /6ksBvE3iaE68Sn2CQ4733UmzPnTQKsAKE8EvFRBt0Ej6Ani+wvx452hsmvy64dZ4tGLH+6z41/Rs 43i6i9qw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1q4fJv-008GIu-Pp; Thu, 01 Jun 2023 10:14:15 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 66A3C3002F0; Thu, 1 Jun 2023 12:14:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 374AA21484A8B; Thu, 1 Jun 2023 12:14:09 +0200 (CEST) Date: Thu, 1 Jun 2023 12:14:09 +0200 From: Peter Zijlstra <peterz@infradead.org> To: Arnd Bergmann <arnd@arndb.de> Cc: Linus Torvalds <torvalds@linux-foundation.org>, Jonathan Corbet <corbet@lwn.net>, Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>, Mark Rutland <mark.rutland@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, dennis@kernel.org, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Heiko Carstens <hca@linux.ibm.com>, gor@linux.ibm.com, Alexander Gordeev <agordeev@linux.ibm.com>, borntraeger@linux.ibm.com, Sven Schnelle <svens@linux.ibm.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>, Joerg Roedel <joro@8bytes.org>, suravee.suthikulpanit@amd.com, Robin Murphy <robin.murphy@arm.com>, David Woodhouse <dwmw2@infradead.org>, Baolu Lu <baolu.lu@linux.intel.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, Vlastimil Babka <vbabka@suse.cz>, Roman Gushchin <roman.gushchin@linux.dev>, 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-arch@vger.kernel.org>, linux-crypto@vger.kernel.org, Stephen Rothwell <sfr@canb.auug.org.au>, Michael Ellerman <mpe@ellerman.id.au>, "James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>, Helge Deller <deller@gmx.de>, linux-parisc@vger.kernel.org Subject: [PATCH v2 07/12] parisc/percpu: Work around the lack of __SIZEOF_INT128__ Message-ID: <20230601101409.GS4253@hirez.programming.kicks-ass.net> References: <20230531130833.635651916@infradead.org> <20230531132323.722039569@infradead.org> <70a69deb-7ad4-45b2-8e13-34955594a7ce@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <70a69deb-7ad4-45b2-8e13-34955594a7ce@app.fastmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767496215858195286?= X-GMAIL-MSGID: =?utf-8?q?1767496215858195286?= |
Series |
None
|
|
Commit Message
Peter Zijlstra
June 1, 2023, 10:14 a.m. UTC
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. Anyway, the below seems to work -- build tested with GCC-10.1 --- Subject: parisc/percpu: Work around the lack of __SIZEOF_INT128__ From: Peter Zijlstra <peterz@infradead.org> 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) <peterz@infradead.org> --- arch/parisc/include/asm/percpu.h | 77 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+)
Comments
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 <peterz@infradead.org> > 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) <peterz@infradead.org> > --- > 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 <linux/types.h> > + > +#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 = raw_cpu_ptr(&(pcp)); \ > + typeof(pcp) __val = *__p, __old = *(ovalp); \ > + bool __ret; \ > + if (!__builtin_memcmp(&__val, &__old, sizeof(pcp))) { \ > + *__p = nval; \ > + __ret = true; \ > + } else { \ > + *(ovalp) = __val; \ > + __ret = false; \ > + } \ > + __ret; \ > +}) > + > +#define raw_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) \ > +({ \ > + typeof(pcp) __old = (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 = 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 = 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 <asm-generic/percpu.h> > + > +#endif /* _ASM_PARISC_PERCPU_H */
On Thu, Jun 01, 2023 at 12:32:38PM +0200, Helge Deller wrote: > 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? Correct, if you're willing to set minimum GCC version to 11 for parisc all is well and this patch can go play in the bit bucket.
On Thu, Jun 1, 2023 at 6:32 AM Helge Deller <deller@gmx.de> wrote: > > 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? This absolutely sounds like the right option. Let's simplify the problem space by just saying that parisc needs the newer compiler. Right now we have that "minimum gcc version" in a somewhat annoying place: it's in the ./scripts/min-tool-version.sh file as a shell script. I wonder if we could move the gcc minimum version check into the Kconfig file instead, and make it easier to let architectures override the minimum version. I don't quite know how to do that sanely, though. I don't think we have a sane way to error out at Kconfig time (except by forcing some syntax error inside an 'if' statement or something horrendously hacky like that). Added Masahiro to the (already overlong) participants list. Linus
On Thu, Jun 1, 2023 at 10:29 PM Linus Torvalds <torvalds@linux-foundation.org> wrote: > > On Thu, Jun 1, 2023 at 6:32 AM Helge Deller <deller@gmx.de> wrote: > > > > 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? > > This absolutely sounds like the right option. Let's simplify the > problem space by just saying that parisc needs the newer compiler. > > Right now we have that "minimum gcc version" in a somewhat annoying > place: it's in the ./scripts/min-tool-version.sh file as a shell > script. > > I wonder if we could move the gcc minimum version check into the > Kconfig file instead, and make it easier to let architectures override > the minimum version. Currently, it is invoked in the Kconfig time, but not directly in Kconfig files. scripts/Kconfig.include -> scripts/cc-version.sh -> scripts/min-tool-version.sh It would be ugly if we wrote the equivalent code directly in Kconfig files. > > I don't quite know how to do that sanely, though. I don't think we > have a sane way to error out at Kconfig time (except by forcing some > syntax error inside an 'if' statement or something horrendously hacky > like that). The parse stage can fail by $(error-if ) macro, but the evaluation stage never fails. I think it is a design. I think checking the compiler version during the parse stage makes sense given the current situation. The compiler version is fixed when Kconfig starts. If the compiler is found to be too old, there is no meaning to proceed. You suggested to choose a compiler in the Kconfig time: https://lore.kernel.org/lkml/CAHk-=whdrvCkSWh=BRrwZwNo3=yLBXXM88NGx8VEpP1VTgmkyQ@mail.gmail.com/ When we achieve that, moving the min version to Kconfig files will be the right thing to do. Then, everything will be evaluated dynamically. > > Added Masahiro to the (already overlong) participants list. > > Linus
Peter Zijlstra <peterz@infradead.org> writes: > On Thu, Jun 01, 2023 at 12:32:38PM +0200, Helge Deller wrote: >> 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? > > Correct, if you're willing to set minimum GCC version to 11 for parisc > all is well and this patch can go play in the bit bucket. It's fine for us in Gentoo, thanks!
On Thu, Jun 01, 2023 at 09:29:18AM -0400, Linus Torvalds wrote: > Right now we have that "minimum gcc version" in a somewhat annoying > place: it's in the ./scripts/min-tool-version.sh file as a shell > script. Something like so then? --- Subject: parisc: Raise minimal GCC version From: Peter Zijlstra <peterz@infradead.org> Date: Fri Jun 2 16:33:54 CEST 2023 With 64bit builds depending on __SIZEOF_INT128__ raise the parisc minimum compiler version to gcc-11.0.0. All other 64bit architectures provide this from GCC-5.1.0 (and probably before), except hppa64 which only started advertising this with GCC-11. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> --- scripts/min-tool-version.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/scripts/min-tool-version.sh +++ b/scripts/min-tool-version.sh @@ -17,7 +17,11 @@ binutils) echo 2.25.0 ;; gcc) - echo 5.1.0 + if [ "$SRCARCH" = parisc ]; then + echo 11.0.0 + else + echo 5.1.0 + fi ;; llvm) if [ "$SRCARCH" = s390 ]; then
On Fri, Jun 02, 2023 at 04:39:12PM +0200, Peter Zijlstra wrote: > On Thu, Jun 01, 2023 at 09:29:18AM -0400, Linus Torvalds wrote: > > > Right now we have that "minimum gcc version" in a somewhat annoying > > place: it's in the ./scripts/min-tool-version.sh file as a shell > > script. > > Something like so then? > > --- > Subject: parisc: Raise minimal GCC version > From: Peter Zijlstra <peterz@infradead.org> > Date: Fri Jun 2 16:33:54 CEST 2023 > > With 64bit builds depending on __SIZEOF_INT128__ raise the parisc > minimum compiler version to gcc-11.0.0. > > All other 64bit architectures provide this from GCC-5.1.0 (and > probably before), except hppa64 which only started advertising this > with GCC-11. > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > scripts/min-tool-version.sh | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > --- a/scripts/min-tool-version.sh > +++ b/scripts/min-tool-version.sh > @@ -17,7 +17,11 @@ binutils) > echo 2.25.0 > ;; > gcc) > - echo 5.1.0 > + if [ "$SRCARCH" = parisc ]; then > + echo 11.0.0 > + else > + echo 5.1.0 > + fi > ;; > llvm) > if [ "$SRCARCH" = s390 ]; then I gave this a spin and it looks good to me: [mark@lakrids:~/src/linux]% usekorg 10.3.0 make ARCH=arm64 CROSS_COMPILE=aarch64-linux- defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf *** Default configuration is based on 'defconfig' # # configuration written to .config # [mark@lakrids:~/src/linux]% usekorg 10.3.0 make ARCH=parisc CROSS_COMPILE=hppa64-linux- generic-64bit_defconfig *** *** C compiler is too old. *** Your GCC version: 10.3.0 *** Minimum GCC version: 11.0.0 *** scripts/Kconfig.include:44: Sorry, this C compiler is not supported. make[1]: *** [scripts/kconfig/Makefile:94: generic-64bit_defconfig] Error 1 make: *** [Makefile:692: generic-64bit_defconfig] Error 2 [mark@lakrids:~/src/linux]% usekorg 11.3.0 make ARCH=parisc CROSS_COMPILE=hppa64-linux- generic-64bit_defconfig # # configuration written to .config # FWIW: Tested-by: Mark Rutland <mark.rutland@arm.com> Mark.
On Fri, Jun 2, 2023 at 10:40 AM Peter Zijlstra <peterz@infradead.org> wrote: > > Something like so then? Ack. I think it would be much cleaner if we would have it as part of the Kconfig file and architectures could just override some GCC_MIN_VERSION value, but that's not the universe we currently have, so your patch looks like the best thing to do. Linus
On June 2, 2023 7:39:12 AM PDT, Peter Zijlstra <peterz@infradead.org> wrote: >On Thu, Jun 01, 2023 at 09:29:18AM -0400, Linus Torvalds wrote: > >> Right now we have that "minimum gcc version" in a somewhat annoying >> place: it's in the ./scripts/min-tool-version.sh file as a shell >> script. > >Something like so then? > >--- >Subject: parisc: Raise minimal GCC version >From: Peter Zijlstra <peterz@infradead.org> >Date: Fri Jun 2 16:33:54 CEST 2023 > >With 64bit builds depending on __SIZEOF_INT128__ raise the parisc >minimum compiler version to gcc-11.0.0. > >All other 64bit architectures provide this from GCC-5.1.0 (and >probably before), except hppa64 which only started advertising this >with GCC-11. > >Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> >--- > scripts/min-tool-version.sh | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > >--- a/scripts/min-tool-version.sh >+++ b/scripts/min-tool-version.sh >@@ -17,7 +17,11 @@ binutils) > echo 2.25.0 > ;; > gcc) >- echo 5.1.0 >+ if [ "$SRCARCH" = parisc ]; then >+ echo 11.0.0 >+ else >+ echo 5.1.0 >+ fi > ;; > llvm) > if [ "$SRCARCH" = s390 ]; then Dumb question: is this only about the cpp macro or is it about __int128 existing at all?
On Fri, Jun 02, 2023 at 10:00:17AM -0700, H. Peter Anvin wrote:
> Dumb question: is this only about the cpp macro or is it about __int128 existing at all?
It's mostly about __int128 being there, __SIZEOF_INT128__ is just the
way we go about detecting if it's there or not.
Ok. So the patch description needs to be fixed. Otherwise the solution would be far simpler :)
On Fri, Jun 02, 2023 at 12:20:05PM -0700, H. Peter Anvin wrote:
> Ok. So the patch description needs to be fixed. Otherwise the solution would be far simpler :)
"With 64bit builds depending on __SIZEOF_INT128__ to detect the
presence of __int128 raise the parisc minimum compiler version to
gcc-11.0.0."
better?
On Fri, Jun 2, 2023 at 3:40 PM Peter Zijlstra <peterz@infradead.org> wrote: > > "With 64bit builds depending on __SIZEOF_INT128__ to detect the > presence of __int128 raise the parisc minimum compiler version to > gcc-11.0.0." > > better? I'd just say "64-bit targets need the __int128 type, which for pa-risc means raising the minimum gcc version to 11". The __SIZEOF_INT128__ part isn't the important part. That's just the symptom. Linus
On 6/2/23 16:39, Peter Zijlstra wrote: > On Thu, Jun 01, 2023 at 09:29:18AM -0400, Linus Torvalds wrote: > >> Right now we have that "minimum gcc version" in a somewhat annoying >> place: it's in the ./scripts/min-tool-version.sh file as a shell >> script. > > Something like so then? > > --- > Subject: parisc: Raise minimal GCC version > From: Peter Zijlstra <peterz@infradead.org> > Date: Fri Jun 2 16:33:54 CEST 2023 > > With 64bit builds depending on __SIZEOF_INT128__ raise the parisc > minimum compiler version to gcc-11.0.0. > > All other 64bit architectures provide this from GCC-5.1.0 (and > probably before), except hppa64 which only started advertising this > with GCC-11. > > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> The patch raises the compiler for 32- and 64-bit parisc builds, but that's OK. So: Acked-by: Helge Deller <deller@gmx.de> Thank you! Helge > --- > scripts/min-tool-version.sh | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > --- a/scripts/min-tool-version.sh > +++ b/scripts/min-tool-version.sh > @@ -17,7 +17,11 @@ binutils) > echo 2.25.0 > ;; > gcc) > - echo 5.1.0 > + if [ "$SRCARCH" = parisc ]; then > + echo 11.0.0 > + else > + echo 5.1.0 > + fi > ;; > llvm) > if [ "$SRCARCH" = s390 ]; then
--- /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 <linux/types.h> + +#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 = raw_cpu_ptr(&(pcp)); \ + typeof(pcp) __val = *__p, __old = *(ovalp); \ + bool __ret; \ + if (!__builtin_memcmp(&__val, &__old, sizeof(pcp))) { \ + *__p = nval; \ + __ret = true; \ + } else { \ + *(ovalp) = __val; \ + __ret = false; \ + } \ + __ret; \ +}) + +#define raw_cpu_generic_cmpxchg_memcmp(pcp, oval, nval) \ +({ \ + typeof(pcp) __old = (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 = 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 = 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 <asm-generic/percpu.h> + +#endif /* _ASM_PARISC_PERCPU_H */