aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/lib/traceevent/Makefile2
-rw-r--r--tools/lib/traceevent/plugin_jbd2.c66
2 files changed, 68 insertions, 0 deletions
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index f9468519d5f7..6c6540075a67 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -212,6 +212,8 @@ PEVENT_LIB_OBJS += parse-filter.o
212PEVENT_LIB_OBJS += parse-utils.o 212PEVENT_LIB_OBJS += parse-utils.o
213PEVENT_LIB_OBJS += kbuffer-parse.o 213PEVENT_LIB_OBJS += kbuffer-parse.o
214 214
215PLUGIN_OBJS = plugin_jbd2.o
216
215PLUGINS := $(PLUGIN_OBJS:.o=.so) 217PLUGINS := $(PLUGIN_OBJS:.o=.so)
216 218
217ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS) 219ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS)
diff --git a/tools/lib/traceevent/plugin_jbd2.c b/tools/lib/traceevent/plugin_jbd2.c
new file mode 100644
index 000000000000..5d85de741b52
--- /dev/null
+++ b/tools/lib/traceevent/plugin_jbd2.c
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2010 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#define MINORBITS 20
27#define MINORMASK ((1U << MINORBITS) - 1)
28
29#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
30#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
31
32unsigned long long process_jbd2_dev_to_name(struct trace_seq *s,
33 unsigned long long *args)
34{
35 unsigned int dev = args[0];
36
37 trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
38 return 0;
39}
40
41unsigned long long process_jiffies_to_msecs(struct trace_seq *s,
42 unsigned long long *args)
43{
44 unsigned long long jiffies = args[0];
45
46 trace_seq_printf(s, "%lld", jiffies);
47 return jiffies;
48}
49
50int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
51{
52 pevent_register_print_function(pevent,
53 process_jbd2_dev_to_name,
54 PEVENT_FUNC_ARG_STRING,
55 "jbd2_dev_to_name",
56 PEVENT_FUNC_ARG_INT,
57 PEVENT_FUNC_ARG_VOID);
58
59 pevent_register_print_function(pevent,
60 process_jiffies_to_msecs,
61 PEVENT_FUNC_ARG_LONG,
62 "jiffies_to_msecs",
63 PEVENT_FUNC_ARG_LONG,
64 PEVENT_FUNC_ARG_VOID);
65 return 0;
66}