~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/traceevent/plugin_kmem.c

Version: ~ [ linux-4.15-rc8 ] ~ [ linux-4.14.13 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.76 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.111 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.48 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.91 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.53 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.98 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2009 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 static int call_site_handler(struct trace_seq *s, struct pevent_record *record,
 27                              struct event_format *event, void *context)
 28 {
 29         struct format_field *field;
 30         unsigned long long val, addr;
 31         void *data = record->data;
 32         const char *func;
 33 
 34         field = pevent_find_field(event, "call_site");
 35         if (!field)
 36                 return 1;
 37 
 38         if (pevent_read_number_field(field, data, &val))
 39                 return 1;
 40 
 41         func = pevent_find_function(event->pevent, val);
 42         if (!func)
 43                 return 1;
 44 
 45         addr = pevent_find_function_address(event->pevent, val);
 46 
 47         trace_seq_printf(s, "(%s+0x%x) ", func, (int)(val - addr));
 48         return 1;
 49 }
 50 
 51 int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 52 {
 53         pevent_register_event_handler(pevent, -1, "kmem", "kfree",
 54                                       call_site_handler, NULL);
 55 
 56         pevent_register_event_handler(pevent, -1, "kmem", "kmalloc",
 57                                       call_site_handler, NULL);
 58 
 59         pevent_register_event_handler(pevent, -1, "kmem", "kmalloc_node",
 60                                       call_site_handler, NULL);
 61 
 62         pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
 63                                       call_site_handler, NULL);
 64 
 65         pevent_register_event_handler(pevent, -1, "kmem",
 66                                       "kmem_cache_alloc_node",
 67                                       call_site_handler, NULL);
 68 
 69         pevent_register_event_handler(pevent, -1, "kmem", "kmem_cache_free",
 70                                       call_site_handler, NULL);
 71         return 0;
 72 }
 73 
 74 void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
 75 {
 76         pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
 77                                         call_site_handler, NULL);
 78 
 79         pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
 80                                         call_site_handler, NULL);
 81 
 82         pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
 83                                         call_site_handler, NULL);
 84 
 85         pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
 86                                         call_site_handler, NULL);
 87 
 88         pevent_unregister_event_handler(pevent, -1, "kmem",
 89                                         "kmem_cache_alloc_node",
 90                                         call_site_handler, NULL);
 91 
 92         pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
 93                                         call_site_handler, NULL);
 94 }
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp