Skip to contentSkip to conversation

tools lib traceevent: Plugin unload enhancement (v2)

PATCH In review Namhyung Kim 3 participants 26 messages Jan 16, 2014 – Jan 19, 2014

lore
Share & tools
lore
#0 lore raw

cover tools lib traceevent: Plugin unload enhancement (v2)

Hello,

When plugins are loaded, they register various event and function handlers. But they don't unregister even after the plugins unloaded so that events could have refererences to non-existing handlers.

This patchset added relevant unregister functions to handle that.

Note that this is not a problem as of now since all of users unload plugins after finishing their access to events. But being a generic library, it should be handled properly IMHO.

* changes in v2)
- add ack and review tags from Steve and Jiri
- improve message on handler unregister (Steve)
- cleanup coding style issue (Steve)

I put the series on the 'libtraceevent/plugin-v2' branch in my tree

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Any comments are welcome, thanks
Namhyung

Namhyung Kim (12):
tools lib traceevent: Add pevent_unregister_event_handler() tools lib traceevent: Add pevent_unregister_print_function() tools lib traceevent: Unregister handler when function plugin
unloaded
tools lib traceevent: Unregister handler when hrtimer plugin unloaded tools lib traceevent: Unregister handler when kmem plugin unloaded tools lib traceevent: Unregister handler when kvm plugin unloaded tools lib traceevent: Unregister handler when sched_switch plugin
unloaded
tools lib traceevent: Unregister handler when mac80211 plugin
unloaded
tools lib traceevent: Unregister handler when cfg80211 plugin
unloaded
tools lib traceevent: Unregister handler when jbd2 plugin unloaded tools lib traceevent: Unregister handler when scsi plugin unloaded tools lib traceevent: Unregister handler when xen plugin unloaded

 tools/lib/traceevent/event-parse.c         | 136 ++++++++++++++++++++++++++---
 tools/lib/traceevent/event-parse.h         |   5 ++
 tools/lib/traceevent/plugin_cfg80211.c     |   6 ++
 tools/lib/traceevent/plugin_function.c     |   3 +
 tools/lib/traceevent/plugin_hrtimer.c      |  10 +++
 tools/lib/traceevent/plugin_jbd2.c         |   9 ++
 tools/lib/traceevent/plugin_kmem.c         |  22 +++++
 tools/lib/traceevent/plugin_kvm.c          |  29 ++++++
 tools/lib/traceevent/plugin_mac80211.c     |   7 ++
 tools/lib/traceevent/plugin_sched_switch.c |  12 +++
 tools/lib/traceevent/plugin_scsi.c         |   6 ++
 tools/lib/traceevent/plugin_xen.c          |   6 ++
 12 files changed, 237 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/12 tools lib traceevent: Add pevent_unregister_event_handler()

When a plugin unloaded it needs to unregister its handler from pevent. So add unregister function to do it.

---
 tools/lib/traceevent/event-parse.c | 113 ++++++++++++++++++++++++++++++++-----
 tools/lib/traceevent/event-parse.h |   3 +
 2 files changed, 102 insertions(+), 14 deletions(-)
tools/lib/traceevent/event-parse.c +99 -14
index 2ce565a73dd5..d1973cb8388b 100644
@@ -5560,6 +5560,29 @@ int pevent_register_print_function(struct pevent *pevent,
 	return ret;
 }
 
+static struct event_format *pevent_search_event(struct pevent *pevent, int id,
+						const char *sys_name,
+						const char *event_name)
+{
+	struct event_format *event;
+
+	if (id >= 0) {
+		/* search by id */
+		event = pevent_find_event(pevent, id);
+		if (!event)
+			return NULL;
+		if (event_name && (strcmp(event_name, event->name) != 0))
+			return NULL;
+		if (sys_name && (strcmp(sys_name, event->system) != 0))
+			return NULL;
+	} else {
+		event = pevent_find_event_by_name(pevent, sys_name, event_name);
+		if (!event)
+			return NULL;
+	}
+	return event;
+}
+
 /**
  * pevent_register_event_handler - register a way to parse an event
  * @pevent: the handle to the pevent
@@ -5584,20 +5607,9 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
 	struct event_format *event;
 	struct event_handler *handle;
 
-	if (id >= 0) {
-		/* search by id */
-		event = pevent_find_event(pevent, id);
-		if (!event)
-			goto not_found;
-		if (event_name && (strcmp(event_name, event->name) != 0))
-			goto not_found;
-		if (sys_name && (strcmp(sys_name, event->system) != 0))
-			goto not_found;
-	} else {
-		event = pevent_find_event_by_name(pevent, sys_name, event_name);
-		if (!event)
-			goto not_found;
-	}
+	event = pevent_search_event(pevent, id, sys_name, event_name);
+	if (event == NULL)
+		goto not_found;
 
 	pr_stat("overriding event (%d) %s:%s with new print handler",
 		event->id, event->system, event->name);
@@ -5637,6 +5649,79 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
 	return -1;
 }
 
+static int handle_matches(struct event_handler *handler, int id,
+			  const char *sys_name, const char *event_name,
+			  pevent_event_handler_func func, void *context)
+{
+	if (id >= 0 && id != handler->id)
+		return 0;
+
+	if (event_name && (strcmp(event_name, handler->event_name) != 0))
+		return 0;
+
+	if (sys_name && (strcmp(sys_name, handler->sys_name) != 0))
+		return 0;
+
+	if (func != handler->func || context != handler->context)
+		return 0;
+
+	return 1;
+}
+
+/**
+ * pevent_unregister_event_handler - unregister an existing event handler
+ * @pevent: the handle to the pevent
+ * @id: the id of the event to unregister
+ * @sys_name: the system name the handler belongs to
+ * @event_name: the name of the event handler
+ * @func: the function to call to parse the event information
+ * @context: the data to be passed to @func
+ *
+ * This function removes existing event handler (parser).
+ *
+ * If @id is >= 0, then it is used to find the event.
+ * else @sys_name and @event_name are used.
+ *
+ * Returns 0 if handler was removed successfully, -1 if event was not found.
+ */
+int pevent_unregister_event_handler(struct pevent *pevent, int id,
+				    const char *sys_name, const char *event_name,
+				    pevent_event_handler_func func, void *context)
+{
+	struct event_format *event;
+	struct event_handler *handle;
+	struct event_handler **next;
+
+	event = pevent_search_event(pevent, id, sys_name, event_name);
+	if (event == NULL)
+		goto not_found;
+
+	if (event->handler == func && event->context == context) {
+		pr_stat("removing override handler for event (%d) %s:%s. Going back to default handler.",
+			event->id, event->system, event->name);
+
+		event->handler = NULL;
+		event->context = NULL;
+		return 0;
+	}
+
+not_found:
+	for (next = &pevent->handlers; *next; next = &(*next)->next) {
+		handle = *next;
+		if (handle_matches(handle, id, sys_name, event_name,
+				   func, context))
+			break;
+	}
+
+	if (!(*next))
+		return -1;
+
+	*next = handle->next;
+	free_handler(handle);
+
+	return 0;
+}
+
 /**
  * pevent_alloc - create a pevent handle
  */
tools/lib/traceevent/event-parse.h +3 -0
index a3beca56cb35..c48acfbc6230 100644
@@ -624,6 +624,9 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
 int pevent_register_event_handler(struct pevent *pevent, int id,
 				  const char *sys_name, const char *event_name,
 				  pevent_event_handler_func func, void *context);
+int pevent_unregister_event_handler(struct pevent *pevent, int id,
+				    const char *sys_name, const char *event_name,
+				    pevent_event_handler_func func, void *context);
 int pevent_register_print_function(struct pevent *pevent,
 				   pevent_func_handler func,
 				   enum pevent_func_arg_type ret_type,
Signature · 1 line
1.7.11.7
#2 lore raw

[tip:perf/core] tools lib traceevent: Add pevent_unregister_event_handler()

tools lib traceevent: Add pevent_unregister_event_handler()
Commit-ID:  ad13701d4905e820f32ce3c2590e19ca65765d63
Gitweb:     http://git.kernel.org/tip/ad13701d4905e820f32ce3c2590e19ca65765d63
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:07 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Add pevent_unregister_event_handler()

When a plugin is unloaded it needs to unregister its handler from pevent.

So add an unregister function to do it.

---
 tools/lib/traceevent/event-parse.c | 113 ++++++++++++++++++++++++++++++++-----
 tools/lib/traceevent/event-parse.h |   3 +
 2 files changed, 102 insertions(+), 14 deletions(-)
tools/lib/traceevent/event-parse.c +99 -14
index 2ce565a..d1973cb 100644
@@ -5560,6 +5560,29 @@ int pevent_register_print_function(struct pevent *pevent,
 	return ret;
 }
 
+static struct event_format *pevent_search_event(struct pevent *pevent, int id,
+						const char *sys_name,
+						const char *event_name)
+{
+	struct event_format *event;
+
+	if (id >= 0) {
+		/* search by id */
+		event = pevent_find_event(pevent, id);
+		if (!event)
+			return NULL;
+		if (event_name && (strcmp(event_name, event->name) != 0))
+			return NULL;
+		if (sys_name && (strcmp(sys_name, event->system) != 0))
+			return NULL;
+	} else {
+		event = pevent_find_event_by_name(pevent, sys_name, event_name);
+		if (!event)
+			return NULL;
+	}
+	return event;
+}
+
 /**
  * pevent_register_event_handler - register a way to parse an event
  * @pevent: the handle to the pevent
@@ -5584,20 +5607,9 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
 	struct event_format *event;
 	struct event_handler *handle;
 
-	if (id >= 0) {
-		/* search by id */
-		event = pevent_find_event(pevent, id);
-		if (!event)
-			goto not_found;
-		if (event_name && (strcmp(event_name, event->name) != 0))
-			goto not_found;
-		if (sys_name && (strcmp(sys_name, event->system) != 0))
-			goto not_found;
-	} else {
-		event = pevent_find_event_by_name(pevent, sys_name, event_name);
-		if (!event)
-			goto not_found;
-	}
+	event = pevent_search_event(pevent, id, sys_name, event_name);
+	if (event == NULL)
+		goto not_found;
 
 	pr_stat("overriding event (%d) %s:%s with new print handler",
 		event->id, event->system, event->name);
@@ -5637,6 +5649,79 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
 	return -1;
 }
 
+static int handle_matches(struct event_handler *handler, int id,
+			  const char *sys_name, const char *event_name,
+			  pevent_event_handler_func func, void *context)
+{
+	if (id >= 0 && id != handler->id)
+		return 0;
+
+	if (event_name && (strcmp(event_name, handler->event_name) != 0))
+		return 0;
+
+	if (sys_name && (strcmp(sys_name, handler->sys_name) != 0))
+		return 0;
+
+	if (func != handler->func || context != handler->context)
+		return 0;
+
+	return 1;
+}
+
+/**
+ * pevent_unregister_event_handler - unregister an existing event handler
+ * @pevent: the handle to the pevent
+ * @id: the id of the event to unregister
+ * @sys_name: the system name the handler belongs to
+ * @event_name: the name of the event handler
+ * @func: the function to call to parse the event information
+ * @context: the data to be passed to @func
+ *
+ * This function removes existing event handler (parser).
+ *
+ * If @id is >= 0, then it is used to find the event.
+ * else @sys_name and @event_name are used.
+ *
+ * Returns 0 if handler was removed successfully, -1 if event was not found.
+ */
+int pevent_unregister_event_handler(struct pevent *pevent, int id,
+				    const char *sys_name, const char *event_name,
+				    pevent_event_handler_func func, void *context)
+{
+	struct event_format *event;
+	struct event_handler *handle;
+	struct event_handler **next;
+
+	event = pevent_search_event(pevent, id, sys_name, event_name);
+	if (event == NULL)
+		goto not_found;
+
+	if (event->handler == func && event->context == context) {
+		pr_stat("removing override handler for event (%d) %s:%s. Going back to default handler.",
+			event->id, event->system, event->name);
+
+		event->handler = NULL;
+		event->context = NULL;
+		return 0;
+	}
+
+not_found:
+	for (next = &pevent->handlers; *next; next = &(*next)->next) {
+		handle = *next;
+		if (handle_matches(handle, id, sys_name, event_name,
+				   func, context))
+			break;
+	}
+
+	if (!(*next))
+		return -1;
+
+	*next = handle->next;
+	free_handler(handle);
+
+	return 0;
+}
+
 /**
  * pevent_alloc - create a pevent handle
  */
tools/lib/traceevent/event-parse.h +3 -0
index a3beca5..c48acfb 100644
@@ -624,6 +624,9 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
 int pevent_register_event_handler(struct pevent *pevent, int id,
 				  const char *sys_name, const char *event_name,
 				  pevent_event_handler_func func, void *context);
+int pevent_unregister_event_handler(struct pevent *pevent, int id,
+				    const char *sys_name, const char *event_name,
+				    pevent_event_handler_func func, void *context);
 int pevent_register_print_function(struct pevent *pevent,
 				   pevent_func_handler func,
 				   enum pevent_func_arg_type ret_type,
#3 lore raw

PATCH 2/12 tools lib traceevent: Add pevent_unregister_print_function()

In reply to Namhyung Kim

When a plugin unloaded it needs to unregister its print handler from pevent. So add unregister function to do it.

---
 tools/lib/traceevent/event-parse.c | 23 +++++++++++++++++++++++
 tools/lib/traceevent/event-parse.h |  2 ++
 2 files changed, 25 insertions(+)
tools/lib/traceevent/event-parse.c +23 -0
index d1973cb8388b..1587ea392ad6 100644
@@ -5560,6 +5560,29 @@ int pevent_register_print_function(struct pevent *pevent,
 	return ret;
 }
 
+/**
+ * pevent_unregister_print_function - unregister a helper function
+ * @pevent: the handle to the pevent
+ * @func: the function to process the helper function
+ * @name: the name of the helper function
+ *
+ * This function removes existing print handler for function @name.
+ *
+ * Returns 0 if the handler was removed successully, -1 otherwise.
+ */
+int pevent_unregister_print_function(struct pevent *pevent,
+				     pevent_func_handler func, char *name)
+{
+	struct pevent_function_handler *func_handle;
+
+	func_handle = find_func_handler(pevent, name);
+	if (func_handle && func_handle->func == func) {
+		remove_func_handler(pevent, name);
+		return 0;
+	}
+	return -1;
+}
+
 static struct event_format *pevent_search_event(struct pevent *pevent, int id,
 						const char *sys_name,
 						const char *event_name)
tools/lib/traceevent/event-parse.h +2 -0
index c48acfbc6230..791c539374c7 100644
@@ -631,6 +631,8 @@ int pevent_register_print_function(struct pevent *pevent,
 				   pevent_func_handler func,
 				   enum pevent_func_arg_type ret_type,
 				   char *name, ...);
+int pevent_unregister_print_function(struct pevent *pevent,
+				     pevent_func_handler func, char *name);
 
 struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
 struct format_field *pevent_find_field(struct event_format *event, const char *name);
Signature · 1 line
1.7.11.7
#4 lore raw

[tip:perf/core] tools lib traceevent: Add pevent_unregister_print_function()

tools lib traceevent: Add pevent_unregister_print_function()
Commit-ID:  20c7e5abbd0cdfaa656f46af052a6e6a8ce94775
Gitweb:     http://git.kernel.org/tip/20c7e5abbd0cdfaa656f46af052a6e6a8ce94775
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:08 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Add pevent_unregister_print_function()

When a plugin unloaded it needs to unregister its print handler from pevent.

So add an unregister function to do it.

---
 tools/lib/traceevent/event-parse.c | 23 +++++++++++++++++++++++
 tools/lib/traceevent/event-parse.h |  2 ++
 2 files changed, 25 insertions(+)
tools/lib/traceevent/event-parse.c +23 -0
index d1973cb..1587ea39 100644
@@ -5560,6 +5560,29 @@ int pevent_register_print_function(struct pevent *pevent,
 	return ret;
 }
 
+/**
+ * pevent_unregister_print_function - unregister a helper function
+ * @pevent: the handle to the pevent
+ * @func: the function to process the helper function
+ * @name: the name of the helper function
+ *
+ * This function removes existing print handler for function @name.
+ *
+ * Returns 0 if the handler was removed successully, -1 otherwise.
+ */
+int pevent_unregister_print_function(struct pevent *pevent,
+				     pevent_func_handler func, char *name)
+{
+	struct pevent_function_handler *func_handle;
+
+	func_handle = find_func_handler(pevent, name);
+	if (func_handle && func_handle->func == func) {
+		remove_func_handler(pevent, name);
+		return 0;
+	}
+	return -1;
+}
+
 static struct event_format *pevent_search_event(struct pevent *pevent, int id,
 						const char *sys_name,
 						const char *event_name)
tools/lib/traceevent/event-parse.h +2 -0
index c48acfb..791c539 100644
@@ -631,6 +631,8 @@ int pevent_register_print_function(struct pevent *pevent,
 				   pevent_func_handler func,
 				   enum pevent_func_arg_type ret_type,
 				   char *name, ...);
+int pevent_unregister_print_function(struct pevent *pevent,
+				     pevent_func_handler func, char *name);
 
 struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
 struct format_field *pevent_find_field(struct event_format *event, const char *name);
#5 lore raw

PATCH 3/12 tools lib traceevent: Unregister handler when function plugin unloaded

In reply to Namhyung Kim

The function handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_function.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/traceevent/plugin_function.c +3 -0
index 39461485f9a7..80ba4ff1fe84 100644
@@ -148,6 +148,9 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
 {
 	int i, x;
 
+	pevent_unregister_event_handler(pevent, -1, "ftrace", "function",
+					function_handler, NULL);
+
 	for (i = 0; i <= cpus; i++) {
 		for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
 			free(fstack[i].stack[x]);
Signature · 1 line
1.7.11.7
#6 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when function plugin is unloaded

tools lib traceevent: Unregister handler when function plugin is unloaded
Commit-ID:  ac668c7b7d87c1895faf196a337b5ddfd32a0e21
Gitweb:     http://git.kernel.org/tip/ac668c7b7d87c1895faf196a337b5ddfd32a0e21
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:09 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Unregister handler when function plugin is unloaded

The function handler should be unregistered when the plugin is unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_function.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/traceevent/plugin_function.c +3 -0
index 3946148..80ba4ff 100644
@@ -148,6 +148,9 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
 {
 	int i, x;
 
+	pevent_unregister_event_handler(pevent, -1, "ftrace", "function",
+					function_handler, NULL);
+
 	for (i = 0; i <= cpus; i++) {
 		for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
 			free(fstack[i].stack[x]);
#7 lore raw

PATCH 4/12 tools lib traceevent: Unregister handler when hrtimer plugin unloaded

In reply to Namhyung Kim

The timer handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_hrtimer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/lib/traceevent/plugin_hrtimer.c +10 -0
index 0b0ebf30aa44..12bf14cc1152 100644
@@ -76,3 +76,13 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      timer_start_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1,
+					"timer", "hrtimer_expire_entry",
+					timer_expire_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
+					timer_start_handler, NULL);
+}
Signature · 1 line
1.7.11.7
#8 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when hrtimer plugin is unloaded

tools lib traceevent: Unregister handler when hrtimer plugin is unloaded
Commit-ID:  4061edaa54744dca833051119e763f073dd3c334
Gitweb:     http://git.kernel.org/tip/4061edaa54744dca833051119e763f073dd3c334
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:10 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Unregister handler when hrtimer plugin is unloaded

The timer handlers should be unregistered when the plugin is unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_hrtimer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
tools/lib/traceevent/plugin_hrtimer.c +10 -0
index 0b0ebf3..12bf14c 100644
@@ -76,3 +76,13 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      timer_start_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1,
+					"timer", "hrtimer_expire_entry",
+					timer_expire_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
+					timer_start_handler, NULL);
+}
#9 lore raw

PATCH 5/12 tools lib traceevent: Unregister handler when kmem plugin unloaded

In reply to Namhyung Kim

The kmem handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_kmem.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
tools/lib/traceevent/plugin_kmem.c +22 -0
index 7115c8037ea8..70650ff48d78 100644
@@ -70,3 +70,25 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      call_site_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem",
+					"kmem_cache_alloc_node",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
+					call_site_handler, NULL);
+}
Signature · 1 line
1.7.11.7
#10 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when kmem plugin is unloaded

tools lib traceevent: Unregister handler when kmem plugin is unloaded
Commit-ID:  11e99c55414ebade1031a0ed3b49915824c7c3ea
Gitweb:     http://git.kernel.org/tip/11e99c55414ebade1031a0ed3b49915824c7c3ea
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:11 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Unregister handler when kmem plugin is unloaded

The kmem handlers should be unregistered when the plugin is unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_kmem.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
tools/lib/traceevent/plugin_kmem.c +22 -0
index 7115c80..70650ff 100644
@@ -70,3 +70,25 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      call_site_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem",
+					"kmem_cache_alloc_node",
+					call_site_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
+					call_site_handler, NULL);
+}
#11 lore raw

PATCH 6/12 tools lib traceevent: Unregister handler when kvm plugin unloaded

In reply to Namhyung Kim

The kvm handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_kvm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
tools/lib/traceevent/plugin_kvm.c +29 -0
index a0e282c6b967..9e0e8c61b43b 100644
@@ -434,3 +434,32 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
+					kvm_exit_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
+					kvm_emulate_insn_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
+					kvm_mmu_get_page_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1,
+					"kvmmmu", "kvm_mmu_unsync_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu",
+			"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
+			NULL);
+
+	pevent_unregister_print_function(pevent, process_is_writable_pte,
+					 "is_writable_pte");
+}
Signature · 1 line
1.7.11.7
#12 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when kvm plugin is unloaded

tools lib traceevent: Unregister handler when kvm plugin is unloaded
Commit-ID:  354a2bd0318e0758f93b8b24553f3376fa9dfa21
Gitweb:     http://git.kernel.org/tip/354a2bd0318e0758f93b8b24553f3376fa9dfa21
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:12 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:24 -0300

tools lib traceevent: Unregister handler when kvm plugin is unloaded

The kvm handlers should be unregistered when the plugin is unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_kvm.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
tools/lib/traceevent/plugin_kvm.c +29 -0
index a0e282c..9e0e8c6 100644
@@ -434,3 +434,32 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
+					kvm_exit_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
+					kvm_emulate_insn_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
+					kvm_mmu_get_page_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1,
+					"kvmmmu", "kvm_mmu_unsync_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
+					kvm_mmu_print_role, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "kvmmmu",
+			"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
+			NULL);
+
+	pevent_unregister_print_function(pevent, process_is_writable_pte,
+					 "is_writable_pte");
+}
#13 lore raw

PATCH 7/12 tools lib traceevent: Unregister handler when sched_switch plugin unloaded

In reply to Namhyung Kim

The event handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_sched_switch.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/lib/traceevent/plugin_sched_switch.c +12 -0
index fea3724aa24f..f1ce60065258 100644
@@ -146,3 +146,15 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      sched_wakeup_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch",
+					sched_switch_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
+					sched_wakeup_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
+					sched_wakeup_handler, NULL);
+}
Signature · 1 line
1.7.11.7
#14 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when sched_switch plugin is unloaded

tools lib traceevent: Unregister handler when sched_switch plugin is unloaded
Commit-ID:  02bafd377c1137d0705f224881cd21de123204f0
Gitweb:     http://git.kernel.org/tip/02bafd377c1137d0705f224881cd21de123204f0
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:13 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when sched_switch plugin is unloaded

The event handlers should be unregistered when the plugin is unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_sched_switch.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/lib/traceevent/plugin_sched_switch.c +12 -0
index fea3724..f1ce600 100644
@@ -146,3 +146,15 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      sched_wakeup_handler, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch",
+					sched_switch_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
+					sched_wakeup_handler, NULL);
+
+	pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
+					sched_wakeup_handler, NULL);
+}
#15 lore raw

PATCH 8/12 tools lib traceevent: Unregister handler when mac80211 plugin unloaded

In reply to Namhyung Kim

The event handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_mac80211.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/lib/traceevent/plugin_mac80211.c +7 -0
index 558a3b91c046..7e15a0f1c2fd 100644
@@ -93,3 +93,10 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      drv_bss_info_changed, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "mac80211",
+					"drv_bss_info_changed",
+					drv_bss_info_changed, NULL);
+}
Signature · 1 line
1.7.11.7
#16 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when mac80211 plugin is unloaded

tools lib traceevent: Unregister handler when mac80211 plugin is unloaded
Commit-ID:  ec7c6debdd446ad2262f236d13964efae90ba0f7
Gitweb:     http://git.kernel.org/tip/ec7c6debdd446ad2262f236d13964efae90ba0f7
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:14 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when mac80211 plugin is unloaded

The event handler should be unregistered when the plugin is unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_mac80211.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/lib/traceevent/plugin_mac80211.c +7 -0
index 558a3b9..7e15a0f 100644
@@ -93,3 +93,10 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				      drv_bss_info_changed, NULL);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_event_handler(pevent, -1, "mac80211",
+					"drv_bss_info_changed",
+					drv_bss_info_changed, NULL);
+}
#17 lore raw

PATCH 9/12 tools lib traceevent: Unregister handler when cfg80211 plugin unloaded

In reply to Namhyung Kim

The function handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_cfg80211.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_cfg80211.c +6 -0
index 57e98221db20..c066b25905f8 100644
@@ -22,3 +22,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process___le16_to_cpup,
+					 "__le16_to_cpup");
+}
Signature · 1 line
1.7.11.7
#18 lore raw

Re: [PATCH 09/12] tools lib traceevent: Unregister handler when cfg80211 plugin unloaded

Quoted 5 lines · On Thu, 16 Jan 2014 11:31:15 +0900 Namhyung Kim <[email protected]> wrote:

The function handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

You can add my Acked-by to patches 9-12 too.

-- Steve

Quoted 18 lines
---
 tools/lib/traceevent/plugin_cfg80211.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_cfg80211.c +6 -0
index 57e98221db20..c066b25905f8 100644
@@ -22,3 +22,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process___le16_to_cpup,
+					 "__le16_to_cpup");
+}
#19 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when cfg80211 plugin is unloaded

In reply to Namhyung Kim
tools lib traceevent: Unregister handler when cfg80211 plugin is unloaded
Commit-ID:  6024cf3898d25088b01025d72a6929839de9c7b6
Gitweb:     http://git.kernel.org/tip/6024cf3898d25088b01025d72a6929839de9c7b6
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:15 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when cfg80211 plugin is unloaded

The function handler should be unregistered when the plugin is unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_cfg80211.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_cfg80211.c +6 -0
index 57e9822..c066b25 100644
@@ -22,3 +22,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process___le16_to_cpup,
+					 "__le16_to_cpup");
+}
#20 lore raw

PATCH 10/12 tools lib traceevent: Unregister handler when jbd2 plugin unloaded

In reply to Namhyung Kim

The function handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_jbd2.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/lib/traceevent/plugin_jbd2.c +9 -0
index 2f93f81f0bac..0db714c721be 100644
@@ -66,3 +66,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
+					 "jbd2_dev_to_name");
+
+	pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
+					 "jiffies_to_msecs");
+}
Signature · 1 line
1.7.11.7
#21 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when jbd2 plugin is is unloaded

tools lib traceevent: Unregister handler when jbd2 plugin is is unloaded
Commit-ID:  0247a967d4c1986821b3c7cbad324468fa6f2ae3
Gitweb:     http://git.kernel.org/tip/0247a967d4c1986821b3c7cbad324468fa6f2ae3
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:16 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when jbd2 plugin is is unloaded

The function handlers should be unregistered when the plugin unloaded otherwise they'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_jbd2.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/lib/traceevent/plugin_jbd2.c +9 -0
index 2f93f81..0db714c 100644
@@ -66,3 +66,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
+					 "jbd2_dev_to_name");
+
+	pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
+					 "jiffies_to_msecs");
+}
#22 lore raw

PATCH 11/12 tools lib traceevent: Unregister handler when scsi plugin unloaded

In reply to Namhyung Kim

The function handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_scsi.c +6 -0
index 7ef16cc96562..eda326fc8620 100644
@@ -421,3 +421,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
+					 "scsi_trace_parse_cdb");
+}
Signature · 1 line
1.7.11.7
#23 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when scsi plugin is unloaded

tools lib traceevent: Unregister handler when scsi plugin is unloaded
Commit-ID:  a157112cfc67b3889f6493933cbd32620aa4be18
Gitweb:     http://git.kernel.org/tip/a157112cfc67b3889f6493933cbd32620aa4be18
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:17 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when scsi plugin is unloaded

The function handler should be unregistered when the plugin is unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_scsi.c +6 -0
index 7ef16cc..eda326f 100644
@@ -421,3 +421,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
+					 "scsi_trace_parse_cdb");
+}
#24 lore raw

PATCH 12/12 tools lib traceevent: Unregister handler when xen plugin unloaded

In reply to Namhyung Kim

The function handler should be unregistered when the plugin unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_xen.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_xen.c +6 -0
index e7794298f3a9..3a413eaada68 100644
@@ -128,3 +128,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_xen_hypercall_name,
+					 "xen_hypercall_name");
+}
Signature · 1 line
1.7.11.7
#25 lore raw

[tip:perf/core] tools lib traceevent: Unregister handler when xen plugin is unloaded

tools lib traceevent: Unregister handler when xen plugin is unloaded
Commit-ID:  bf6b3a95ff439b1dcd6151b3f38810f3cec1e319
Gitweb:     http://git.kernel.org/tip/bf6b3a95ff439b1dcd6151b3f38810f3cec1e319
Author:     Namhyung Kim <[email protected]>
AuthorDate: Thu, 16 Jan 2014 11:31:18 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 16 Jan 2014 16:26:25 -0300

tools lib traceevent: Unregister handler when xen plugin is unloaded

The function handler should be unregistered when the plugin is unloaded otherwise it'll try to access invalid memory.

---
 tools/lib/traceevent/plugin_xen.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/lib/traceevent/plugin_xen.c +6 -0
index e779429..3a413ea 100644
@@ -128,3 +128,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
 				       PEVENT_FUNC_ARG_VOID);
 	return 0;
 }
+
+void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
+{
+	pevent_unregister_print_function(pevent, process_xen_hypercall_name,
+					 "xen_hypercall_name");
+}