lkml.org 
[lkml]   [2008]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [rfc] x86, ptrace: memory accounting for branch tracing

* 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


\
 
 \ /
  Last update: 2008-12-16 18:33    [W:0.061 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site