* [PATCH] kprobes: Sanitize struct kretprobe_instance allocations
@ 2009-10-30 13:53 Ananth N Mavinakayanahalli
2009-10-30 19:55 ` Masami Hiramatsu
2009-11-02 16:19 ` [tip:tracing/core] " tip-bot for Ananth N Mavinakayanahalli
0 siblings, 2 replies; 3+ messages in thread
From: Ananth N Mavinakayanahalli @ 2009-10-30 13:53 UTC (permalink / raw)
To: lkml; +Cc: Masami Hiramatsu, Andrew Morton, Jim Keniston, Ingo Molnar,
fweisbec
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
For as long as kretprobes have existed, we've allocated NR_CPUS
instances of kretprobe_instance structures. With the default value of
CONFIG_NR_CPUS increasing on certain architectures, we are potentially
wasting kernel memory.
See http://sourceware.org/bugzilla/show_bug.cgi?id=10839#c3 for more
details.
Use a saner num_possible_cpus() instead of NR_CPUS for allocation.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
---
kernel/kprobes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6.32-rc5/kernel/kprobes.c
===================================================================
--- linux-2.6.32-rc5.orig/kernel/kprobes.c
+++ linux-2.6.32-rc5/kernel/kprobes.c
@@ -1014,9 +1014,9 @@ int __kprobes register_kretprobe(struct
/* Pre-allocate memory for max kretprobe instances */
if (rp->maxactive <= 0) {
#ifdef CONFIG_PREEMPT
- rp->maxactive = max(10, 2 * NR_CPUS);
+ rp->maxactive = max(10, 2 * num_possible_cpus());
#else
- rp->maxactive = NR_CPUS;
+ rp->maxactive = num_possible_cpus();
#endif
}
spin_lock_init(&rp->lock);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] kprobes: Sanitize struct kretprobe_instance allocations
2009-10-30 13:53 [PATCH] kprobes: Sanitize struct kretprobe_instance allocations Ananth N Mavinakayanahalli
@ 2009-10-30 19:55 ` Masami Hiramatsu
2009-11-02 16:19 ` [tip:tracing/core] " tip-bot for Ananth N Mavinakayanahalli
1 sibling, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2009-10-30 19:55 UTC (permalink / raw)
To: ananth; +Cc: lkml, Andrew Morton, Jim Keniston, Ingo Molnar, fweisbec
Ananth N Mavinakayanahalli wrote:
> From: Ananth N Mavinakayanahalli<ananth@in.ibm.com>
>
> For as long as kretprobes have existed, we've allocated NR_CPUS
> instances of kretprobe_instance structures. With the default value of
> CONFIG_NR_CPUS increasing on certain architectures, we are potentially
> wasting kernel memory.
>
> See http://sourceware.org/bugzilla/show_bug.cgi?id=10839#c3 for more
> details.
>
> Use a saner num_possible_cpus() instead of NR_CPUS for allocation.
>
> Signed-off-by: Ananth N Mavinakayanahalli<ananth@in.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Thanks!
> ---
> kernel/kprobes.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Index: linux-2.6.32-rc5/kernel/kprobes.c
> ===================================================================
> --- linux-2.6.32-rc5.orig/kernel/kprobes.c
> +++ linux-2.6.32-rc5/kernel/kprobes.c
> @@ -1014,9 +1014,9 @@ int __kprobes register_kretprobe(struct
> /* Pre-allocate memory for max kretprobe instances */
> if (rp->maxactive<= 0) {
> #ifdef CONFIG_PREEMPT
> - rp->maxactive = max(10, 2 * NR_CPUS);
> + rp->maxactive = max(10, 2 * num_possible_cpus());
> #else
> - rp->maxactive = NR_CPUS;
> + rp->maxactive = num_possible_cpus();
> #endif
> }
> spin_lock_init(&rp->lock);
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:tracing/core] kprobes: Sanitize struct kretprobe_instance allocations
2009-10-30 13:53 [PATCH] kprobes: Sanitize struct kretprobe_instance allocations Ananth N Mavinakayanahalli
2009-10-30 19:55 ` Masami Hiramatsu
@ 2009-11-02 16:19 ` tip-bot for Ananth N Mavinakayanahalli
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Ananth N Mavinakayanahalli @ 2009-11-02 16:19 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, ananth, hpa, mingo, jkenisto, tglx, mhiramat, mingo
Commit-ID: 4dae560f97fa438f373b53e14b30149c9e44a600
Gitweb: http://git.kernel.org/tip/4dae560f97fa438f373b53e14b30149c9e44a600
Author: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
AuthorDate: Fri, 30 Oct 2009 19:23:10 +0530
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 2 Nov 2009 17:00:18 +0100
kprobes: Sanitize struct kretprobe_instance allocations
For as long as kretprobes have existed, we've allocated NR_CPUS
instances of kretprobe_instance structures. With the default
value of CONFIG_NR_CPUS increasing on certain architectures, we
are potentially wasting kernel memory.
See http://sourceware.org/bugzilla/show_bug.cgi?id=10839#c3 for
more details.
Use a saner num_possible_cpus() instead of NR_CPUS for
allocation.
Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: fweisbec@gmail.com
LKML-Reference: <20091030135310.GA22230@in.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/kprobes.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 5240d75..1494e85 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1014,9 +1014,9 @@ int __kprobes register_kretprobe(struct kretprobe *rp)
/* Pre-allocate memory for max kretprobe instances */
if (rp->maxactive <= 0) {
#ifdef CONFIG_PREEMPT
- rp->maxactive = max(10, 2 * NR_CPUS);
+ rp->maxactive = max(10, 2 * num_possible_cpus());
#else
- rp->maxactive = NR_CPUS;
+ rp->maxactive = num_possible_cpus();
#endif
}
spin_lock_init(&rp->lock);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-02 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-30 13:53 [PATCH] kprobes: Sanitize struct kretprobe_instance allocations Ananth N Mavinakayanahalli
2009-10-30 19:55 ` Masami Hiramatsu
2009-11-02 16:19 ` [tip:tracing/core] " tip-bot for Ananth N Mavinakayanahalli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox