[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091030135310.GA22230@in.ibm.com>
Date: Fri, 30 Oct 2009 19:23:10 +0530
From: Ananth N Mavinakayanahalli <ananth@...ibm.com>
To: lkml <linux-kernel@...r.kernel.org>
Cc: Masami Hiramatsu <mhiramat@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Jim Keniston <jkenisto@...ibm.com>,
Ingo Molnar <mingo@...e.hu>, fweisbec@...il.com
Subject: [PATCH] kprobes: Sanitize struct kretprobe_instance allocations
From: Ananth N Mavinakayanahalli <ananth@...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@...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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists