Skip to contentSkip to conversation

tracepoint: Do not waste memory on mods with no tracepoints

RFC PATCH In review Steven Rostedt 3 participants 4 messages Feb 26, 2014 – Feb 27, 2014 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

RFC PATCH 1/1 tracepoint: Do not waste memory on mods with no tracepoints

No reason to allocate tp_module structures for modules that have no tracepoints. This just wastes memory.

Fixes b75ef8b44b1c "Tracepoint: Dissociate from module mutex"
Cc Mathieu Desnoyers <[email protected]>
---
 kernel/tracepoint.c | 6 ++++++
 1 file changed, 6 insertions(+)
kernel/tracepoint.c +6 -0
index 29f2654..0d4ef26 100644
@@ -636,6 +636,9 @@ static int tracepoint_module_coming(struct module *mod)
 	struct tp_module *tp_mod, *iter;
 	int ret = 0;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	/*
 	 * We skip modules that taint the kernel, especially those with different
 	 * module headers (for forced load), to make sure we don't cause a crash.
@@ -679,6 +682,9 @@ static int tracepoint_module_going(struct module *mod)
 {
 	struct tp_module *pos;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	mutex_lock(&tracepoints_mutex);
 	tracepoint_update_probe_range(mod->tracepoints_ptrs,
 		mod->tracepoints_ptrs + mod->num_tracepoints);
Signature · 1 line
1.8.1.4
reviewer Acked-by on v1 1/1
#1 lore raw

----- Original Message -----

Quoted 11 lines

From: "Steven Rostedt" <[email protected]>
To: "LKML" <[email protected]>
Cc: "Ingo Molnar" <[email protected]>, "Rusty Russell" <[email protected]>, "Peter Zijlstra" <[email protected]>, "Mathieu Desnoyers" <[email protected]>, "Andrew Morton" <[email protected]>
Sent: Wednesday, February 26, 2014 11:03:13 AM
Subject: [RFC][PATCH] tracepoint: Do not waste memory on mods with no tracepoints

No reason to allocate tp_module structures for modules that have no tracepoints. This just wastes memory.

Good catch! Thanks!

Quoted 37 lines
Fixes b75ef8b44b1c "Tracepoint: Dissociate from module mutex"
Cc Mathieu Desnoyers <[email protected]>
---
 kernel/tracepoint.c | 6 ++++++
 1 file changed, 6 insertions(+)
kernel/tracepoint.c +6 -1
index 29f2654..0d4ef26 100644
@@ -636,6 +636,9 @@ static int tracepoint_module_coming(struct module *mod)
 	struct tp_module *tp_mod, *iter;
 	int ret = 0;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	/*
 	 * We skip modules that taint the kernel, especially those with different
 	 * module headers (for forced load), to make sure we don't cause a crash.
@@ -679,6 +682,9 @@ static int tracepoint_module_going(struct module *mod)
 {
 	struct tp_module *pos;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	mutex_lock(&tracepoints_mutex);
 	tracepoint_update_probe_range(mod->tracepoints_ptrs,
 		mod->tracepoints_ptrs + mod->num_tracepoints);
--

1.8.1.4

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#2 lore raw
In reply to Steven Rostedt
Quoted 5 lines · Steven Rostedt

No reason to allocate tp_module structures for modules that have no tracepoints. This just wastes memory.

Fixes b75ef8b44b1c "Tracepoint: Dissociate from module mutex"

Really? CC:stable? To save an insignificant amount of memory?

The definition of stable seems to be shifting away from "fixes for problems with significant effects". I obviously missed the memo.

Rusty.

Quoted 32 lines
Cc Mathieu Desnoyers <[email protected]>
---
 kernel/tracepoint.c | 6 ++++++
 1 file changed, 6 insertions(+)
kernel/tracepoint.c +6 -0
index 29f2654..0d4ef26 100644
@@ -636,6 +636,9 @@ static int tracepoint_module_coming(struct module *mod)
 	struct tp_module *tp_mod, *iter;
 	int ret = 0;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	/*
 	 * We skip modules that taint the kernel, especially those with different
 	 * module headers (for forced load), to make sure we don't cause a crash.
@@ -679,6 +682,9 @@ static int tracepoint_module_going(struct module *mod)
 {
 	struct tp_module *pos;
 
+	if (!mod->num_tracepoints)
+		return 0;
+
 	mutex_lock(&tracepoints_mutex);
 	tracepoint_update_probe_range(mod->tracepoints_ptrs,
 		mod->tracepoints_ptrs + mod->num_tracepoints);
Signature · 1 line
1.8.1.4
author maintainer
#3 lore raw
Quoted 8 lines · On Thu, 27 Feb 2014 11:00:35 +1030 Rusty Russell <[email protected]> wrote:
Quoted 5 lines · Steven Rostedt

No reason to allocate tp_module structures for modules that have no tracepoints. This just wastes memory.

Fixes b75ef8b44b1c "Tracepoint: Dissociate from module mutex"

Really? CC:stable? To save an insignificant amount of memory?

I agree that this rational alone is not sufficient for stable. But this is required for another patch that warns when tracepoints are not loaded by a module due to taints. We don't want to warn on all modules.

Quoted 3 lines

The definition of stable seems to be shifting away from "fixes for problems with significant effects". I obviously missed the memo.

Not telling users that tracepoints were not activated, but acting in every other way like they are is to me a "significant effect". This just happened to be something that fixing this depended on.

-- Steve