From: Andrew Morton <akpm@linux-foundation.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Markus Metzger <markus.t.metzger@intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
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 10:18:04 -0800 [thread overview]
Message-ID: <20081216101804.eccda780.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081216173059.GD11683@elte.hu>
On Tue, 16 Dec 2008 18:30:59 +0100 Ingo Molnar <mingo@elte.hu> wrote:
>
> * 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:
Close. I suspect we could refactor mlock.c to avoid all the code
duplication we have there.
There's (almost) nothing BTS-specific in this code, and it would be
better if it lived in mm/mlock.c. Hopefully in a
usable-by-other-parts-of-mlock.c fashion.
> > +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)
This is off-by-one, I think. Should be
if (vm > rmlim)
> > + goto out;
> > +
> > + rlim = child->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
> > + vm = child->mm->locked_vm + pgsz;
> > + if (rlim < vm)
ditto
> > + 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
next prev parent reply other threads:[~2008-12-16 18:19 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
2008-12-16 18:18 ` Andrew Morton [this message]
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=20081216101804.eccda780.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--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=mingo@elte.hu \
--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.