2022-06-20 08:43:07

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH bpf-next] libbpf: Include linux/log2.h to use is_pow_of_2()

is_pow_of_2() is already defined in tools/include/linux/log2.h [1],
so no need to define it again in tools/lib/bpf/libbpf_internal.h,
just include linux/log2.h directly.

[1] https://lore.kernel.org/bpf/20220619171248.GC3362@bug/

Suggested-by: Pavel Machek <[email protected]>
Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/lib/bpf/libbpf_internal.h | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index a1ad145..021946a 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -13,6 +13,7 @@
#include <limits.h>
#include <errno.h>
#include <linux/err.h>
+#include <linux/log2.h>
#include <fcntl.h>
#include <unistd.h>
#include "libbpf_legacy.h"
@@ -582,9 +583,4 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
const char *usdt_provider, const char *usdt_name,
__u64 usdt_cookie);

-static inline bool is_pow_of_2(size_t x)
-{
- return x && (x & (x - 1)) == 0;
-}
-
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */
--
2.1.0


2022-06-20 11:51:07

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH bpf-next] libbpf: Include linux/log2.h to use is_pow_of_2()

Hi Tiezhu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url: https://github.com/intel-lab-lkp/linux/commits/Tiezhu-Yang/libbpf-Include-linux-log2-h-to-use-is_pow_of_2/20220620-160053
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: s390-defconfig (https://download.01.org/0day-ci/archive/20220620/[email protected]/config)
compiler: s390-linux-gcc (GCC) 11.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/intel-lab-lkp/linux/commit/785c0dfdcebd7deec5cfaaf7bce252c40f30a350
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Tiezhu-Yang/libbpf-Include-linux-log2-h-to-use-is_pow_of_2/20220620-160053
git checkout 785c0dfdcebd7deec5cfaaf7bce252c40f30a350
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=s390 prepare

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
linker.c: In function 'linker_sanity_check_elf':
>> linker.c:722:49: error: implicit declaration of function 'is_pow_of_2'; did you mean 'is_power_of_2'? [-Werror=implicit-function-declaration]
722 | if (sec->shdr->sh_addralign && !is_pow_of_2(sec->shdr->sh_addralign))
| ^~~~~~~~~~~
| is_power_of_2
>> linker.c:722:49: error: nested extern declaration of 'is_pow_of_2' [-Werror=nested-externs]
libbpf.c: In function 'adjust_ringbuf_sz':
>> libbpf.c:5134:36: error: implicit declaration of function 'is_pow_of_2'; did you mean 'is_power_of_2'? [-Werror=implicit-function-declaration]
5134 | if ((sz % page_sz) == 0 && is_pow_of_2(sz / page_sz))
| ^~~~~~~~~~~
| is_power_of_2
>> libbpf.c:5134:36: error: nested extern declaration of 'is_pow_of_2' [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[5]: *** [tools/build/Makefile.build:96: tools/bpf/resolve_btfids/libbpf/staticobjs/linker.o] Error 1
make[5]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[5]: *** [tools/build/Makefile.build:96: tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf.o] Error 1
make[4]: *** [Makefile:157: tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf-in.o] Error 2
make[3]: *** [Makefile:55: tools/bpf/resolve_btfids//libbpf/libbpf.a] Error 2
make[2]: *** [Makefile:76: bpf/resolve_btfids] Error 2
make[1]: *** [Makefile:1344: tools/bpf/resolve_btfids] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

--
0-DAY CI Kernel Test Service
https://01.org/lkp