From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [ast:timer 4/4] kernel/bpf/helpers.c:1022:6: warning: variable 'ret' set but not used
Date: Wed, 23 Jun 2021 16:01:07 +0800 [thread overview]
Message-ID: <202106231602.nidRgTxc-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 7798 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git timer
head: eb86df61cd52ea2e05357f8ae2b77e9bf6d63463
commit: eb86df61cd52ea2e05357f8ae2b77e9bf6d63463 [4/4] bpf: Implement verifier support for validation of async callbacks.
config: parisc-randconfig-s032-20210622 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-341-g8af24329-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/commit/?id=eb86df61cd52ea2e05357f8ae2b77e9bf6d63463
git remote add ast https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git
git fetch --no-tags ast timer
git checkout eb86df61cd52ea2e05357f8ae2b77e9bf6d63463
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
kernel/bpf/helpers.c: In function 'bpf_timer_cb':
>> kernel/bpf/helpers.c:1022:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
1022 | int ret;
| ^~~
In file included from <command-line>:
In function '____bpf_timer_init',
inlined from 'bpf_timer_init' at kernel/bpf/helpers.c:1064:1:
include/linux/compiler_types.h:328:38: error: call to '__compiletime_assert_353' declared with attribute error: BUILD_BUG_ON failed: __alignof__(struct bpf_timer_kern) != __alignof__(struct bpf_timer)
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler_types.h:309:4: note: in definition of macro '__compiletime_assert'
309 | prefix ## suffix(); \
| ^~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
kernel/bpf/helpers.c:1073:2: note: in expansion of macro 'BUILD_BUG_ON'
1073 | BUILD_BUG_ON(__alignof__(struct bpf_timer_kern) != __alignof__(struct bpf_timer));
| ^~~~~~~~~~~~
vim +/ret +1022 kernel/bpf/helpers.c
7e26a76313f427 Alexei Starovoitov 2021-05-17 1011
7e26a76313f427 Alexei Starovoitov 2021-05-17 1012 static enum hrtimer_restart bpf_timer_cb(struct hrtimer *hrtimer)
7e26a76313f427 Alexei Starovoitov 2021-05-17 1013 {
7e26a76313f427 Alexei Starovoitov 2021-05-17 1014 struct bpf_hrtimer *t = container_of(hrtimer, struct bpf_hrtimer, timer);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1015 struct bpf_map *map = t->map;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1016 void *value = t->value;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1017 struct bpf_timer_kern *timer = value + map->timer_off;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1018 struct bpf_prog *prog;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1019 void *callback_fn;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1020 void *key;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1021 u32 idx;
7e26a76313f427 Alexei Starovoitov 2021-05-17 @1022 int ret;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1023
7e26a76313f427 Alexei Starovoitov 2021-05-17 1024 ____bpf_spin_lock(&timer->lock);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1025 /* callback_fn and prog need to match. They're updated together
7e26a76313f427 Alexei Starovoitov 2021-05-17 1026 * and have to be read under lock.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1027 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1028 prog = t->prog;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1029 callback_fn = t->callback_fn;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1030
7e26a76313f427 Alexei Starovoitov 2021-05-17 1031 /* wrap bpf subprog invocation with prog->refcnt++ and -- to make
7e26a76313f427 Alexei Starovoitov 2021-05-17 1032 * sure that refcnt doesn't become zero when subprog is executing.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1033 * Do it under lock to make sure that bpf_timer_start doesn't drop
7e26a76313f427 Alexei Starovoitov 2021-05-17 1034 * prev prog refcnt to zero before timer_cb has a chance to bump it.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1035 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1036 bpf_prog_inc(prog);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1037 ____bpf_spin_unlock(&timer->lock);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1038
7e26a76313f427 Alexei Starovoitov 2021-05-17 1039 /* bpf_timer_cb() runs in hrtimer_run_softirq. It doesn't migrate and
7e26a76313f427 Alexei Starovoitov 2021-05-17 1040 * cannot be preempted by another bpf_timer_cb() on the same cpu.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1041 * Remember the timer this callback is servicing to prevent
7e26a76313f427 Alexei Starovoitov 2021-05-17 1042 * deadlock if callback_fn() calls bpf_timer_cancel() on the same timer.
7e26a76313f427 Alexei Starovoitov 2021-05-17 1043 */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1044 this_cpu_write(hrtimer_running, t);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1045 if (map->map_type == BPF_MAP_TYPE_ARRAY) {
7e26a76313f427 Alexei Starovoitov 2021-05-17 1046 struct bpf_array *array = container_of(map, struct bpf_array, map);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1047
7e26a76313f427 Alexei Starovoitov 2021-05-17 1048 /* compute the key */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1049 idx = ((char *)value - array->value) / array->elem_size;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1050 key = &idx;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1051 } else { /* hash or lru */
7e26a76313f427 Alexei Starovoitov 2021-05-17 1052 key = value - round_up(map->key_size, 8);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1053 }
7e26a76313f427 Alexei Starovoitov 2021-05-17 1054
7e26a76313f427 Alexei Starovoitov 2021-05-17 1055 ret = BPF_CAST_CALL(callback_fn)((u64)(long)map,
7e26a76313f427 Alexei Starovoitov 2021-05-17 1056 (u64)(long)key,
7e26a76313f427 Alexei Starovoitov 2021-05-17 1057 (u64)(long)value, 0, 0);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1058 bpf_prog_put(prog);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1059
7e26a76313f427 Alexei Starovoitov 2021-05-17 1060 this_cpu_write(hrtimer_running, NULL);
7e26a76313f427 Alexei Starovoitov 2021-05-17 1061 return HRTIMER_NORESTART;
7e26a76313f427 Alexei Starovoitov 2021-05-17 1062 }
7e26a76313f427 Alexei Starovoitov 2021-05-17 1063
:::::: The code at line 1022 was first introduced by commit
:::::: 7e26a76313f4274c6013a7565411f3f7b6773b29 bpf: Introduce bpf_timer
:::::: TO: Alexei Starovoitov <ast@kernel.org>
:::::: CC: Alexei Starovoitov <ast@kernel.org>
---
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: 21510 bytes --]
next reply other threads:[~2021-06-23 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 8:01 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-06-23 9:23 [ast:timer 4/4] kernel/bpf/helpers.c:1022:6: warning: variable 'ret' set but not used kernel test robot
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=202106231602.nidRgTxc-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.org \
/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 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.