lkml.org 
[lkml]   [2015]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 4/7] perf: Free aux pages in unmap path
    On Fri, Dec 04, 2015 at 06:02:06PM +0100, Peter Zijlstra wrote:
    > The only solution I've come up with is:
    >
    > struct rb_aux *aux = rb->aux;
    >
    > if (aux && vma->vm_pgoff == aux->pgoff) {
    > ctx = perf_event_ctx_lock(event);

    Can't do this at all, see the comment in put_event(). perf_read_group()
    accesses user memory (and hence causes faults, which in turn take
    mmap_sem) while holding ctx::mutex.

    So neither this, not what you proposed can work.

    Will need moar thinking.

    > if (!atomic_dec_and_mutex_lock(&aux->mmap_count, &event->mmap_mutex) {
    > /* we now hold both ctx::mutex and event::mmap_mutex */
    > rb->aux = NULL;
    > ring_buffer_put(rb); /* aux had a reference */
    > _perf_event_stop(event);
    > ring_buffer_put_aux(aux); /* should be last */
    > mutex_unlock(&event->mmap_mutex);
    > }
    > mutex_unlock(&ctx->mutex);
    > }
    >
    >


    \
     
     \ /
      Last update: 2015-12-04 23:41    [W:3.672 / U:0.368 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site