All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Markus Metzger <markus.t.metzger@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com,
	markus.t.metzger@gmail.com, roland@redhat.com,
	eranian@googlemail.com
Subject: Re: [rfc] x86, ptrace: memory accounting for branch tracing
Date: Tue, 16 Dec 2008 18:30:59 +0100	[thread overview]
Message-ID: <20081216173059.GD11683@elte.hu> (raw)
In-Reply-To: <20081216162424.A30209@sedona.ch.intel.com>


* Markus Metzger <markus.t.metzger@intel.com> wrote:

> Account memory allocated for the BTS buffer to the traced task's 
> total_vm and locked_vm.

Andrew, is this the right (and preferred) way to attach BTS buffer 
allocation overhead to the RLIMIT_MEMLOCK bucket:

> +static int ptrace_bts_allocate_buffer(struct task_struct *child, size_t size)
> +{
> +	unsigned long rlim, vm, pgsz;
> +	int error = -ENOMEM;
> +
> +	pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT;
> +
> +	down_write(&child->mm->mmap_sem);
> +
> +	rlim = child->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
> +	vm   = child->mm->total_vm + pgsz;
> +	if (rlim < vm)
> +		goto out;
> +
> +	rlim = child->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
> +	vm   = child->mm->locked_vm + pgsz;
> +	if (rlim < vm)
> +		goto out;
> +
> +	child->bts_buffer = kzalloc(size, GFP_KERNEL);
> +	if (!child->bts_buffer)
> +		goto out;
> +
> +	child->bts_size = size;
> +
> +	child->mm->total_vm  += pgsz;
> +	child->mm->locked_vm += pgsz;
> +
> +	error = 0;
> + out:
> +	up_write(&child->mm->mmap_sem);
> +	return error;

?

	Ingo

  reply	other threads:[~2008-12-16 17:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 15:24 [rfc] x86, ptrace: memory accounting for branch tracing Markus Metzger
2008-12-16 17:30 ` Ingo Molnar [this message]
2008-12-16 18:18   ` Andrew Morton
2008-12-18 15:57     ` Metzger, Markus T

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=20081216173059.GD11683@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=eranian@googlemail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.t.metzger@gmail.com \
    --cc=markus.t.metzger@intel.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.