Skip to content

Commit 656fe2b

Browse files
tzanussirostedt
authored andcommittedDec 22, 2018
tracing: Use hist trigger's var_ref array to destroy var_refs
Since every var ref for a trigger has an entry in the var_ref[] array, use that to destroy the var_refs, instead of piecemeal via the field expressions. This allows us to avoid having to keep and treat differently separate lists for the action-related references, which future patches will remove. Link: http://lkml.kernel.org/r/fad1a164f0e257c158e70d6eadbf6c586e04b2a2.1545161087.git.tom.zanussi@linux.intel.com Acked-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent de40f03 commit 656fe2b

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed
 

‎kernel/trace/trace_events_hist.c

+19-5
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,15 @@ static int contains_operator(char *str)
21902190
return field_op;
21912191
}
21922192

2193+
static void __destroy_hist_field(struct hist_field *hist_field)
2194+
{
2195+
kfree(hist_field->var.name);
2196+
kfree(hist_field->name);
2197+
kfree(hist_field->type);
2198+
2199+
kfree(hist_field);
2200+
}
2201+
21932202
static void destroy_hist_field(struct hist_field *hist_field,
21942203
unsigned int level)
21952204
{
@@ -2201,14 +2210,13 @@ static void destroy_hist_field(struct hist_field *hist_field,
22012210
if (!hist_field)
22022211
return;
22032212

2213+
if (hist_field->flags & HIST_FIELD_FL_VAR_REF)
2214+
return; /* var refs will be destroyed separately */
2215+
22042216
for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++)
22052217
destroy_hist_field(hist_field->operands[i], level + 1);
22062218

2207-
kfree(hist_field->var.name);
2208-
kfree(hist_field->name);
2209-
kfree(hist_field->type);
2210-
2211-
kfree(hist_field);
2219+
__destroy_hist_field(hist_field);
22122220
}
22132221

22142222
static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
@@ -2335,6 +2343,12 @@ static void destroy_hist_fields(struct hist_trigger_data *hist_data)
23352343
hist_data->fields[i] = NULL;
23362344
}
23372345
}
2346+
2347+
for (i = 0; i < hist_data->n_var_refs; i++) {
2348+
WARN_ON(!(hist_data->var_refs[i]->flags & HIST_FIELD_FL_VAR_REF));
2349+
__destroy_hist_field(hist_data->var_refs[i]);
2350+
hist_data->var_refs[i] = NULL;
2351+
}
23382352
}
23392353

23402354
static int init_var_ref(struct hist_field *ref_field,

0 commit comments

Comments
 (0)
Please sign in to comment.