aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorWang Nan <wangnan0@huawei.com>2015-11-27 03:47:37 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-11-27 20:00:46 -0500
commit0bb93490170477224f8bd4cc9ce8920517461643 (patch)
tree557cc686d470ac513c647cafd07ae61bf9793e0c /tools/perf
parent561bbccac72d08babafaa33fd7fa9100ec4c9fb6 (diff)
perf bpf: Rename bpf config to program config
Following patches are going to introduce BPF object level configuration to enable setting values into BPF maps. To avoid confusion, this patch renames existing 'config' in bpf-loader.c to 'program config'. Following patches would introduce 'object config'. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1448614067-197576-4-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/bpf-loader.c65
-rw-r--r--tools/perf/util/bpf-loader.h2
2 files changed, 33 insertions, 34 deletions
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 36544e5ece43..540a7efa657e 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -120,7 +120,7 @@ bpf_prog_priv__clear(struct bpf_program *prog __maybe_unused,
120} 120}
121 121
122static int 122static int
123config__exec(const char *value, struct perf_probe_event *pev) 123prog_config__exec(const char *value, struct perf_probe_event *pev)
124{ 124{
125 pev->uprobes = true; 125 pev->uprobes = true;
126 pev->target = strdup(value); 126 pev->target = strdup(value);
@@ -130,7 +130,7 @@ config__exec(const char *value, struct perf_probe_event *pev)
130} 130}
131 131
132static int 132static int
133config__module(const char *value, struct perf_probe_event *pev) 133prog_config__module(const char *value, struct perf_probe_event *pev)
134{ 134{
135 pev->uprobes = false; 135 pev->uprobes = false;
136 pev->target = strdup(value); 136 pev->target = strdup(value);
@@ -140,8 +140,7 @@ config__module(const char *value, struct perf_probe_event *pev)
140} 140}
141 141
142static int 142static int
143config__bool(const char *value, 143prog_config__bool(const char *value, bool *pbool, bool invert)
144 bool *pbool, bool invert)
145{ 144{
146 int err; 145 int err;
147 bool bool_value; 146 bool bool_value;
@@ -158,17 +157,17 @@ config__bool(const char *value,
158} 157}
159 158
160static int 159static int
161config__inlines(const char *value, 160prog_config__inlines(const char *value,
162 struct perf_probe_event *pev __maybe_unused) 161 struct perf_probe_event *pev __maybe_unused)
163{ 162{
164 return config__bool(value, &probe_conf.no_inlines, true); 163 return prog_config__bool(value, &probe_conf.no_inlines, true);
165} 164}
166 165
167static int 166static int
168config__force(const char *value, 167prog_config__force(const char *value,
169 struct perf_probe_event *pev __maybe_unused) 168 struct perf_probe_event *pev __maybe_unused)
170{ 169{
171 return config__bool(value, &probe_conf.force_add, false); 170 return prog_config__bool(value, &probe_conf.force_add, false);
172} 171}
173 172
174static struct { 173static struct {
@@ -176,58 +175,58 @@ static struct {
176 const char *usage; 175 const char *usage;
177 const char *desc; 176 const char *desc;
178 int (*func)(const char *, struct perf_probe_event *); 177 int (*func)(const char *, struct perf_probe_event *);
179} bpf_config_terms[] = { 178} bpf_prog_config_terms[] = {
180 { 179 {
181 .key = "exec", 180 .key = "exec",
182 .usage = "exec=<full path of file>", 181 .usage = "exec=<full path of file>",
183 .desc = "Set uprobe target", 182 .desc = "Set uprobe target",
184 .func = config__exec, 183 .func = prog_config__exec,
185 }, 184 },
186 { 185 {
187 .key = "module", 186 .key = "module",
188 .usage = "module=<module name> ", 187 .usage = "module=<module name> ",
189 .desc = "Set kprobe module", 188 .desc = "Set kprobe module",
190 .func = config__module, 189 .func = prog_config__module,
191 }, 190 },
192 { 191 {
193 .key = "inlines", 192 .key = "inlines",
194 .usage = "inlines=[yes|no] ", 193 .usage = "inlines=[yes|no] ",
195 .desc = "Probe at inline symbol", 194 .desc = "Probe at inline symbol",
196 .func = config__inlines, 195 .func = prog_config__inlines,
197 }, 196 },
198 { 197 {
199 .key = "force", 198 .key = "force",
200 .usage = "force=[yes|no] ", 199 .usage = "force=[yes|no] ",
201 .desc = "Forcibly add events with existing name", 200 .desc = "Forcibly add events with existing name",
202 .func = config__force, 201 .func = prog_config__force,
203 }, 202 },
204}; 203};
205 204
206static int 205static int
207do_config(const char *key, const char *value, 206do_prog_config(const char *key, const char *value,
208 struct perf_probe_event *pev) 207 struct perf_probe_event *pev)
209{ 208{
210 unsigned int i; 209 unsigned int i;
211 210
212 pr_debug("config bpf program: %s=%s\n", key, value); 211 pr_debug("config bpf program: %s=%s\n", key, value);
213 for (i = 0; i < ARRAY_SIZE(bpf_config_terms); i++) 212 for (i = 0; i < ARRAY_SIZE(bpf_prog_config_terms); i++)
214 if (strcmp(key, bpf_config_terms[i].key) == 0) 213 if (strcmp(key, bpf_prog_config_terms[i].key) == 0)
215 return bpf_config_terms[i].func(value, pev); 214 return bpf_prog_config_terms[i].func(value, pev);
216 215
217 pr_debug("BPF: ERROR: invalid config option in object: %s=%s\n", 216 pr_debug("BPF: ERROR: invalid program config option: %s=%s\n",
218 key, value); 217 key, value);
219 218
220 pr_debug("\nHint: Currently valid options are:\n"); 219 pr_debug("\nHint: Valid options are:\n");
221 for (i = 0; i < ARRAY_SIZE(bpf_config_terms); i++) 220 for (i = 0; i < ARRAY_SIZE(bpf_prog_config_terms); i++)
222 pr_debug("\t%s:\t%s\n", bpf_config_terms[i].usage, 221 pr_debug("\t%s:\t%s\n", bpf_prog_config_terms[i].usage,
223 bpf_config_terms[i].desc); 222 bpf_prog_config_terms[i].desc);
224 pr_debug("\n"); 223 pr_debug("\n");
225 224
226 return -BPF_LOADER_ERRNO__CONFIG_TERM; 225 return -BPF_LOADER_ERRNO__PROGCONF_TERM;
227} 226}
228 227
229static const char * 228static const char *
230parse_config_kvpair(const char *config_str, struct perf_probe_event *pev) 229parse_prog_config_kvpair(const char *config_str, struct perf_probe_event *pev)
231{ 230{
232 char *text = strdup(config_str); 231 char *text = strdup(config_str);
233 char *sep, *line; 232 char *sep, *line;
@@ -253,7 +252,7 @@ parse_config_kvpair(const char *config_str, struct perf_probe_event *pev)
253 } 252 }
254 *equ = '\0'; 253 *equ = '\0';
255 254
256 err = do_config(line, equ + 1, pev); 255 err = do_prog_config(line, equ + 1, pev);
257 if (err) 256 if (err)
258 break; 257 break;
259nextline: 258nextline:
@@ -268,10 +267,10 @@ nextline:
268} 267}
269 268
270static int 269static int
271parse_config(const char *config_str, struct perf_probe_event *pev) 270parse_prog_config(const char *config_str, struct perf_probe_event *pev)
272{ 271{
273 int err; 272 int err;
274 const char *main_str = parse_config_kvpair(config_str, pev); 273 const char *main_str = parse_prog_config_kvpair(config_str, pev);
275 274
276 if (IS_ERR(main_str)) 275 if (IS_ERR(main_str))
277 return PTR_ERR(main_str); 276 return PTR_ERR(main_str);
@@ -312,7 +311,7 @@ config_bpf_program(struct bpf_program *prog)
312 pev = &priv->pev; 311 pev = &priv->pev;
313 312
314 pr_debug("bpf: config program '%s'\n", config_str); 313 pr_debug("bpf: config program '%s'\n", config_str);
315 err = parse_config(config_str, pev); 314 err = parse_prog_config(config_str, pev);
316 if (err) 315 if (err)
317 goto errout; 316 goto errout;
318 317
@@ -750,7 +749,7 @@ static const char *bpf_loader_strerror_table[NR_ERRNO] = {
750 [ERRCODE_OFFSET(EVENTNAME)] = "No event name found in config string", 749 [ERRCODE_OFFSET(EVENTNAME)] = "No event name found in config string",
751 [ERRCODE_OFFSET(INTERNAL)] = "BPF loader internal error", 750 [ERRCODE_OFFSET(INTERNAL)] = "BPF loader internal error",
752 [ERRCODE_OFFSET(COMPILE)] = "Error when compiling BPF scriptlet", 751 [ERRCODE_OFFSET(COMPILE)] = "Error when compiling BPF scriptlet",
753 [ERRCODE_OFFSET(CONFIG_TERM)] = "Invalid config term in config string", 752 [ERRCODE_OFFSET(PROGCONF_TERM)] = "Invalid program config term in config string",
754 [ERRCODE_OFFSET(PROLOGUE)] = "Failed to generate prologue", 753 [ERRCODE_OFFSET(PROLOGUE)] = "Failed to generate prologue",
755 [ERRCODE_OFFSET(PROLOGUE2BIG)] = "Prologue too big for program", 754 [ERRCODE_OFFSET(PROLOGUE2BIG)] = "Prologue too big for program",
756 [ERRCODE_OFFSET(PROLOGUEOOB)] = "Offset out of bound for prologue", 755 [ERRCODE_OFFSET(PROLOGUEOOB)] = "Offset out of bound for prologue",
@@ -834,7 +833,7 @@ int bpf__strerror_probe(struct bpf_object *obj __maybe_unused,
834 int err, char *buf, size_t size) 833 int err, char *buf, size_t size)
835{ 834{
836 bpf__strerror_head(err, buf, size); 835 bpf__strerror_head(err, buf, size);
837 case BPF_LOADER_ERRNO__CONFIG_TERM: { 836 case BPF_LOADER_ERRNO__PROGCONF_TERM: {
838 scnprintf(buf, size, "%s (add -v to see detail)", emsg); 837 scnprintf(buf, size, "%s (add -v to see detail)", emsg);
839 break; 838 break;
840 } 839 }
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index a58740b0f31e..6fdc0457e2b6 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -20,7 +20,7 @@ enum bpf_loader_errno {
20 BPF_LOADER_ERRNO__EVENTNAME, /* Event name is missing */ 20 BPF_LOADER_ERRNO__EVENTNAME, /* Event name is missing */
21 BPF_LOADER_ERRNO__INTERNAL, /* BPF loader internal error */ 21 BPF_LOADER_ERRNO__INTERNAL, /* BPF loader internal error */
22 BPF_LOADER_ERRNO__COMPILE, /* Error when compiling BPF scriptlet */ 22 BPF_LOADER_ERRNO__COMPILE, /* Error when compiling BPF scriptlet */
23 BPF_LOADER_ERRNO__CONFIG_TERM, /* Invalid config term in config term */ 23 BPF_LOADER_ERRNO__PROGCONF_TERM,/* Invalid program config term in config string */
24 BPF_LOADER_ERRNO__PROLOGUE, /* Failed to generate prologue */ 24 BPF_LOADER_ERRNO__PROLOGUE, /* Failed to generate prologue */
25 BPF_LOADER_ERRNO__PROLOGUE2BIG, /* Prologue too big for program */ 25 BPF_LOADER_ERRNO__PROLOGUE2BIG, /* Prologue too big for program */
26 BPF_LOADER_ERRNO__PROLOGUEOOB, /* Offset out of bound for prologue */ 26 BPF_LOADER_ERRNO__PROLOGUEOOB, /* Offset out of bound for prologue */