Re: [tip: x86/percpu] x86/percpu: Convert this_percpu_xchg_op() from asm() to C code, to generate better code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx> 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@xxxxxxxxx/

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




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux