Skip to content

Commit ce4c8f8

Browse files
committed
Merge tag 'trace-v5.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Minor fixes to the processing of the bootconfig tree" * tag 'trace-v5.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: bootconfig: Rename xbc_node_find_child() to xbc_node_find_subkey() tracing/boot: Fix to check the histogram control param is a leaf node tracing/boot: Fix trace_boot_hist_add_array() to check array is value
2 parents a1406e4 + 5dfe50b commit ce4c8f8

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

include/linux/bootconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static inline __init bool xbc_node_is_leaf(struct xbc_node *node)
110110
}
111111

112112
/* Tree-based key-value access APIs */
113-
struct xbc_node * __init xbc_node_find_child(struct xbc_node *parent,
113+
struct xbc_node * __init xbc_node_find_subkey(struct xbc_node *parent,
114114
const char *key);
115115

116116
const char * __init xbc_node_find_value(struct xbc_node *parent,
@@ -148,7 +148,7 @@ xbc_find_value(const char *key, struct xbc_node **vnode)
148148
*/
149149
static inline struct xbc_node * __init xbc_find_node(const char *key)
150150
{
151-
return xbc_node_find_child(NULL, key);
151+
return xbc_node_find_subkey(NULL, key);
152152
}
153153

154154
/**

kernel/trace/trace_boot.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,12 @@ static int __init
219219
trace_boot_hist_add_array(struct xbc_node *hnode, char **bufp,
220220
char *end, const char *key)
221221
{
222-
struct xbc_node *knode, *anode;
222+
struct xbc_node *anode;
223223
const char *p;
224224
char sep;
225225

226-
knode = xbc_node_find_child(hnode, key);
227-
if (knode) {
228-
anode = xbc_node_get_child(knode);
226+
p = xbc_node_find_value(hnode, key, &anode);
227+
if (p) {
229228
if (!anode) {
230229
pr_err("hist.%s requires value(s).\n", key);
231230
return -EINVAL;
@@ -263,9 +262,9 @@ trace_boot_hist_add_one_handler(struct xbc_node *hnode, char **bufp,
263262
append_printf(bufp, end, ":%s(%s)", handler, p);
264263

265264
/* Compose 'action' parameter */
266-
knode = xbc_node_find_child(hnode, "trace");
265+
knode = xbc_node_find_subkey(hnode, "trace");
267266
if (!knode)
268-
knode = xbc_node_find_child(hnode, "save");
267+
knode = xbc_node_find_subkey(hnode, "save");
269268

270269
if (knode) {
271270
anode = xbc_node_get_child(knode);
@@ -284,7 +283,7 @@ trace_boot_hist_add_one_handler(struct xbc_node *hnode, char **bufp,
284283
sep = ',';
285284
}
286285
append_printf(bufp, end, ")");
287-
} else if (xbc_node_find_child(hnode, "snapshot")) {
286+
} else if (xbc_node_find_subkey(hnode, "snapshot")) {
288287
append_printf(bufp, end, ".snapshot()");
289288
} else {
290289
pr_err("hist.%s requires an action.\n",
@@ -315,7 +314,7 @@ trace_boot_hist_add_handlers(struct xbc_node *hnode, char **bufp,
315314
break;
316315
}
317316

318-
if (xbc_node_find_child(hnode, param))
317+
if (xbc_node_find_subkey(hnode, param))
319318
ret = trace_boot_hist_add_one_handler(hnode, bufp, end, handler, param);
320319

321320
return ret;
@@ -375,7 +374,7 @@ trace_boot_compose_hist_cmd(struct xbc_node *hnode, char *buf, size_t size)
375374
if (p)
376375
append_printf(&buf, end, ":name=%s", p);
377376

378-
node = xbc_node_find_child(hnode, "var");
377+
node = xbc_node_find_subkey(hnode, "var");
379378
if (node) {
380379
xbc_node_for_each_key_value(node, knode, p) {
381380
/* Expression must not include spaces. */
@@ -386,21 +385,21 @@ trace_boot_compose_hist_cmd(struct xbc_node *hnode, char *buf, size_t size)
386385
}
387386

388387
/* Histogram control attributes (mutual exclusive) */
389-
if (xbc_node_find_child(hnode, "pause"))
388+
if (xbc_node_find_value(hnode, "pause", NULL))
390389
append_printf(&buf, end, ":pause");
391-
else if (xbc_node_find_child(hnode, "continue"))
390+
else if (xbc_node_find_value(hnode, "continue", NULL))
392391
append_printf(&buf, end, ":continue");
393-
else if (xbc_node_find_child(hnode, "clear"))
392+
else if (xbc_node_find_value(hnode, "clear", NULL))
394393
append_printf(&buf, end, ":clear");
395394

396395
/* Histogram handler and actions */
397-
node = xbc_node_find_child(hnode, "onmax");
396+
node = xbc_node_find_subkey(hnode, "onmax");
398397
if (node && trace_boot_hist_add_handlers(node, &buf, end, "var") < 0)
399398
return -EINVAL;
400-
node = xbc_node_find_child(hnode, "onchange");
399+
node = xbc_node_find_subkey(hnode, "onchange");
401400
if (node && trace_boot_hist_add_handlers(node, &buf, end, "var") < 0)
402401
return -EINVAL;
403-
node = xbc_node_find_child(hnode, "onmatch");
402+
node = xbc_node_find_subkey(hnode, "onmatch");
404403
if (node && trace_boot_hist_add_handlers(node, &buf, end, "event") < 0)
405404
return -EINVAL;
406405

@@ -437,7 +436,7 @@ trace_boot_init_histograms(struct trace_event_file *file,
437436
}
438437
}
439438

440-
if (xbc_node_find_child(hnode, "keys")) {
439+
if (xbc_node_find_subkey(hnode, "keys")) {
441440
if (trace_boot_compose_hist_cmd(hnode, buf, size) == 0) {
442441
tmp = kstrdup(buf, GFP_KERNEL);
443442
if (trigger_process_regex(file, buf) < 0)
@@ -496,7 +495,7 @@ trace_boot_init_one_event(struct trace_array *tr, struct xbc_node *gnode,
496495
else if (trigger_process_regex(file, buf) < 0)
497496
pr_err("Failed to apply an action: %s\n", p);
498497
}
499-
anode = xbc_node_find_child(enode, "hist");
498+
anode = xbc_node_find_subkey(enode, "hist");
500499
if (anode)
501500
trace_boot_init_histograms(file, anode, buf, ARRAY_SIZE(buf));
502501
} else if (xbc_node_find_value(enode, "actions", NULL))
@@ -518,7 +517,7 @@ trace_boot_init_events(struct trace_array *tr, struct xbc_node *node)
518517
bool enable, enable_all = false;
519518
const char *data;
520519

521-
node = xbc_node_find_child(node, "event");
520+
node = xbc_node_find_subkey(node, "event");
522521
if (!node)
523522
return;
524523
/* per-event key starts with "event.GROUP.EVENT" */
@@ -621,7 +620,7 @@ trace_boot_init_instances(struct xbc_node *node)
621620
struct trace_array *tr;
622621
const char *p;
623622

624-
node = xbc_node_find_child(node, "instance");
623+
node = xbc_node_find_subkey(node, "instance");
625624
if (!node)
626625
return;
627626

lib/bootconfig.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ xbc_node_match_prefix(struct xbc_node *node, const char **prefix)
142142
}
143143

144144
/**
145-
* xbc_node_find_child() - Find a child node which matches given key
145+
* xbc_node_find_subkey() - Find a subkey node which matches given key
146146
* @parent: An XBC node.
147147
* @key: A key string.
148148
*
149-
* Search a node under @parent which matches @key. The @key can contain
149+
* Search a key node under @parent which matches @key. The @key can contain
150150
* several words jointed with '.'. If @parent is NULL, this searches the
151151
* node from whole tree. Return NULL if no node is matched.
152152
*/
153153
struct xbc_node * __init
154-
xbc_node_find_child(struct xbc_node *parent, const char *key)
154+
xbc_node_find_subkey(struct xbc_node *parent, const char *key)
155155
{
156156
struct xbc_node *node;
157157

@@ -191,7 +191,7 @@ const char * __init
191191
xbc_node_find_value(struct xbc_node *parent, const char *key,
192192
struct xbc_node **vnode)
193193
{
194-
struct xbc_node *node = xbc_node_find_child(parent, key);
194+
struct xbc_node *node = xbc_node_find_subkey(parent, key);
195195

196196
if (!node || !xbc_node_is_key(node))
197197
return NULL;

0 commit comments

Comments
 (0)