From: Nathan Chancellor <nathan@kernel.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
x86@kernel.org, Kees Cook <keescook@chromium.org>,
Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [tip: x86/percpu] x86/percpu: Convert this_percpu_xchg_op() from asm() to C code, to generate better code
Date: Wed, 20 Mar 2024 10:37:58 -0700 [thread overview]
Message-ID: <20240320173758.GA3017166@dev-arch.thelio-3990X> (raw)
In-Reply-To: <CAFULd4bNETbtP3VTGao4o3mtfpw6d=rhcWp5N+pnzp-f3fjXAw@mail.gmail.com>
On Wed, Mar 20, 2024 at 02:12:14PM +0100, Uros Bizjak wrote:
> On Wed, Mar 20, 2024 at 12:45 PM Ingo Molnar <mingo@kernel.org> wrote:
> > Clang claims to be compatible:
> >
> > https://releases.llvm.org/9.0.0/tools/clang/docs/LanguageExtensions.html
> >
> > "You can also use the GCC compatibility macros __seg_fs and __seg_gs for the
> > same purpose. The preprocessor symbols __SEG_FS and __SEG_GS indicate their
> > support."
> >
> > I haven't tried it yet though.
>
> In the RFC submission, the support was determined by the functional
> check [2]. Perhaps we should re-introduce this instead of checking for
> known compiler versions:
>
> +config CC_HAS_NAMED_AS
> + def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC)
> -x c - -c -o /dev/null)
>
> [2] https://lore.kernel.org/lkml/20231001131620.112484-3-ubizjak@gmail.com/
I applied this change on top of current mainline (a4145ce1e7bc) and
built ARCH=x86_64 defconfig with LLVM 17.0.6 from [1] but it doesn't get
too far :)
In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from include/linux/crypto.h:15:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:7:
In file included from include/linux/spinlock.h:56:
In file included from include/linux/preempt.h:79:
In file included from arch/x86/include/asm/preempt.h:7:
arch/x86/include/asm/current.h:47:10: error: multiple identical address spaces specified for type [-Werror,-Wduplicate-decl-specifier]
47 | return this_cpu_read_const(const_pcpu_hot.current_task);
| ^
arch/x86/include/asm/percpu.h:471:34: note: expanded from macro 'this_cpu_read_const'
471 | #define this_cpu_read_const(pcp) __raw_cpu_read(, pcp)
| ^
arch/x86/include/asm/percpu.h:441:30: note: expanded from macro '__raw_cpu_read'
441 | *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \
| ^
arch/x86/include/asm/percpu.h:105:28: note: expanded from macro '__my_cpu_ptr'
105 | #define __my_cpu_ptr(ptr) (__my_cpu_type(*ptr) *)(uintptr_t)(ptr)
| ^
arch/x86/include/asm/percpu.h:104:40: note: expanded from macro '__my_cpu_type'
104 | #define __my_cpu_type(var) typeof(var) __percpu_seg_override
| ^
arch/x86/include/asm/percpu.h:45:31: note: expanded from macro '__percpu_seg_override'
45 | #define __percpu_seg_override __seg_gs
| ^
<built-in>:338:33: note: expanded from macro '__seg_gs'
338 | #define __seg_gs __attribute__((address_space(256)))
| ^
In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from include/linux/crypto.h:15:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:7:
In file included from include/linux/spinlock.h:56:
In file included from include/linux/preempt.h:79:
In file included from arch/x86/include/asm/preempt.h:7:
arch/x86/include/asm/current.h:47:10: error: multiple identical address spaces specified for type [-Werror,-Wduplicate-decl-specifier]
arch/x86/include/asm/percpu.h:471:34: note: expanded from macro 'this_cpu_read_const'
471 | #define this_cpu_read_const(pcp) __raw_cpu_read(, pcp)
| ^
arch/x86/include/asm/percpu.h:441:9: note: expanded from macro '__raw_cpu_read'
441 | *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \
| ^
arch/x86/include/asm/percpu.h:104:40: note: expanded from macro '__my_cpu_type'
104 | #define __my_cpu_type(var) typeof(var) __percpu_seg_override
| ^
arch/x86/include/asm/percpu.h:45:31: note: expanded from macro '__percpu_seg_override'
45 | #define __percpu_seg_override __seg_gs
| ^
<built-in>:338:33: note: expanded from macro '__seg_gs'
338 | #define __seg_gs __attribute__((address_space(256)))
| ^
In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from include/linux/crypto.h:15:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:7:
In file included from include/linux/spinlock.h:60:
In file included from include/linux/thread_info.h:60:
In file included from arch/x86/include/asm/thread_info.h:59:
In file included from arch/x86/include/asm/cpufeature.h:5:
arch/x86/include/asm/processor.h:530:10: error: multiple identical address spaces specified for type [-Werror,-Wduplicate-decl-specifier]
530 | return this_cpu_read_const(const_pcpu_hot.top_of_stack);
| ^
arch/x86/include/asm/percpu.h:471:34: note: expanded from macro 'this_cpu_read_const'
471 | #define this_cpu_read_const(pcp) __raw_cpu_read(, pcp)
| ^
arch/x86/include/asm/percpu.h:441:30: note: expanded from macro '__raw_cpu_read'
441 | *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \
| ^
arch/x86/include/asm/percpu.h:105:28: note: expanded from macro '__my_cpu_ptr'
105 | #define __my_cpu_ptr(ptr) (__my_cpu_type(*ptr) *)(uintptr_t)(ptr)
| ^
arch/x86/include/asm/percpu.h:104:40: note: expanded from macro '__my_cpu_type'
104 | #define __my_cpu_type(var) typeof(var) __percpu_seg_override
| ^
arch/x86/include/asm/percpu.h:45:31: note: expanded from macro '__percpu_seg_override'
45 | #define __percpu_seg_override __seg_gs
| ^
<built-in>:338:33: note: expanded from macro '__seg_gs'
338 | #define __seg_gs __attribute__((address_space(256)))
| ^
In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from include/linux/crypto.h:15:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:7:
In file included from include/linux/spinlock.h:60:
In file included from include/linux/thread_info.h:60:
In file included from arch/x86/include/asm/thread_info.h:59:
In file included from arch/x86/include/asm/cpufeature.h:5:
arch/x86/include/asm/processor.h:530:10: error: multiple identical address spaces specified for type [-Werror,-Wduplicate-decl-specifier]
arch/x86/include/asm/percpu.h:471:34: note: expanded from macro 'this_cpu_read_const'
471 | #define this_cpu_read_const(pcp) __raw_cpu_read(, pcp)
| ^
arch/x86/include/asm/percpu.h:441:9: note: expanded from macro '__raw_cpu_read'
441 | *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \
| ^
arch/x86/include/asm/percpu.h:104:40: note: expanded from macro '__my_cpu_type'
104 | #define __my_cpu_type(var) typeof(var) __percpu_seg_override
| ^
arch/x86/include/asm/percpu.h:45:31: note: expanded from macro '__percpu_seg_override'
45 | #define __percpu_seg_override __seg_gs
| ^
<built-in>:338:33: note: expanded from macro '__seg_gs'
338 | #define __seg_gs __attribute__((address_space(256)))
| ^
4 errors generated.
[1]: https://mirrors.edge.kernel.org/pub/tools/llvm/
Cheers,
Nathan
prev parent reply other threads:[~2024-03-20 17:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 8:30 [PATCH 1/2] x86/percpu: Define this_percpu_xchg_op() Uros Bizjak
2024-03-20 8:30 ` [PATCH 2/2] x86/percpu: Move raw_percpu_xchg_op() to a better place Uros Bizjak
2024-03-20 11:22 ` [tip: x86/percpu] " tip-bot2 for Uros Bizjak
2024-03-20 11:39 ` tip-bot2 for Uros Bizjak
2024-03-20 11:22 ` [tip: x86/percpu] x86/percpu: Convert this_percpu_xchg_op() from asm() to C code, to generate better code tip-bot2 for Uros Bizjak
2024-03-20 11:39 ` tip-bot2 for Uros Bizjak
2024-03-20 11:45 ` Ingo Molnar
2024-03-20 13:12 ` Uros Bizjak
2024-03-20 17:37 ` Nathan Chancellor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240320173758.GA3017166@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox