Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: LGPL-2.1
0002 /*
0003  * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
0004  */
0005 #include <stdio.h>
0006 #include <stdlib.h>
0007 #include <string.h>
0008 
0009 #include "event-parse.h"
0010 #include "trace-seq.h"
0011 
0012 #define MINORBITS   20
0013 #define MINORMASK   ((1U << MINORBITS) - 1)
0014 
0015 #define MAJOR(dev)  ((unsigned int) ((dev) >> MINORBITS))
0016 #define MINOR(dev)  ((unsigned int) ((dev) & MINORMASK))
0017 
0018 static unsigned long long
0019 process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args)
0020 {
0021     unsigned int dev = args[0];
0022 
0023     trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
0024     return 0;
0025 }
0026 
0027 static unsigned long long
0028 process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
0029 {
0030     unsigned long long jiffies = args[0];
0031 
0032     trace_seq_printf(s, "%lld", jiffies);
0033     return jiffies;
0034 }
0035 
0036 int TEP_PLUGIN_LOADER(struct tep_handle *tep)
0037 {
0038     tep_register_print_function(tep,
0039                     process_jbd2_dev_to_name,
0040                     TEP_FUNC_ARG_STRING,
0041                     "jbd2_dev_to_name",
0042                     TEP_FUNC_ARG_INT,
0043                     TEP_FUNC_ARG_VOID);
0044 
0045     tep_register_print_function(tep,
0046                     process_jiffies_to_msecs,
0047                     TEP_FUNC_ARG_LONG,
0048                     "jiffies_to_msecs",
0049                     TEP_FUNC_ARG_LONG,
0050                     TEP_FUNC_ARG_VOID);
0051     return 0;
0052 }
0053 
0054 void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
0055 {
0056     tep_unregister_print_function(tep, process_jbd2_dev_to_name,
0057                       "jbd2_dev_to_name");
0058 
0059     tep_unregister_print_function(tep, process_jiffies_to_msecs,
0060                       "jiffies_to_msecs");
0061 }