[tip:perf/core 10/17] kernel/events/core.c:9634:13: warning: 'perf_event_free_bpf_handler' defined but not used

From: kernel test robot
Date: Fri Apr 12 2024 - 09:08:27 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
head: 93d3fde7fd19c2e2cde7220e7986f9a75e9c5680
commit: 4c03fe11b96bda60610aca77002e83f37b4a2242 [10/17] perf/bpf: Reorder bpf_overflow_handler() ahead of __perf_event_overflow()
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20240412/202404122021.kE3qOoZo-lkp@xxxxxxxxx/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240412/202404122021.kE3qOoZo-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404122021.kE3qOoZo-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> kernel/events/core.c:9634:13: warning: 'perf_event_free_bpf_handler' defined but not used [-Wunused-function]
9634 | static void perf_event_free_bpf_handler(struct perf_event *event)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/events/core.c:9596:12: warning: 'perf_event_set_bpf_handler' defined but not used [-Wunused-function]
9596 | static int perf_event_set_bpf_handler(struct perf_event *event,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/perf_event_free_bpf_handler +9634 kernel/events/core.c

9595
> 9596 static int perf_event_set_bpf_handler(struct perf_event *event,
9597 struct bpf_prog *prog,
9598 u64 bpf_cookie)
9599 {
9600 if (event->overflow_handler_context)
9601 /* hw breakpoint or kernel counter */
9602 return -EINVAL;
9603
9604 if (event->prog)
9605 return -EEXIST;
9606
9607 if (prog->type != BPF_PROG_TYPE_PERF_EVENT)
9608 return -EINVAL;
9609
9610 if (event->attr.precise_ip &&
9611 prog->call_get_stack &&
9612 (!(event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) ||
9613 event->attr.exclude_callchain_kernel ||
9614 event->attr.exclude_callchain_user)) {
9615 /*
9616 * On perf_event with precise_ip, calling bpf_get_stack()
9617 * may trigger unwinder warnings and occasional crashes.
9618 * bpf_get_[stack|stackid] works around this issue by using
9619 * callchain attached to perf_sample_data. If the
9620 * perf_event does not full (kernel and user) callchain
9621 * attached to perf_sample_data, do not allow attaching BPF
9622 * program that calls bpf_get_[stack|stackid].
9623 */
9624 return -EPROTO;
9625 }
9626
9627 event->prog = prog;
9628 event->bpf_cookie = bpf_cookie;
9629 event->orig_overflow_handler = READ_ONCE(event->overflow_handler);
9630 WRITE_ONCE(event->overflow_handler, bpf_overflow_handler);
9631 return 0;
9632 }
9633
> 9634 static void perf_event_free_bpf_handler(struct perf_event *event)
9635 {
9636 struct bpf_prog *prog = event->prog;
9637
9638 if (!prog)
9639 return;
9640
9641 WRITE_ONCE(event->overflow_handler, event->orig_overflow_handler);
9642 event->prog = NULL;
9643 bpf_prog_put(prog);
9644 }
9645 #else
9646 static int perf_event_set_bpf_handler(struct perf_event *event,
9647 struct bpf_prog *prog,
9648 u64 bpf_cookie)
9649 {
9650 return -EOPNOTSUPP;
9651 }
9652

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki