Skip to content

Commit 3e14b10

Browse files
rostedtacmel
authored andcommitted
tools lib traceevent: Add plugin for tlb_flush
The tlb_flush tracepoints uses enums that are not yet known by the traceevent library. Add a plugin to handle that. Link: http://lore.kernel.org/linux-trace-devel/20200625100516.365338-9-tz.stoyanov@gmail.com Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> [ Ported from trace-cmd.git ] Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: linux-trace-devel@vger.kernel.org Link: http://lore.kernel.org/lkml/20200702185704.706977382@goodmis.org Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent e7a9088 commit 3e14b10

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

‎tools/lib/traceevent/plugins/Build‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ plugin_function-y += plugin_function.o
88
plugin_xen-y += plugin_xen.o
99
plugin_scsi-y += plugin_scsi.o
1010
plugin_cfg80211-y += plugin_cfg80211.o
11+
plugin_tlb-y += plugin_tlb.o

‎tools/lib/traceevent/plugins/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ PLUGINS += plugin_function.so
137137
PLUGINS += plugin_xen.so
138138
PLUGINS += plugin_scsi.so
139139
PLUGINS += plugin_cfg80211.so
140+
PLUGINS += plugin_tlb.so
140141

141142
PLUGINS := $(addprefix $(OUTPUT),$(PLUGINS))
142143
PLUGINS_IN := $(PLUGINS:.so=-in.o)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (C) 2015 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
3+
*
4+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+
* This program is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation;
8+
* version 2.1 of the License (not later!)
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this program; if not, see <http://www.gnu.org/licenses>
17+
*
18+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
*/
20+
#include <stdio.h>
21+
#include <stdlib.h>
22+
#include <string.h>
23+
24+
#include "event-parse.h"
25+
26+
enum tlb_flush_reason {
27+
TLB_FLUSH_ON_TASK_SWITCH,
28+
TLB_REMOTE_SHOOTDOWN,
29+
TLB_LOCAL_SHOOTDOWN,
30+
TLB_LOCAL_MM_SHOOTDOWN,
31+
NR_TLB_FLUSH_REASONS,
32+
};
33+
34+
static int tlb_flush_handler(struct trace_seq *s, struct tep_record *record,
35+
struct tep_event *event, void *context)
36+
{
37+
unsigned long long val;
38+
39+
trace_seq_printf(s, "pages=");
40+
41+
tep_print_num_field(s, "%ld", event, "pages", record, 1);
42+
43+
if (tep_get_field_val(s, event, "reason", record, &val, 1) < 0)
44+
return -1;
45+
46+
trace_seq_puts(s, " reason=");
47+
48+
switch (val) {
49+
case TLB_FLUSH_ON_TASK_SWITCH:
50+
trace_seq_puts(s, "flush on task switch");
51+
break;
52+
case TLB_REMOTE_SHOOTDOWN:
53+
trace_seq_puts(s, "remote shootdown");
54+
break;
55+
case TLB_LOCAL_SHOOTDOWN:
56+
trace_seq_puts(s, "local shootdown");
57+
break;
58+
case TLB_LOCAL_MM_SHOOTDOWN:
59+
trace_seq_puts(s, "local mm shootdown");
60+
break;
61+
}
62+
63+
trace_seq_printf(s, " (%lld)", val);
64+
65+
return 0;
66+
}
67+
68+
int TEP_PLUGIN_LOADER(struct tep_handle *tep)
69+
{
70+
tep_register_event_handler(tep, -1, "tlb", "tlb_flush",
71+
tlb_flush_handler, NULL);
72+
73+
return 0;
74+
}
75+
76+
void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
77+
{
78+
tep_unregister_event_handler(tep, -1,
79+
"tlb", "tlb_flush",
80+
tlb_flush_handler, NULL);
81+
}

0 commit comments

Comments
 (0)