[lkml]   [2019]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 34/85] perf config: Bail out when a handler returns failure for a key-value pair
From: Arnaldo Carvalho de Melo <>

So perf_config() uses:

int ret = 0;

perf_config_set__for_each_entry(config_set, section, item) {
ret = fn();
if (ret < 0)

return ret;

Expecting that that break will imediatelly go to function exit to return
that error value (ret).

The problem is that perf_config_set__for_each_entry() expands into two
nested for() loops, one traversing the sections in a config and the
second the items in each of those sections, so we have to change that
'break' to a goto label right before that final 'return ret'.

With that, for instance 'perf trace' now correctly bails out when a
event that is requested to be added via its 'trace.add_events'
~/.perfconfig entry gets rejected by the kernel BPF verifier:

# perf trace ls
event syntax error: '/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o'
\___ Kernel verifier blocks program loading

(add -v to see detail)
Run 'perf list' for a list of valid events
Error: wrong config key-value pair trace.add_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o

While before it would continue and explode later, when trying to find
maps that would have been in place had that augmented_raw_syscalls.o
precompiled BPF proggie been accepted by the, humm, bast... rigorous
kernel BPF verifier 8-)

Cc: Adrian Hunter <>
Cc: Alexander Shishkin <>
Cc: Alexei Starovoitov <>
Cc: Daniel Borkmann <>
Cc: Jiri Olsa <>
Cc: Martin KaFai Lau <>
Cc: Mathieu Poirier <>
Cc: Mike Leach <>
Cc: Namhyung Kim <>
Cc: Song Liu <>
Cc: Suzuki Poulouse <>
Cc: Taeung Song <>
Cc: Yonghong Song <>
Fixes: 8a0a9c7e9146 ("perf config: Introduce new init() and exit()")
Signed-off-by: Arnaldo Carvalho de Melo <>
tools/perf/util/config.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
index 7e3c1b60120c..e7d2c08d263a 100644
--- a/tools/perf/util/config.c
+++ b/tools/perf/util/config.c
@@ -739,11 +739,15 @@ int perf_config(config_fn_t fn, void *data)
if (ret < 0) {
pr_err("Error: wrong config key-value pair %s=%s\n",
key, value);
- break;
+ /*
+ * Can't be just a 'break', as perf_config_set__for_each_entry()
+ * expands to two nested for() loops.
+ */
+ goto out;
return ret;

 \ /
  Last update: 2019-06-11 21:15    [W:0.329 / U:1.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site