public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: ananth@in.ibm.com
Cc: lkml <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jim Keniston <jkenisto@us.ibm.com>, Ingo Molnar <mingo@elte.hu>,
	fweisbec@gmail.com
Subject: Re: [PATCH] kprobes: Sanitize struct kretprobe_instance allocations
Date: Fri, 30 Oct 2009 15:55:28 -0400	[thread overview]
Message-ID: <4AEB44B0.7020005@redhat.com> (raw)
In-Reply-To: <20091030135310.GA22230@in.ibm.com>

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


  reply	other threads:[~2009-10-30 19:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-30 13:53 [PATCH] kprobes: Sanitize struct kretprobe_instance allocations Ananth N Mavinakayanahalli
2009-10-30 19:55 ` Masami Hiramatsu [this message]
2009-11-02 16:19 ` [tip:tracing/core] " tip-bot for Ananth N Mavinakayanahalli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AEB44B0.7020005@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=jkenisto@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox