lkml.org 
[lkml]   [2010]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 03/10] perf: Ensure IOC_OUTPUT isnt used to create multi-writer buffers
    Since we want to ensure buffers only have a single writer, we must
    avoid creating one with multiple.

    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    ---
    kernel/perf_event.c | 19 +++++++++++++++++++
    1 file changed, 19 insertions(+)

    Index: linux-2.6/kernel/perf_event.c
    ===================================================================
    --- linux-2.6.orig/kernel/perf_event.c
    +++ linux-2.6/kernel/perf_event.c
    @@ -4885,6 +4885,13 @@ static int perf_event_set_output(struct
    int fput_needed = 0;
    int ret = -EINVAL;

    + /*
    + * Don't allow output of inherited per-task events. This would
    + * create performance issues due to cross cpu access.
    + */
    + if (event->cpu == -1 && event->attr.inherit)
    + return -EINVAL;
    +
    if (!output_fd)
    goto set;

    @@ -4905,6 +4912,18 @@ static int perf_event_set_output(struct
    if (event->data)
    goto out;

    + /*
    + * Don't allow cross-cpu buffers
    + */
    + if (output_event->cpu != event->cpu)
    + goto out;
    +
    + /*
    + * If its not a per-cpu buffer, it must be the same task.
    + */
    + if (output_event->cpu == -1 && output_event->ctx != event->ctx)
    + goto out;
    +
    atomic_long_inc(&output_file->f_count);

    set:



    \
     
     \ /
      Last update: 2010-05-21 11:13    [W:4.620 / U:0.204 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site