Skip to content

Commit 5f2e094

Browse files
Tom Zanussirostedt
authored andcommitted
tracing: Allow multiple hitcount values in histograms
The hitcount is treated specially in the histograms - since it's always expected to be there regardless of whether the user specified anything or not, it's always added as the first histogram value. Currently the code doesn't allow it to be added more than once as a value, which is inconsistent with all the other possible values. It would seem to be a pointless thing to want to do, but other features being added such as percent and graph modifiers don't work properly with the current hitcount restrictions. Fix this by allowing multiple hitcounts to be added. Link: https://lore.kernel.org/linux-trace-kernel/166610812248.56030.16754785928712505251.stgit@devnote2 Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Tested-by: Tom Zanussi <[email protected]>
1 parent fd3dc56 commit 5f2e094

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,8 @@ static const char *hist_field_name(struct hist_field *field,
13561356
field_name = field->name;
13571357
} else if (field->flags & HIST_FIELD_FL_TIMESTAMP)
13581358
field_name = "common_timestamp";
1359+
else if (field->flags & HIST_FIELD_FL_HITCOUNT)
1360+
field_name = "hitcount";
13591361

13601362
if (field_name == NULL)
13611363
field_name = "";
@@ -2328,6 +2330,8 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file,
23282330
hist_data->attrs->ts_in_usecs = true;
23292331
} else if (strcmp(field_name, "common_cpu") == 0)
23302332
*flags |= HIST_FIELD_FL_CPU;
2333+
else if (strcmp(field_name, "hitcount") == 0)
2334+
*flags |= HIST_FIELD_FL_HITCOUNT;
23312335
else {
23322336
field = trace_find_event_field(file->event_call, field_name);
23332337
if (!field || !field->size) {
@@ -4328,8 +4332,8 @@ static int create_var_field(struct hist_trigger_data *hist_data,
43284332
static int create_val_fields(struct hist_trigger_data *hist_data,
43294333
struct trace_event_file *file)
43304334
{
4335+
unsigned int i, j = 1, n_hitcount = 0;
43314336
char *fields_str, *field_str;
4332-
unsigned int i, j = 1;
43334337
int ret;
43344338

43354339
ret = create_hitcount_val(hist_data);
@@ -4346,8 +4350,10 @@ static int create_val_fields(struct hist_trigger_data *hist_data,
43464350
if (!field_str)
43474351
break;
43484352

4349-
if (strcmp(field_str, "hitcount") == 0)
4350-
continue;
4353+
if (strcmp(field_str, "hitcount") == 0) {
4354+
if (!n_hitcount++)
4355+
continue;
4356+
}
43514357

43524358
ret = create_val_field(hist_data, j++, file, field_str);
43534359
if (ret)

0 commit comments

Comments
 (0)