bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Yonghong Song <yhs@fb.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-sparse@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, clang-built-linux@googlegroups.com,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH bpf 1/2] samples/bpf: Set flag __SANE_USERSPACE_TYPES__ for MIPS to fix build warnings
Date: Mon, 18 Jan 2021 11:22:20 +0800	[thread overview]
Message-ID: <f077bcae-97be-fc7f-c3fa-c6026bfe25d2@loongson.cn> (raw)
In-Reply-To: <e3eb5919-4573-4576-e6aa-bd8ff56409ed@fb.com>

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>
>>


  reply	other threads:[~2021-01-18  3:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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  8:40   ` Sergei Shtylyov
2021-01-13 17:16 ` [PATCH 0/2] Fix build errors and warnings when make M=samples/bpf Yonghong Song

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=f077bcae-97be-fc7f-c3fa-c6026bfe25d2@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).