Skip to content

Commit ac68154

Browse files
ZhengjunXingrostedt
authored andcommitted
tracing: Add "gfp_t" support in synthetic_events
Add "gfp_t" support in synthetic_events, then the "gfp_t" type parameter in some functions can be traced. Prints the gfp flags as hex in addition to the human-readable flag string. Example output: whoopsie-630 [000] ...1 78.969452: testevent: bar=b20 (GFP_ATOMIC|__GFP_ZERO) rcuc/0-11 [000] ...1 81.097555: testevent: bar=a20 (GFP_ATOMIC) rcuc/0-11 [000] ...1 81.583123: testevent: bar=a20 (GFP_ATOMIC) Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Zhengjun Xing <[email protected]> [ Added printing of flag names ] Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent a47b53e commit ac68154

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <linux/rculist.h>
1414
#include <linux/tracefs.h>
1515

16+
/* for gfp flag names */
17+
#include <linux/trace_events.h>
18+
#include <trace/events/mmflags.h>
19+
1620
#include "tracing_map.h"
1721
#include "trace.h"
1822
#include "trace_dynevent.h"
@@ -752,6 +756,8 @@ static int synth_field_size(char *type)
752756
size = sizeof(unsigned long);
753757
else if (strcmp(type, "pid_t") == 0)
754758
size = sizeof(pid_t);
759+
else if (strcmp(type, "gfp_t") == 0)
760+
size = sizeof(gfp_t);
755761
else if (synth_field_is_string(type))
756762
size = synth_field_string_size(type);
757763

@@ -792,6 +798,8 @@ static const char *synth_field_fmt(char *type)
792798
fmt = "%lu";
793799
else if (strcmp(type, "pid_t") == 0)
794800
fmt = "%d";
801+
else if (strcmp(type, "gfp_t") == 0)
802+
fmt = "%x";
795803
else if (synth_field_is_string(type))
796804
fmt = "%s";
797805

@@ -834,9 +842,20 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter,
834842
i == se->n_fields - 1 ? "" : " ");
835843
n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
836844
} else {
845+
struct trace_print_flags __flags[] = {
846+
__def_gfpflag_names, {-1, NULL} };
847+
837848
trace_seq_printf(s, print_fmt, se->fields[i]->name,
838849
entry->fields[n_u64],
839850
i == se->n_fields - 1 ? "" : " ");
851+
852+
if (strcmp(se->fields[i]->type, "gfp_t") == 0) {
853+
trace_seq_puts(s, " (");
854+
trace_print_flags_seq(s, "|",
855+
entry->fields[n_u64],
856+
__flags);
857+
trace_seq_putc(s, ')');
858+
}
840859
n_u64++;
841860
}
842861
}

0 commit comments

Comments
 (0)