2014-02-26 16:03:16

by Steven Rostedt

[permalink] [raw]
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.

Fixes: b75ef8b44b1c "Tracepoint: Dissociate from module mutex"
Cc: [email protected] # 3.2+
Cc: Mathieu Desnoyers <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/tracepoint.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 29f2654..0d4ef26 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -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


2014-02-26 17:20:37

by Mathieu Desnoyers

[permalink] [raw]
Subject: Re: [RFC][PATCH] tracepoint: Do not waste memory on mods with no tracepoints

----- Original Message -----
> 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!

Acked-by: Mathieu Desnoyers <[email protected]>

>
> Fixes: b75ef8b44b1c "Tracepoint: Dissociate from module mutex"
> Cc: [email protected] # 3.2+
> Cc: Mathieu Desnoyers <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> kernel/tracepoint.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 29f2654..0d4ef26 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -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
>
>

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

2014-02-27 00:39:19

by Rusty Russell

[permalink] [raw]
Subject: Re: [RFC][PATCH] tracepoint: Do not waste memory on mods with no tracepoints

Steven Rostedt <[email protected]> writes:
> 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: [email protected] # 3.2+

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.



> Cc: Mathieu Desnoyers <[email protected]>
> Signed-off-by: Steven Rostedt <[email protected]>
> ---
> kernel/tracepoint.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
> index 29f2654..0d4ef26 100644
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -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

2014-02-27 01:42:53

by Steven Rostedt

[permalink] [raw]
Subject: Re: [RFC][PATCH] tracepoint: Do not waste memory on mods with no tracepoints

On Thu, 27 Feb 2014 11:00:35 +1030
Rusty Russell <[email protected]> wrote:

> Steven Rostedt <[email protected]> writes:
> > 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: [email protected] # 3.2+
>
> 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.


>
> 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