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 <wangnan0@huawei.com>
Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1456479154-136027-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Wang Nan 2016-02-26 09:31:51 +00:00 committed by Arnaldo Carvalho de Melo
parent abab5e7fce
commit b8cbb34906
10 changed files with 15 additions and 21 deletions

View File

@ -1264,8 +1264,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
if (ret < 0) if (ret < 0)
return ret; return ret;
perf_config(perf_default_config, NULL);
argc = parse_options(argc, argv, options, diff_usage, 0); argc = parse_options(argc, argv, options, diff_usage, 0);
if (symbol__init(NULL) < 0) if (symbol__init(NULL) < 0)

View File

@ -272,7 +272,7 @@ static int perf_help_config(const char *var, const char *value, void *cb)
if (!prefixcmp(var, "man.")) if (!prefixcmp(var, "man."))
return add_man_viewer_info(var, value); return add_man_viewer_info(var, value);
return perf_default_config(var, value, cb); return 0;
} }
static struct cmdnames main_cmds, other_cmds; static struct cmdnames main_cmds, other_cmds;

View File

@ -1834,7 +1834,7 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL); return cmd_record(i, rec_argv, NULL);
} }
static int kmem_config(const char *var, const char *value, void *cb) static int kmem_config(const char *var, const char *value, void *cb __maybe_unused)
{ {
if (!strcmp(var, "kmem.default")) { if (!strcmp(var, "kmem.default")) {
if (!strcmp(value, "slab")) if (!strcmp(value, "slab"))
@ -1847,7 +1847,7 @@ static int kmem_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return perf_default_config(var, value, cb); return 0;
} }
int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)

View File

@ -90,7 +90,7 @@ static int report__config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return perf_default_config(var, value, cb); return 0;
} }
static int hist_iter__report_callback(struct hist_entry_iter *iter, static int hist_iter__report_callback(struct hist_entry_iter *iter,

View File

@ -1065,7 +1065,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
return parse_callchain_top_opt(arg); return parse_callchain_top_opt(arg);
} }
static int perf_top_config(const char *var, const char *value, void *cb) static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
{ {
if (!strcmp(var, "top.call-graph")) if (!strcmp(var, "top.call-graph"))
var = "call-graph.record-mode"; /* fall-through */ var = "call-graph.record-mode"; /* fall-through */
@ -1074,7 +1074,7 @@ static int perf_top_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return perf_default_config(var, value, cb); return 0;
} }
static int static int

View File

@ -548,6 +548,8 @@ int main(int argc, const char **argv)
srandom(time(NULL)); srandom(time(NULL));
perf_config(perf_default_config, NULL);
/* get debugfs/tracefs mount point from /proc/mounts */ /* get debugfs/tracefs mount point from /proc/mounts */
tracing_path_mount(); tracing_path_mount();

View File

@ -6,12 +6,6 @@
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
static int perf_config_cb(const char *var, const char *val,
void *arg __maybe_unused)
{
return perf_default_config(var, val, arg);
}
#ifdef HAVE_LIBBPF_SUPPORT #ifdef HAVE_LIBBPF_SUPPORT
static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz) static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
{ {
@ -77,8 +71,6 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
if (should_load_fail) if (should_load_fail)
*should_load_fail = bpf_source_table[idx].should_load_fail; *should_load_fail = bpf_source_table[idx].should_load_fail;
perf_config(perf_config_cb, NULL);
/* /*
* Skip this test if user's .perfconfig doesn't set [llvm] section * Skip this test if user's .perfconfig doesn't set [llvm] section
* and clang is not found in $PATH, and this is not perf test -v * and clang is not found in $PATH, and this is not perf test -v

View File

@ -32,14 +32,15 @@ int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty)
return 0; return 0;
} }
int perf_color_default_config(const char *var, const char *value, void *cb) int perf_color_default_config(const char *var, const char *value,
void *cb __maybe_unused)
{ {
if (!strcmp(var, "color.ui")) { if (!strcmp(var, "color.ui")) {
perf_use_color_default = perf_config_colorbool(var, value, -1); perf_use_color_default = perf_config_colorbool(var, value, -1);
return 0; return 0;
} }
return perf_default_config(var, value, cb); return 0;
} }
static int __color_vsnprintf(char *bf, size_t size, const char *color, static int __color_vsnprintf(char *bf, size_t size, const char *color,

View File

@ -1117,7 +1117,7 @@ static int convert__config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
return perf_default_config(var, value, cb); return 0;
} }
int bt_convert__perf2ctf(const char *input, const char *path, bool force) int bt_convert__perf2ctf(const char *input, const char *path, bool force)

View File

@ -6,7 +6,8 @@
static int autocorrect; static int autocorrect;
static struct cmdnames aliases; static struct cmdnames aliases;
static int perf_unknown_cmd_config(const char *var, const char *value, void *cb) static int perf_unknown_cmd_config(const char *var, const char *value,
void *cb __maybe_unused)
{ {
if (!strcmp(var, "help.autocorrect")) if (!strcmp(var, "help.autocorrect"))
autocorrect = perf_config_int(var,value); autocorrect = perf_config_int(var,value);
@ -14,7 +15,7 @@ static int perf_unknown_cmd_config(const char *var, const char *value, void *cb)
if (!prefixcmp(var, "alias.")) if (!prefixcmp(var, "alias."))
add_cmdname(&aliases, var + 6, strlen(var + 6)); add_cmdname(&aliases, var + 6, strlen(var + 6));
return perf_default_config(var, value, cb); return 0;
} }
static int levenshtein_compare(const void *p1, const void *p2) static int levenshtein_compare(const void *p1, const void *p2)