diff options
author | Ananth N Mavinakayanahalli <ananth@in.ibm.com> | 2009-10-30 09:53:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-02 11:00:18 -0500 |
commit | 4dae560f97fa438f373b53e14b30149c9e44a600 (patch) | |
tree | 4408896d10c483e0f855636f8b9e208bd856d6fc /kernel/kprobes.c | |
parent | 5e9b397292ca0b9409dced33e3a22ec993377064 (diff) |
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>
Diffstat (limited to 'kernel/kprobes.c')
-rw-r--r-- | kernel/kprobes.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 5240d75f4c6..1494e85b35f 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -1014,9 +1014,9 @@ int __kprobes register_kretprobe(struct kretprobe *rp) | |||
1014 | /* Pre-allocate memory for max kretprobe instances */ | 1014 | /* Pre-allocate memory for max kretprobe instances */ |
1015 | if (rp->maxactive <= 0) { | 1015 | if (rp->maxactive <= 0) { |
1016 | #ifdef CONFIG_PREEMPT | 1016 | #ifdef CONFIG_PREEMPT |
1017 | rp->maxactive = max(10, 2 * NR_CPUS); | 1017 | rp->maxactive = max(10, 2 * num_possible_cpus()); |
1018 | #else | 1018 | #else |
1019 | rp->maxactive = NR_CPUS; | 1019 | rp->maxactive = num_possible_cpus(); |
1020 | #endif | 1020 | #endif |
1021 | } | 1021 | } |
1022 | spin_lock_init(&rp->lock); | 1022 | spin_lock_init(&rp->lock); |