Re: [PATCH v3 bpf-next 01/15] bpf: Introduce any context BPF specific memory allocator.

kernel test robot
2022-08-20T00:03:18Z

Hi Alexei,

I love your patch! Yet something to improve:

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

url: https://github.com/intel-lab-lkp/linux/commits/Alexei-Starovoitov/bpf-BPF-specific-memory-allocator/20220820-054421
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: powerpc-randconfig-r035-20220820 (https://download.01.org/0day-ci/archive/20220820/202208200754.DmNmnDs3-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 0ac597f3cacf60479ffd36b03766fa7462dabd78)
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
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/430052d4904f4c7e48cd90f0d4efeb45f73ea69e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Alexei-Starovoitov/bpf-BPF-specific-memory-allocator/20220820-054421
git checkout 430052d4904f4c7e48cd90f0d4efeb45f73ea69e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash kernel/bpf/

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

All errors (new ones prefixed by >>):

kernel/bpf/memalloc.c:84:2: error: unknown type name 'local_t'
local_t active;
^
>> kernel/bpf/memalloc.c:178:7: error: implicit declaration of function 'local_inc_return' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (local_inc_return(&c->active) == 1) {
^
kernel/bpf/memalloc.c:178:7: note: did you mean 'atomic_inc_return'?
include/linux/atomic/atomic-instrumented.h:195:1: note: 'atomic_inc_return' declared here
atomic_inc_return(atomic_t *v)
^
>> kernel/bpf/memalloc.c:182:3: error: implicit declaration of function 'local_dec' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
local_dec(&c->active);
^
kernel/bpf/memalloc.c:207:7: error: implicit declaration of function 'local_inc_return' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (local_inc_return(&c->active) == 1) {
^
kernel/bpf/memalloc.c:214:3: error: implicit declaration of function 'local_dec' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
local_dec(&c->active);
^
kernel/bpf/memalloc.c:380:6: error: implicit declaration of function 'local_inc_return' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (local_inc_return(&c->active) == 1) {
^
kernel/bpf/memalloc.c:385:2: error: implicit declaration of function 'local_dec' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
local_dec(&c->active);
^
kernel/bpf/memalloc.c:408:6: error: implicit declaration of function 'local_inc_return' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (local_inc_return(&c->active) == 1) {
^
kernel/bpf/memalloc.c:420:2: error: implicit declaration of function 'local_dec' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
local_dec(&c->active);
^
9 errors generated.

vim +/local_inc_return +178 kernel/bpf/memalloc.c

156
157 /* Mostly runs from irq_work except __init phase. */
158 static void alloc_bulk(struct bpf_mem_cache *c, int cnt, int node)
159 {
160 struct mem_cgroup *memcg = NULL, *old_memcg;
161 unsigned long flags;
162 void *obj;
163 int i;
164
165 memcg = get_memcg(c);
166 old_memcg = set_active_memcg(memcg);
167 for (i = 0; i < cnt; i++) {
168 obj = __alloc(c, node);
169 if (!obj)
170 break;
171 if (IS_ENABLED(CONFIG_PREEMPT_RT))
172 /* In RT irq_work runs in per-cpu kthread, so disable
173 * interrupts to avoid preemption and interrupts and
174 * reduce the chance of bpf prog executing on this cpu
175 * when active counter is busy.
176 */
177 local_irq_save(flags);
> 178 if (local_inc_return(&c->active) == 1) {
179 __llist_add(obj, &c->free_llist);
180 c->free_cnt++;
181 }
> 182 local_dec(&c->active);
183 if (IS_ENABLED(CONFIG_PREEMPT_RT))
184 local_irq_restore(flags);
185 }
186 set_active_memcg(old_memcg);
187 mem_cgroup_put(memcg);
188 }
189

--
0-DAY CI Kernel Test Service