[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202210281119.zghWtpd0-lkp@intel.com>
Date: Fri, 28 Oct 2022 11:13:52 +0800
From: kernel test robot <lkp@...el.com>
To: Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Greg KH <greg@...ah.com>, Jiri Kosina <jikos@...nel.org>,
Jonathan Corbet <corbet@....net>,
Shuah Khan <skhan@...uxfoundation.org>
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
Tero Kristo <tero.kristo@...ux.intel.com>,
linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-doc@...r.kernel.org,
Benjamin Tissoires <benjamin.tissoires@...hat.com>
Subject: Re: [PATCH hid v11 04/14] HID: bpf jmp table: simplify the logic of
cleaning up programs
Hi Benjamin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on hid/master]
url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git master
patch link: https://lore.kernel.org/r/20221025093458.457089-5-benjamin.tissoires%40redhat.com
patch subject: [PATCH hid v11 04/14] HID: bpf jmp table: simplify the logic of cleaning up programs
config: arm64-randconfig-r015-20221027
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
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 arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/e16299dd3103acbce798add51a7595b8c59ecb9e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Benjamin-Tissoires/Introduce-eBPF-support-for-HID-devices/20221025-173852
git checkout e16299dd3103acbce798add51a7595b8c59ecb9e
# 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=arm64 SHELL=/bin/bash drivers/hid/bpf/ fs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> drivers/hid/bpf/hid_bpf_jmp_table.c:288:9: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
int i, cnt, index = -1, map_fd = -1, err = -EINVAL;
^
1 warning generated.
vim +/cnt +288 drivers/hid/bpf/hid_bpf_jmp_table.c
281
282 /*
283 * Insert the given BPF program represented by its fd in the jmp table.
284 * Returns the index in the jump table or a negative error.
285 */
286 static int hid_bpf_insert_prog(int prog_fd, struct bpf_prog *prog)
287 {
> 288 int i, cnt, index = -1, map_fd = -1, err = -EINVAL;
289
290 /* retrieve a fd of our prog_array map in BPF */
291 map_fd = skel_map_get_fd_by_id(jmp_table.map->id);
292
293 if (map_fd < 0) {
294 err = -EINVAL;
295 goto out;
296 }
297
298 cnt = 0;
299 /* find the first available index in the jmp_table
300 * and count how many time this program has been inserted
301 */
302 for (i = 0; i < HID_BPF_MAX_PROGS; i++) {
303 if (!jmp_table.progs[i] && index < 0) {
304 /* mark the index as used */
305 jmp_table.progs[i] = prog;
306 index = i;
307 __set_bit(i, jmp_table.enabled);
308 cnt++;
309 } else {
310 if (jmp_table.progs[i] == prog)
311 cnt++;
312 }
313 }
314 if (index < 0) {
315 err = -ENOMEM;
316 goto out;
317 }
318
319 /* insert the program in the jump table */
320 err = skel_map_update_elem(map_fd, &index, &prog_fd, 0);
321 if (err)
322 goto out;
323
324 /*
325 * The program has been safely inserted, decrement the reference count
326 * so it doesn't interfere with the number of actual user handles.
327 * This is safe to do because:
328 * - we overrite the put_ptr in the prog fd map
329 * - we also have a cleanup function that monitors when a program gets
330 * released and we manually do the cleanup in the prog fd map
331 */
332 bpf_prog_sub(prog, 1);
333
334 /* return the index */
335 err = index;
336
337 out:
338 if (err < 0)
339 __hid_bpf_do_release_prog(map_fd, index);
340 if (map_fd >= 0)
341 close_fd(map_fd);
342 return err;
343 }
344
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (168720 bytes)
Powered by blists - more mailing lists