RE: [rfc] x86, ptrace: memory accounting for branch tracing

From: Metzger, Markus T
Date: Thu Dec 18 2008 - 10:58:19 EST


>-----Original Message-----
>From: Andrew Morton [mailto:akpm@xxxxxxxxxxxxxxxxxxxx]
>Sent: Dienstag, 16. Dezember 2008 19:18
>To: Ingo Molnar
>Cc: Metzger, Markus T; Peter Zijlstra;

>> > 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.

Thanks,

I added alloc_locked_buffer() and free_locked_buffer() functions to mm/mlock.c.


>> > +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)
>

Those two should be equivalent, shouldn't they?


regards,
markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/