• Paul Mackerras's avatar
    perf_counter: Provide functions for locking and pinning the context for a task · 25346b93
    Paul Mackerras authored
    This abstracts out the code for locking the context associated
    with a task.  Because the context might get transferred from
    one task to another concurrently, we have to check after
    locking the context that it is still the right context for the
    task and retry if not.  This was open-coded in
    find_get_context() and perf_counter_init_task().
    
    This adds a further function for pinning the context for a
    task, i.e. marking it so it can't be transferred to another
    task.  This adds a 'pin_count' field to struct
    perf_counter_context to indicate that a context is pinned,
    instead of the previous method of setting the parent_gen count
    to all 1s.  Pinning the context with a pin_count is easier to
    undo and doesn't require saving the parent_gen value.  This
    also adds a perf_unpin_context() to undo the effect of
    perf_pin_task_context() and changes perf_counter_init_task to
    use it.
    Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
    Cc: Marcelo Tosatti <mtosatti@redhat.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    LKML-Reference: <18979.34748.755674.596386@cargo.ozlabs.ibm.com>
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    25346b93
perf_counter.c 93.8 KB