lkml.org 
[lkml]   [2011]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/7] perf record: No need to check for overwrites
    Date
    From: Arnaldo Carvalho de Melo <acme@redhat.com>

    As we open the mmap with (PROT_READ | PROT_WRITE), signalling the kernel
    with perf_mmap__write_tail() when consuming data, so the kernel will not
    overwrite.

    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Tom Zanussi <tzanussi@gmail.com>
    LKML-Reference: <new-submission>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    ---
    tools/perf/builtin-record.c | 24 ++++--------------------
    1 files changed, 4 insertions(+), 20 deletions(-)

    diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
    index d788630..caf9279 100644
    --- a/tools/perf/builtin-record.c
    +++ b/tools/perf/builtin-record.c
    @@ -115,27 +115,11 @@ static void mmap_read(struct perf_mmap *md)
    unsigned char *data = md->base + page_size;
    unsigned long size;
    void *buf;
    - int diff;

    - /*
    - * If we're further behind than half the buffer, there's a chance
    - * the writer will bite our tail and mess up the samples under us.
    - *
    - * If we somehow ended up ahead of the head, we got messed up.
    - *
    - * In either case, truncate and restart at head.
    - */
    - diff = head - old;
    - if (diff < 0) {
    - fprintf(stderr, "WARNING: failed to keep up with mmap data\n");
    - /*
    - * head points to a known good entry, start there.
    - */
    - old = head;
    - }
    + if (old == head)
    + return;

    - if (old != head)
    - samples++;
    + samples++;

    size = head - old;

    --
    1.6.2.5


    \
     
     \ /
      Last update: 2011-01-29 23:21    [W:0.021 / U:211.604 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site