Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing/boot: Support multiple handlers for per-event histogram

Support multiple handlers for per-event histogram in boot-time tracing.
Since the histogram can register multiple same handler-actions with
different parameters, this expands the syntax to support such cases.

With this update, the 'onmax', 'onchange' and 'onmatch' handler subkeys
under per-event histogram option will take a number subkeys optionally
as below. (see [.N])

ftrace.[instance.INSTANCE.]event.GROUP.EVENT.hist {
onmax|onchange[.N] { var = <VAR>; <ACTION> [= <PARAM>] }
onmatch[.N] { event = <EVENT>; <ACTION> [= <PARAM>] }
}

The 'N' must be a digit (or digit started word).

Thus user can add several handler-actions to the histogram,
for example,

ftrace.event.SOMEGROUP.SOMEEVENT.hist {
keys = SOME_ID; lat = common_timestamp.usecs-$ts0
onmatch.1 {
event = GROUP1.STARTEVENT1
trace = latency_event, SOME_ID, $lat
}
onmatch.2 {
event = GROUP2.STARTEVENT2
trace = latency_event, SOME_ID, $lat
}
}

Then, it can trace the elapsed time from GROUP1.STARTEVENT1 to
SOMEGROUP.SOMEEVENT, and from GROUP2.STARTEVENT2 to
SOMEGROUP.SOMEEVENT with SOME_ID key.

Link: https://lkml.kernel.org/r/162856124905.203126.14913731908137885922.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
8993665a e66ed86c

+35 -8
+35 -8
kernel/trace/trace_boot.c
··· 245 245 } 246 246 247 247 static int __init 248 - trace_boot_hist_add_handler(struct xbc_node *hnode, char **bufp, 249 - char *end, const char *param) 248 + trace_boot_hist_add_one_handler(struct xbc_node *hnode, char **bufp, 249 + char *end, const char *handler, 250 + const char *param) 250 251 { 251 252 struct xbc_node *knode, *anode; 252 253 const char *p; ··· 260 259 xbc_node_get_data(hnode), param); 261 260 return -EINVAL; 262 261 } 263 - append_printf(bufp, end, ":%s(%s)", xbc_node_get_data(hnode), p); 262 + append_printf(bufp, end, ":%s(%s)", handler, p); 264 263 265 264 /* Compose 'action' parameter */ 266 265 knode = xbc_node_find_child(hnode, "trace"); ··· 295 294 return 0; 296 295 } 297 296 297 + static int __init 298 + trace_boot_hist_add_handlers(struct xbc_node *hnode, char **bufp, 299 + char *end, const char *param) 300 + { 301 + struct xbc_node *node; 302 + const char *p, *handler; 303 + int ret; 304 + 305 + handler = xbc_node_get_data(hnode); 306 + 307 + xbc_node_for_each_subkey(hnode, node) { 308 + p = xbc_node_get_data(node); 309 + if (!isdigit(p[0])) 310 + continue; 311 + /* All digit started node should be instances. */ 312 + ret = trace_boot_hist_add_one_handler(node, bufp, end, handler, param); 313 + if (ret < 0) 314 + break; 315 + } 316 + 317 + if (xbc_node_find_child(hnode, param)) 318 + ret = trace_boot_hist_add_one_handler(hnode, bufp, end, handler, param); 319 + 320 + return ret; 321 + } 322 + 298 323 /* 299 324 * Histogram boottime tracing syntax. 300 325 * ··· 332 305 * name = <HISTNAME> 333 306 * var { <VAR> = <EXPR> ... } 334 307 * pause|continue|clear 335 - * onmax|onchange { var = <VAR>; <ACTION> [= <PARAM>] } 336 - * onmatch { event = <EVENT>; <ACTION> [= <PARAM>] } 308 + * onmax|onchange[.N] { var = <VAR>; <ACTION> [= <PARAM>] } 309 + * onmatch[.N] { event = <EVENT>; <ACTION> [= <PARAM>] } 337 310 * filter = <FILTER> 338 311 * } 339 312 * ··· 395 368 396 369 /* Histogram handler and actions */ 397 370 node = xbc_node_find_child(hnode, "onmax"); 398 - if (node && trace_boot_hist_add_handler(node, &buf, end, "var") < 0) 371 + if (node && trace_boot_hist_add_handlers(node, &buf, end, "var") < 0) 399 372 return -EINVAL; 400 373 node = xbc_node_find_child(hnode, "onchange"); 401 - if (node && trace_boot_hist_add_handler(node, &buf, end, "var") < 0) 374 + if (node && trace_boot_hist_add_handlers(node, &buf, end, "var") < 0) 402 375 return -EINVAL; 403 376 node = xbc_node_find_child(hnode, "onmatch"); 404 - if (node && trace_boot_hist_add_handler(node, &buf, end, "event") < 0) 377 + if (node && trace_boot_hist_add_handlers(node, &buf, end, "event") < 0) 405 378 return -EINVAL; 406 379 407 380 p = xbc_node_find_value(hnode, "filter", NULL);