lkml.org 
[lkml]   [2011]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/4] perf top: Don't let events to eat up whole header line
    Date
    From: Jiri Olsa <jolsa@redhat.com>

    Passing multiple events might force out information about pid/tid/cpu.
    Attached patch leaves 30 characters for this info at the expense of the
    events' names.

    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Paul Mackerras <paulus@samba.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Han Pingtian <phan@redhat.com>
    LKML-Reference: <1299528821-17521-3-git-send-email-jolsa@redhat.com>
    Signed-off-by: Jiri Olsa <jolsa@redhat.com>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    ---
    tools/perf/util/top.c | 20 +++++++++++++++++---
    1 files changed, 17 insertions(+), 3 deletions(-)

    diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c
    index 4f869da..75cfe4d 100644
    --- a/tools/perf/util/top.c
    +++ b/tools/perf/util/top.c
    @@ -115,9 +115,23 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
    if (!top->display_weighted) {
    ret += SNPRINTF(bf + ret, size - ret, "%s",
    event_name(top->sym_evsel));
    - } else list_for_each_entry(counter, &top->evlist->entries, node) {
    - ret += SNPRINTF(bf + ret, size - ret, "%s%s",
    - counter->idx ? "/" : "", event_name(counter));
    + } else {
    + /*
    + * Don't let events eat all the space. Leaving 30 bytes
    + * for the rest should be enough.
    + */
    + size_t last_pos = size - 30;
    +
    + list_for_each_entry(counter, &top->evlist->entries, node) {
    + ret += SNPRINTF(bf + ret, size - ret, "%s%s",
    + counter->idx ? "/" : "",
    + event_name(counter));
    + if (ret > last_pos) {
    + sprintf(bf + last_pos - 3, "..");
    + ret = last_pos - 1;
    + break;
    + }
    + }
    }

    ret += SNPRINTF(bf + ret, size - ret, "], ");
    --
    1.6.2.5


    \
     
     \ /
      Last update: 2011-03-10 20:33    [W:0.032 / U:29.916 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site