Skip to content

Commit b8cbb34

Browse files
WangNan0acmel
authored andcommitted
perf config: Bring perf_default_config to the very beginning at main()
Before this patch each subcommand calls perf_config() by themself, reading the default configuration together with subcommand specific options. If a subcommand doesn't have it own options, it needs to call 'perf_config(perf_default_config, NULL)' to ensure .perfconfig is loaded. This patch brings perf_config(perf_default_config, NULL) to the very start of main(), so subcommands don't need to do it. After this patch, 'llvm.clang-path' works for 'perf trace'. Signed-off-by: Wang Nan <[email protected]> Suggested-and-Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Li Zefan <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent abab5e7 commit b8cbb34

File tree

10 files changed

+15
-21
lines changed

10 files changed

+15
-21
lines changed

tools/perf/builtin-diff.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
12641264
if (ret < 0)
12651265
return ret;
12661266

1267-
perf_config(perf_default_config, NULL);
1268-
12691267
argc = parse_options(argc, argv, options, diff_usage, 0);
12701268

12711269
if (symbol__init(NULL) < 0)

tools/perf/builtin-help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static int perf_help_config(const char *var, const char *value, void *cb)
272272
if (!prefixcmp(var, "man."))
273273
return add_man_viewer_info(var, value);
274274

275-
return perf_default_config(var, value, cb);
275+
return 0;
276276
}
277277

278278
static struct cmdnames main_cmds, other_cmds;

tools/perf/builtin-kmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ static int __cmd_record(int argc, const char **argv)
18341834
return cmd_record(i, rec_argv, NULL);
18351835
}
18361836

1837-
static int kmem_config(const char *var, const char *value, void *cb)
1837+
static int kmem_config(const char *var, const char *value, void *cb __maybe_unused)
18381838
{
18391839
if (!strcmp(var, "kmem.default")) {
18401840
if (!strcmp(value, "slab"))
@@ -1847,7 +1847,7 @@ static int kmem_config(const char *var, const char *value, void *cb)
18471847
return 0;
18481848
}
18491849

1850-
return perf_default_config(var, value, cb);
1850+
return 0;
18511851
}
18521852

18531853
int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)

tools/perf/builtin-report.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int report__config(const char *var, const char *value, void *cb)
9090
return 0;
9191
}
9292

93-
return perf_default_config(var, value, cb);
93+
return 0;
9494
}
9595

9696
static int hist_iter__report_callback(struct hist_entry_iter *iter,

tools/perf/builtin-top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
10651065
return parse_callchain_top_opt(arg);
10661066
}
10671067

1068-
static int perf_top_config(const char *var, const char *value, void *cb)
1068+
static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
10691069
{
10701070
if (!strcmp(var, "top.call-graph"))
10711071
var = "call-graph.record-mode"; /* fall-through */
@@ -1074,7 +1074,7 @@ static int perf_top_config(const char *var, const char *value, void *cb)
10741074
return 0;
10751075
}
10761076

1077-
return perf_default_config(var, value, cb);
1077+
return 0;
10781078
}
10791079

10801080
static int

tools/perf/perf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ int main(int argc, const char **argv)
548548

549549
srandom(time(NULL));
550550

551+
perf_config(perf_default_config, NULL);
552+
551553
/* get debugfs/tracefs mount point from /proc/mounts */
552554
tracing_path_mount();
553555

tools/perf/tests/llvm.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
#include "tests.h"
77
#include "debug.h"
88

9-
static int perf_config_cb(const char *var, const char *val,
10-
void *arg __maybe_unused)
11-
{
12-
return perf_default_config(var, val, arg);
13-
}
14-
159
#ifdef HAVE_LIBBPF_SUPPORT
1610
static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
1711
{
@@ -77,8 +71,6 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
7771
if (should_load_fail)
7872
*should_load_fail = bpf_source_table[idx].should_load_fail;
7973

80-
perf_config(perf_config_cb, NULL);
81-
8274
/*
8375
* Skip this test if user's .perfconfig doesn't set [llvm] section
8476
* and clang is not found in $PATH, and this is not perf test -v

tools/perf/util/color.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty)
3232
return 0;
3333
}
3434

35-
int perf_color_default_config(const char *var, const char *value, void *cb)
35+
int perf_color_default_config(const char *var, const char *value,
36+
void *cb __maybe_unused)
3637
{
3738
if (!strcmp(var, "color.ui")) {
3839
perf_use_color_default = perf_config_colorbool(var, value, -1);
3940
return 0;
4041
}
4142

42-
return perf_default_config(var, value, cb);
43+
return 0;
4344
}
4445

4546
static int __color_vsnprintf(char *bf, size_t size, const char *color,

tools/perf/util/data-convert-bt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static int convert__config(const char *var, const char *value, void *cb)
11171117
return 0;
11181118
}
11191119

1120-
return perf_default_config(var, value, cb);
1120+
return 0;
11211121
}
11221122

11231123
int bt_convert__perf2ctf(const char *input, const char *path, bool force)

tools/perf/util/help-unknown-cmd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
static int autocorrect;
77
static struct cmdnames aliases;
88

9-
static int perf_unknown_cmd_config(const char *var, const char *value, void *cb)
9+
static int perf_unknown_cmd_config(const char *var, const char *value,
10+
void *cb __maybe_unused)
1011
{
1112
if (!strcmp(var, "help.autocorrect"))
1213
autocorrect = perf_config_int(var,value);
1314
/* Also use aliases for command lookup */
1415
if (!prefixcmp(var, "alias."))
1516
add_cmdname(&aliases, var + 6, strlen(var + 6));
1617

17-
return perf_default_config(var, value, cb);
18+
return 0;
1819
}
1920

2021
static int levenshtein_compare(const void *p1, const void *p2)

0 commit comments

Comments
 (0)