All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf
@ 2021-01-13 10:57 Tiezhu Yang
  2021-01-13 10:57 ` [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Tiezhu Yang @ 2021-01-13 10:57 UTC (permalink / raw)
  To: Luc Van Oostenryck, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li

There exists many build errors and warnings when make M=samples/bpf,
this patch series fix some of them, I will submit some other patches
related with MIPS later.

Tiezhu Yang (2):
  samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build
    warnings
  compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build
    errors

 include/linux/compiler.h    | 6 ++++++
 samples/bpf/Makefile        | 4 ++++
 tools/include/linux/types.h | 3 +++
 3 files changed, 13 insertions(+)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
  2021-01-13 10:57 [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Tiezhu Yang
@ 2021-01-13 10:57 ` Tiezhu Yang
  2021-01-13 17:12   ` Yonghong Song
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
  2021-01-13 17:16 ` [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Yonghong Song
  2 siblings, 1 reply; 12+ messages in thread
From: Tiezhu Yang @ 2021-01-13 10:57 UTC (permalink / raw)
  To: Luc Van Oostenryck, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li

MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
'int-ll64.h' in arch/mips/include/uapi/asm/types.h and avoid compile
warnings when printing __u64 with %llu, %llx or %lld.

    printf("0x%02x : %llu\n", key, value);
                     ~~~^          ~~~~~
                     %lu
   printf("%s/%llx;", sym->name, addr);
              ~~~^               ~~~~
              %lx
  printf(";%s %lld\n", key->waker, count);
              ~~~^                 ~~~~~
              %ld

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 samples/bpf/Makefile        | 4 ++++
 tools/include/linux/types.h | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 26fc96c..27de306 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -183,6 +183,10 @@ BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
 TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
 endif
 
+ifeq ($(ARCH), mips)
+TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
+endif
+
 TPROGS_CFLAGS += -Wall -O2
 TPROGS_CFLAGS += -Wmissing-prototypes
 TPROGS_CFLAGS += -Wstrict-prototypes
diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
index 154eb4e..e9c5a21 100644
--- a/tools/include/linux/types.h
+++ b/tools/include/linux/types.h
@@ -6,7 +6,10 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#ifndef __SANE_USERSPACE_TYPES__
 #define __SANE_USERSPACE_TYPES__	/* For PPC64, to get LL64 types */
+#endif
+
 #include <asm/types.h>
 #include <asm/posix_types.h>
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 10:57 [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Tiezhu Yang
  2021-01-13 10:57 ` [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
@ 2021-01-13 10:57 ` Tiezhu Yang
  2021-01-13 17:14   ` Yonghong Song
                     ` (3 more replies)
  2021-01-13 17:16 ` [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Yonghong Song
  2 siblings, 4 replies; 12+ messages in thread
From: Tiezhu Yang @ 2021-01-13 10:57 UTC (permalink / raw)
  To: Luc Van Oostenryck, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li

When make M=samples/bpf on the Loongson 3A3000 platform which
belongs to MIPS arch, there exists many similar build errors
about 'asm/rwonce.h' file not found, so include it only under
CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
and alpha arch.

  CLANG-bpf  samples/bpf/xdpsock_kern.o
In file included from samples/bpf/xdpsock_kern.c:2:
In file included from ./include/linux/bpf.h:9:
In file included from ./include/linux/workqueue.h:9:
In file included from ./include/linux/timer.h:5:
In file included from ./include/linux/list.h:9:
In file included from ./include/linux/kernel.h:10:
./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
         ^~~~~~~~~~~~~~
1 error generated.

$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/alpha/include/asm/rwonce.h

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 include/linux/compiler.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b8fe0c2..bdbe759 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -243,6 +243,12 @@ static inline void *offset_to_ptr(const int *off)
  */
 #define prevent_tail_call_optimization()	mb()
 
+#ifdef CONFIG_ARM64
 #include <asm/rwonce.h>
+#endif
+
+#ifdef CONFIG_ALPHA
+#include <asm/rwonce.h>
+#endif
 
 #endif /* __LINUX_COMPILER_H */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
  2021-01-13 10:57 ` [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
@ 2021-01-13 17:12   ` Yonghong Song
  2021-01-18  3:22     ` Tiezhu Yang
  0 siblings, 1 reply; 12+ messages in thread
From: Yonghong Song @ 2021-01-13 17:12 UTC (permalink / raw)
  To: Tiezhu Yang, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li



On 1/13/21 2:57 AM, Tiezhu Yang wrote:
> MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
> 'int-ll64.h' in arch/mips/include/uapi/asm/types.h and avoid compile
> warnings when printing __u64 with %llu, %llx or %lld.

could you mention which command produces the following warning?

> 
>      printf("0x%02x : %llu\n", key, value);
>                       ~~~^          ~~~~~
>                       %lu
>     printf("%s/%llx;", sym->name, addr);
>                ~~~^               ~~~~
>                %lx
>    printf(";%s %lld\n", key->waker, count);
>                ~~~^                 ~~~~~
>                %ld
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   samples/bpf/Makefile        | 4 ++++
>   tools/include/linux/types.h | 3 +++
>   2 files changed, 7 insertions(+)
> 
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 26fc96c..27de306 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -183,6 +183,10 @@ BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
>   TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
>   endif
>   
> +ifeq ($(ARCH), mips)
> +TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
> +endif
> +

This change looks okay based on description in
arch/mips/include/uapi/asm/types.h

'''
/*
  * We don't use int-l64.h for the kernel anymore but still use it for
  * userspace to avoid code changes.
  *
  * However, some user programs (e.g. perf) may not want this. They can
  * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
  */
'''

>   TPROGS_CFLAGS += -Wall -O2
>   TPROGS_CFLAGS += -Wmissing-prototypes
>   TPROGS_CFLAGS += -Wstrict-prototypes
> diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
> index 154eb4e..e9c5a21 100644
> --- a/tools/include/linux/types.h
> +++ b/tools/include/linux/types.h
> @@ -6,7 +6,10 @@
>   #include <stddef.h>
>   #include <stdint.h>
>   
> +#ifndef __SANE_USERSPACE_TYPES__
>   #define __SANE_USERSPACE_TYPES__	/* For PPC64, to get LL64 types */
> +#endif

What problem this patch fixed? If this header is used, you can just
change comment from "PPC64" to "PPC64/MIPS", right?

> +
>   #include <asm/types.h>
>   #include <asm/posix_types.h>
>   
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
@ 2021-01-13 17:14   ` Yonghong Song
  2021-01-18  9:25     ` Tiezhu Yang
  2021-01-14  2:18   ` kernel test robot
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Yonghong Song @ 2021-01-13 17:14 UTC (permalink / raw)
  To: Tiezhu Yang, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li



On 1/13/21 2:57 AM, Tiezhu Yang wrote:
> When make M=samples/bpf on the Loongson 3A3000 platform which
> belongs to MIPS arch, there exists many similar build errors
> about 'asm/rwonce.h' file not found, so include it only under
> CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
> and alpha arch.
> 
>    CLANG-bpf  samples/bpf/xdpsock_kern.o
> In file included from samples/bpf/xdpsock_kern.c:2:
> In file included from ./include/linux/bpf.h:9:
> In file included from ./include/linux/workqueue.h:9:
> In file included from ./include/linux/timer.h:5:
> In file included from ./include/linux/list.h:9:
> In file included from ./include/linux/kernel.h:10:
> ./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> 
> $ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   include/linux/compiler.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index b8fe0c2..bdbe759 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -243,6 +243,12 @@ static inline void *offset_to_ptr(const int *off)
>    */
>   #define prevent_tail_call_optimization()	mb()
>   
> +#ifdef CONFIG_ARM64
>   #include <asm/rwonce.h>
> +#endif
> +
> +#ifdef CONFIG_ALPHA
> +#include <asm/rwonce.h>
> +#endif

I do not think this fix is correct. x86 does not define its own
rwonce.h and still compiles fine.

As noted in the above, we have include/asm-generic/rwonce.h.
Once you do a proper build, you will have rwonce.h in arch
generated directory like

-bash-4.4$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/alpha/include/asm/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/x86/include/generated/asm/rwonce.h

for mips, it should generated in 
arch/mips/include/generated/asm/rwonce.h. Please double check why this 
does not happen.

>   
>   #endif /* __LINUX_COMPILER_H */
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf
  2021-01-13 10:57 [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Tiezhu Yang
  2021-01-13 10:57 ` [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
@ 2021-01-13 17:16 ` Yonghong Song
  2 siblings, 0 replies; 12+ messages in thread
From: Yonghong Song @ 2021-01-13 17:16 UTC (permalink / raw)
  To: Tiezhu Yang, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li



On 1/13/21 2:57 AM, Tiezhu Yang wrote:
> There exists many build errors and warnings when make M=samples/bpf,

both fixes in this patch related to mips, please do mention in the 
commit message that this is
mips related. x86 (and arm64 I assume) compiles just fine.

> this patch series fix some of them, I will submit some other patches
> related with MIPS later.
> 
> Tiezhu Yang (2):
>    samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build
>      warnings
>    compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build
>      errors
> 
>   include/linux/compiler.h    | 6 ++++++
>   samples/bpf/Makefile        | 4 ++++
>   tools/include/linux/types.h | 3 +++
>   3 files changed, 13 insertions(+)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
  2021-01-13 17:14   ` Yonghong Song
@ 2021-01-14  2:18   ` kernel test robot
  2021-01-14  8:40   ` Sergei Shtylyov
  2021-01-14 15:58   ` kernel test robot
  3 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2021-01-14  2:18 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3986 bytes --]

Hi Tiezhu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master linus/master v5.11-rc3 next-20210113]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tiezhu-Yang/Fix-build-errors-and-warnings-when-make-M-samples-bpf/20210113-190045
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: arm-defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f65413b91d3c20f52eb8b53d7d32b9fd38a18dca
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tiezhu-Yang/Fix-build-errors-and-warnings-when-make-M-samples-bpf/20210113-190045
        git checkout f65413b91d3c20f52eb8b53d7d32b9fd38a18dca
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/spinlock_types.h:13,
                    from include/linux/ratelimit_types.h:7,
                    from include/linux/ratelimit.h:5,
                    from lib/ratelimit.c:11:
>> arch/arm/include/asm/spinlock_types.h:13:3: error: unknown type name 'u32'
      13 |   u32 slock;
         |   ^~~
>> arch/arm/include/asm/spinlock_types.h:19:4: error: unknown type name 'u16'
      19 |    u16 owner;
         |    ^~~
   arch/arm/include/asm/spinlock_types.h:20:4: error: unknown type name 'u16'
      20 |    u16 next;
         |    ^~~
   arch/arm/include/asm/spinlock_types.h:29:2: error: unknown type name 'u32'
      29 |  u32 lock;
         |  ^~~


vim +/u32 +13 arch/arm/include/asm/spinlock_types.h

546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  10  
fb1c8f93d869b34c include/asm-arm/spinlock_types.h      Ingo Molnar     2005-09-10  11  typedef struct {
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  12  	union {
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06 @13  		u32 slock;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  14  		struct __raw_tickets {
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  15  #ifdef __ARMEB__
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  16  			u16 next;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  17  			u16 owner;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  18  #else
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06 @19  			u16 owner;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  20  			u16 next;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  21  #endif
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  22  		} tickets;
546c2896a42202db arch/arm/include/asm/spinlock_types.h Will Deacon     2012-07-06  23  	};
445c89514be242b1 arch/arm/include/asm/spinlock_types.h Thomas Gleixner 2009-12-02  24  } arch_spinlock_t;
fb1c8f93d869b34c include/asm-arm/spinlock_types.h      Ingo Molnar     2005-09-10  25  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 54191 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
  2021-01-13 17:14   ` Yonghong Song
  2021-01-14  2:18   ` kernel test robot
@ 2021-01-14  8:40   ` Sergei Shtylyov
  2021-01-14 15:58   ` kernel test robot
  3 siblings, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2021-01-14  8:40 UTC (permalink / raw)
  To: Tiezhu Yang, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Nathan Chancellor,
	Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li

Hello!

On 13.01.2021 13:57, Tiezhu Yang wrote:

> When make M=samples/bpf on the Loongson 3A3000 platform which
> belongs to MIPS arch, there exists many similar build errors
> about 'asm/rwonce.h' file not found, so include it only under
> CONFIG_ARM64 and CONFIG_ALPHA due to it exists only in arm64
> and alpha arch.
> 
>    CLANG-bpf  samples/bpf/xdpsock_kern.o
> In file included from samples/bpf/xdpsock_kern.c:2:
> In file included from ./include/linux/bpf.h:9:
> In file included from ./include/linux/workqueue.h:9:
> In file included from ./include/linux/timer.h:5:
> In file included from ./include/linux/list.h:9:
> In file included from ./include/linux/kernel.h:10:
> ./include/linux/compiler.h:246:10: fatal error: 'asm/rwonce.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> 
> $ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>   include/linux/compiler.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index b8fe0c2..bdbe759 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -243,6 +243,12 @@ static inline void *offset_to_ptr(const int *off)
>    */
>   #define prevent_tail_call_optimization()	mb()
>   
> +#ifdef CONFIG_ARM64

    Why not #if defined(CONFIG_ALPHA) || defined(CONFIG_ARM64)?

>   #include <asm/rwonce.h>
> +#endif
> +
> +#ifdef CONFIG_ALPHA
> +#include <asm/rwonce.h>
> +#endif
>   
>   #endif /* __LINUX_COMPILER_H */
> 

MBR, Sergei

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
                     ` (2 preceding siblings ...)
  2021-01-14  8:40   ` Sergei Shtylyov
@ 2021-01-14 15:58   ` kernel test robot
  3 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2021-01-14 15:58 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2732 bytes --]

Hi Tiezhu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master linus/master v5.11-rc3 next-20210114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tiezhu-Yang/Fix-build-errors-and-warnings-when-make-M-samples-bpf/20210113-190045
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-rhel-8.3 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/f65413b91d3c20f52eb8b53d7d32b9fd38a18dca
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tiezhu-Yang/Fix-build-errors-and-warnings-when-make-M-samples-bpf/20210113-190045
        git checkout f65413b91d3c20f52eb8b53d7d32b9fd38a18dca
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from lib/error-inject.c:3:
>> include/linux/error-injection.h:10:8: error: unknown type name 'bool'
      10 | extern bool within_error_injection_list(unsigned long addr);
         |        ^~~~
>> lib/error-inject.c:23:6: error: conflicting types for 'within_error_injection_list'
      23 | bool within_error_injection_list(unsigned long addr)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from lib/error-inject.c:3:
   include/linux/error-injection.h:10:13: note: previous declaration of 'within_error_injection_list' was here
      10 | extern bool within_error_injection_list(unsigned long addr);
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from arch/x86/lib/error-inject.c:3:
>> include/linux/error-injection.h:10:8: error: unknown type name 'bool'
      10 | extern bool within_error_injection_list(unsigned long addr);
         |        ^~~~


vim +/bool +10 include/linux/error-injection.h

540adea3809f61 Masami Hiramatsu 2018-01-13   9  
540adea3809f61 Masami Hiramatsu 2018-01-13 @10  extern bool within_error_injection_list(unsigned long addr);
663faf9f7beeac Masami Hiramatsu 2018-01-13  11  extern int get_injectable_error_type(unsigned long addr);
540adea3809f61 Masami Hiramatsu 2018-01-13  12  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 41087 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
  2021-01-13 17:12   ` Yonghong Song
@ 2021-01-18  3:22     ` Tiezhu Yang
  2021-01-18 18:44       ` Yonghong Song
  0 siblings, 1 reply; 12+ messages in thread
From: Tiezhu Yang @ 2021-01-18  3:22 UTC (permalink / raw)
  To: Yonghong Song, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li

On 01/14/2021 01:12 AM, Yonghong Song wrote:
>
>
> On 1/13/21 2:57 AM, Tiezhu Yang wrote:
>> MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
>> 'int-ll64.h' in arch/mips/include/uapi/asm/types.h and avoid compile
>> warnings when printing __u64 with %llu, %llx or %lld.
>
> could you mention which command produces the following warning?

make M=samples/bpf

>
>>
>>      printf("0x%02x : %llu\n", key, value);
>>                       ~~~^          ~~~~~
>>                       %lu
>>     printf("%s/%llx;", sym->name, addr);
>>                ~~~^               ~~~~
>>                %lx
>>    printf(";%s %lld\n", key->waker, count);
>>                ~~~^                 ~~~~~
>>                %ld
>>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>>   samples/bpf/Makefile        | 4 ++++
>>   tools/include/linux/types.h | 3 +++
>>   2 files changed, 7 insertions(+)
>>
>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>> index 26fc96c..27de306 100644
>> --- a/samples/bpf/Makefile
>> +++ b/samples/bpf/Makefile
>> @@ -183,6 +183,10 @@ BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
>>   TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
>>   endif
>>   +ifeq ($(ARCH), mips)
>> +TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
>> +endif
>> +
>
> This change looks okay based on description in
> arch/mips/include/uapi/asm/types.h
>
> '''
> /*
>  * We don't use int-l64.h for the kernel anymore but still use it for
>  * userspace to avoid code changes.
>  *
>  * However, some user programs (e.g. perf) may not want this. They can
>  * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
>  */
> '''
>
>>   TPROGS_CFLAGS += -Wall -O2
>>   TPROGS_CFLAGS += -Wmissing-prototypes
>>   TPROGS_CFLAGS += -Wstrict-prototypes
>> diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
>> index 154eb4e..e9c5a21 100644
>> --- a/tools/include/linux/types.h
>> +++ b/tools/include/linux/types.h
>> @@ -6,7 +6,10 @@
>>   #include <stddef.h>
>>   #include <stdint.h>
>>   +#ifndef __SANE_USERSPACE_TYPES__
>>   #define __SANE_USERSPACE_TYPES__    /* For PPC64, to get LL64 types */
>> +#endif
>
> What problem this patch fixed?

If add "TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__" in
samples/bpf/Makefile, it appears the following error:

Auto-detecting system features:
...                        libelf: [ on  ]
...                          zlib: [ on  ]
...                           bpf: [ OFF ]

BPF API too old
make[3]: *** [Makefile:293: bpfdep] Error 1
make[2]: *** [Makefile:156: all] Error 2

With #ifndef __SANE_USERSPACE_TYPES__  in tools/include/linux/types.h,
the above error has gone.

> If this header is used, you can just
> change comment from "PPC64" to "PPC64/MIPS", right?

If include <linux/types.h> in the source files which have compile warnings
when printing __u64 with %llu, %llx or %lld, it has no effect due to 
actually
it includes usr/include/linux/types.h instead of 
tools/include/linux/types.h,
this is because the include-directories in samples/bpf/Makefile are searched
in the order, -I./usr/include is in the front of -I./tools/include.

So I think define __SANE_USERSPACE_TYPES__ for MIPS in samples/bpf/Makefile
is proper, at the same time, add #ifndef __SANE_USERSPACE_TYPES__ in
tools/include/linux/types.h can avoid build error and have no side effect.

I will send v2 later with mention in the commit message that this is
mips related.

Thanks,
Tiezhu

>
>> +
>>   #include <asm/types.h>
>>   #include <asm/posix_types.h>
>>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors
  2021-01-13 17:14   ` Yonghong Song
@ 2021-01-18  9:25     ` Tiezhu Yang
  0 siblings, 0 replies; 12+ messages in thread
From: Tiezhu Yang @ 2021-01-18  9:25 UTC (permalink / raw)
  To: Yonghong Song, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li, Sergei Shtylyov, kernel test robot

On 01/14/2021 01:14 AM, Yonghong Song wrote:
> I do not think this fix is correct. x86 does not define its own
> rwonce.h and still compiles fine.
>
> As noted in the above, we have include/asm-generic/rwonce.h.
> Once you do a proper build, you will have rwonce.h in arch
> generated directory like
>
> -bash-4.4$ find . -name rwonce.h
> ./include/asm-generic/rwonce.h
> ./arch/alpha/include/asm/rwonce.h
> ./arch/arm64/include/asm/rwonce.h
> ./arch/x86/include/generated/asm/rwonce.h
>
> for mips, it should generated in 
> arch/mips/include/generated/asm/rwonce.h. Please double check why this 
> does not happen.

Hi Yonghong,

Thank you very much for your reply.
You are right, this patch is meaningless.

I find this build error when make M=samples/bpf after make clean,
so the ./arch/mips/include/generated/asm/rwonce.h is not exist.

After rebuild the kernel, this header file can be found when make
M=samples/bpf due to samples/bpf/Makefile contains $LINUXINCLUDE.

$ find . -name rwonce.h
./include/asm-generic/rwonce.h
./arch/arm64/include/asm/rwonce.h
./arch/mips/include/generated/asm/rwonce.h
./arch/alpha/include/asm/rwonce.h
$ cat ./arch/mips/include/generated/asm/rwonce.h
#include <asm-generic/rwonce.h>


Hi Sergei and kernel test robot,

Thank you for your suggestion and report,
please ignore this patch, sorry for the noise.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
  2021-01-18  3:22     ` Tiezhu Yang
@ 2021-01-18 18:44       ` Yonghong Song
  0 siblings, 0 replies; 12+ messages in thread
From: Yonghong Song @ 2021-01-18 18:44 UTC (permalink / raw)
  To: Tiezhu Yang, Luc Van Oostenryck, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Song Liu,
	John Fastabend, KP Singh, Nathan Chancellor, Nick Desaulniers
  Cc: linux-sparse, netdev, bpf, clang-built-linux, linux-mips,
	linux-kernel, Xuefeng Li



On 1/17/21 7:22 PM, Tiezhu Yang wrote:
> On 01/14/2021 01:12 AM, Yonghong Song wrote:
>>
>>
>> On 1/13/21 2:57 AM, Tiezhu Yang wrote:
>>> MIPS needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
>>> 'int-ll64.h' in arch/mips/include/uapi/asm/types.h and avoid compile
>>> warnings when printing __u64 with %llu, %llx or %lld.
>>
>> could you mention which command produces the following warning?
> 
> make M=samples/bpf
> 
>>
>>>
>>>      printf("0x%02x : %llu\n", key, value);
>>>                       ~~~^          ~~~~~
>>>                       %lu
>>>     printf("%s/%llx;", sym->name, addr);
>>>                ~~~^               ~~~~
>>>                %lx
>>>    printf(";%s %lld\n", key->waker, count);
>>>                ~~~^                 ~~~~~
>>>                %ld
>>>
>>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>>> ---
>>>   samples/bpf/Makefile        | 4 ++++
>>>   tools/include/linux/types.h | 3 +++
>>>   2 files changed, 7 insertions(+)
>>>
>>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>>> index 26fc96c..27de306 100644
>>> --- a/samples/bpf/Makefile
>>> +++ b/samples/bpf/Makefile
>>> @@ -183,6 +183,10 @@ BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
>>>   TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
>>>   endif
>>>   +ifeq ($(ARCH), mips)
>>> +TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__
>>> +endif
>>> +
>>
>> This change looks okay based on description in
>> arch/mips/include/uapi/asm/types.h
>>
>> '''
>> /*
>>  * We don't use int-l64.h for the kernel anymore but still use it for
>>  * userspace to avoid code changes.
>>  *
>>  * However, some user programs (e.g. perf) may not want this. They can
>>  * flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
>>  */
>> '''
>>
>>>   TPROGS_CFLAGS += -Wall -O2
>>>   TPROGS_CFLAGS += -Wmissing-prototypes
>>>   TPROGS_CFLAGS += -Wstrict-prototypes
>>> diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
>>> index 154eb4e..e9c5a21 100644
>>> --- a/tools/include/linux/types.h
>>> +++ b/tools/include/linux/types.h
>>> @@ -6,7 +6,10 @@
>>>   #include <stddef.h>
>>>   #include <stdint.h>
>>>   +#ifndef __SANE_USERSPACE_TYPES__
>>>   #define __SANE_USERSPACE_TYPES__    /* For PPC64, to get LL64 types */
>>> +#endif
>>
>> What problem this patch fixed?
> 
> If add "TPROGS_CFLAGS += -D__SANE_USERSPACE_TYPES__" in
> samples/bpf/Makefile, it appears the following error:
> 
> Auto-detecting system features:
> ...                        libelf: [ on  ]
> ...                          zlib: [ on  ]
> ...                           bpf: [ OFF ]
> 
> BPF API too old
> make[3]: *** [Makefile:293: bpfdep] Error 1
> make[2]: *** [Makefile:156: all] Error 2
> 
> With #ifndef __SANE_USERSPACE_TYPES__  in tools/include/linux/types.h,
> the above error has gone.
> 
>> If this header is used, you can just
>> change comment from "PPC64" to "PPC64/MIPS", right?
> 
> If include <linux/types.h> in the source files which have compile warnings
> when printing __u64 with %llu, %llx or %lld, it has no effect due to 
> actually
> it includes usr/include/linux/types.h instead of 
> tools/include/linux/types.h,
> this is because the include-directories in samples/bpf/Makefile are 
> searched
> in the order, -I./usr/include is in the front of -I./tools/include.
> 
> So I think define __SANE_USERSPACE_TYPES__ for MIPS in samples/bpf/Makefile
> is proper, at the same time, add #ifndef __SANE_USERSPACE_TYPES__ in
> tools/include/linux/types.h can avoid build error and have no side effect.
> 
> I will send v2 later with mention in the commit message that this is
> mips related.

It would be good if you can add the above information to the commit
message so people will know what the root cause of the issue.

If I understand correctly, if we could have include path
"tools/include" earlier than "usr/include", we might not have this 
issue. The problem is that "usr/include" is preferred first (uapi)
than "tools/include" (including kernel dev headers).

I am wondering whether we could avoid changes in 
tools/include/linux/types.h, e.g., by undef __SANE_USER_SPACE_TYPES 
right before include
path tools/include. But that sounds like a ugly hack and actually
the change in tools/include/linux/types.h does not hurt other
compilations.

So your current change looks good to me, but please have better
explanation of the problem and why for each change in the commit
message.

> 
> Thanks,
> Tiezhu
> 
>>
>>> +
>>>   #include <asm/types.h>
>>>   #include <asm/posix_types.h>
>>>
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-01-18 18:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 10:57 [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Tiezhu Yang
2021-01-13 10:57 ` [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings Tiezhu Yang
2021-01-13 17:12   ` Yonghong Song
2021-01-18  3:22     ` Tiezhu Yang
2021-01-18 18:44       ` Yonghong Song
2021-01-13 10:57 ` [PATCH 2/2] compiler.h: Include asm/rwonce.h under ARM64 and ALPHA to fix build errors Tiezhu Yang
2021-01-13 17:14   ` Yonghong Song
2021-01-18  9:25     ` Tiezhu Yang
2021-01-14  2:18   ` kernel test robot
2021-01-14  8:40   ` Sergei Shtylyov
2021-01-14 15:58   ` kernel test robot
2021-01-13 17:16 ` [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Yonghong Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.