Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / lib / traceevent / plugins / plugin_jbd2.c
blob69111a68d3cf1ad598ef0c7d0b6b776900630d3d
1 // SPDX-License-Identifier: LGPL-2.1
2 /*
3 * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
9 #include "event-parse.h"
10 #include "trace-seq.h"
12 #define MINORBITS 20
13 #define MINORMASK ((1U << MINORBITS) - 1)
15 #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
16 #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
18 static unsigned long long
19 process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args)
21 unsigned int dev = args[0];
23 trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
24 return 0;
27 static unsigned long long
28 process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
30 unsigned long long jiffies = args[0];
32 trace_seq_printf(s, "%lld", jiffies);
33 return jiffies;
36 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
38 tep_register_print_function(tep,
39 process_jbd2_dev_to_name,
40 TEP_FUNC_ARG_STRING,
41 "jbd2_dev_to_name",
42 TEP_FUNC_ARG_INT,
43 TEP_FUNC_ARG_VOID);
45 tep_register_print_function(tep,
46 process_jiffies_to_msecs,
47 TEP_FUNC_ARG_LONG,
48 "jiffies_to_msecs",
49 TEP_FUNC_ARG_LONG,
50 TEP_FUNC_ARG_VOID);
51 return 0;
54 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
56 tep_unregister_print_function(tep, process_jbd2_dev_to_name,
57 "jbd2_dev_to_name");
59 tep_unregister_print_function(tep, process_jiffies_to_msecs,
60 "jiffies_to_msecs");