linux/tools/lib/traceevent/plugins/plugin_jbd2.c
<<
>>
Prefs
   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#include "trace-seq.h"
  26
  27#define MINORBITS       20
  28#define MINORMASK       ((1U << MINORBITS) - 1)
  29
  30#define MAJOR(dev)      ((unsigned int) ((dev) >> MINORBITS))
  31#define MINOR(dev)      ((unsigned int) ((dev) & MINORMASK))
  32
  33static unsigned long long
  34process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args)
  35{
  36        unsigned int dev = args[0];
  37
  38        trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
  39        return 0;
  40}
  41
  42static unsigned long long
  43process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
  44{
  45        unsigned long long jiffies = args[0];
  46
  47        trace_seq_printf(s, "%lld", jiffies);
  48        return jiffies;
  49}
  50
  51int TEP_PLUGIN_LOADER(struct tep_handle *tep)
  52{
  53        tep_register_print_function(tep,
  54                                    process_jbd2_dev_to_name,
  55                                    TEP_FUNC_ARG_STRING,
  56                                    "jbd2_dev_to_name",
  57                                    TEP_FUNC_ARG_INT,
  58                                    TEP_FUNC_ARG_VOID);
  59
  60        tep_register_print_function(tep,
  61                                    process_jiffies_to_msecs,
  62                                    TEP_FUNC_ARG_LONG,
  63                                    "jiffies_to_msecs",
  64                                    TEP_FUNC_ARG_LONG,
  65                                    TEP_FUNC_ARG_VOID);
  66        return 0;
  67}
  68
  69void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  70{
  71        tep_unregister_print_function(tep, process_jbd2_dev_to_name,
  72                                      "jbd2_dev_to_name");
  73
  74        tep_unregister_print_function(tep, process_jiffies_to_msecs,
  75                                      "jiffies_to_msecs");
  76}
  77