Commit b8cbb349 authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

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: default avatarWang Nan <wangnan0@huawei.com>
Suggested-and-Tested-by: default avatarArnaldo 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent abab5e7f
......@@ -1264,8 +1264,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
if (ret < 0)
return ret;
perf_config(perf_default_config, NULL);
argc = parse_options(argc, argv, options, diff_usage, 0);
if (symbol__init(NULL) < 0)
......
......@@ -272,7 +272,7 @@ static int perf_help_config(const char *var, const char *value, void *cb)
if (!prefixcmp(var, "man."))
return add_man_viewer_info(var, value);
return perf_default_config(var, value, cb);
return 0;
}
static struct cmdnames main_cmds, other_cmds;
......
......@@ -1834,7 +1834,7 @@ static int __cmd_record(int argc, const char **argv)
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(value, "slab"))
......@@ -1847,7 +1847,7 @@ static int kmem_config(const char *var, const char *value, void *cb)
return 0;
}
return perf_default_config(var, value, cb);
return 0;
}
int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
......
......@@ -90,7 +90,7 @@ static int report__config(const char *var, const char *value, void *cb)
return 0;
}
return perf_default_config(var, value, cb);
return 0;
}
static int hist_iter__report_callback(struct hist_entry_iter *iter,
......
......@@ -1065,7 +1065,7 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
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"))
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 perf_default_config(var, value, cb);
return 0;
}
static int
......
......@@ -548,6 +548,8 @@ int main(int argc, const char **argv)
srandom(time(NULL));
perf_config(perf_default_config, NULL);
/* get debugfs/tracefs mount point from /proc/mounts */
tracing_path_mount();
......
......@@ -6,12 +6,6 @@
#include "tests.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
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)
*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
* and clang is not found in $PATH, and this is not perf test -v
......
......@@ -32,14 +32,15 @@ int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty)
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")) {
perf_use_color_default = perf_config_colorbool(var, value, -1);
return 0;
}
return perf_default_config(var, value, cb);
return 0;
}
static int __color_vsnprintf(char *bf, size_t size, const char *color,
......
......@@ -1117,7 +1117,7 @@ static int convert__config(const char *var, const char *value, void *cb)
return 0;
}
return perf_default_config(var, value, cb);
return 0;
}
int bt_convert__perf2ctf(const char *input, const char *path, bool force)
......
......@@ -6,7 +6,8 @@
static int autocorrect;
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"))
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."))
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment