From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940957AbcISNWh (ORCPT ); Mon, 19 Sep 2016 09:22:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41158 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760835AbcISNLL (ORCPT ); Mon, 19 Sep 2016 09:11:11 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Don Zickus , Joe Mario , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , Andi Kleen Subject: [PATCH 23/61] perf c2c report: Add dcacheline dimension key Date: Mon, 19 Sep 2016 15:09:32 +0200 Message-Id: <1474290610-23241-24-git-send-email-jolsa@kernel.org> In-Reply-To: <1474290610-23241-1-git-send-email-jolsa@kernel.org> References: <1474290610-23241-1-git-send-email-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 19 Sep 2016 13:11:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding dcacheline dimension key support. It displays cacheline address as hex number. Using c2c wrapper to standard 'dcacheline' object to defined own header and simple (just address) cacheline output. Link: http://lkml.kernel.org/n/tip-j5enppr8e7h27nskqhgq33lu@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-c2c.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index c21124e6bb63..060ee1050da9 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -1,5 +1,6 @@ #include #include +#include #include "util.h" #include "debug.h" #include "builtin.h" @@ -7,6 +8,7 @@ #include "mem-events.h" #include "session.h" #include "hist.h" +#include "sort.h" #include "tool.h" #include "data.h" #include "sort.h" @@ -271,6 +273,33 @@ static int c2c_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, return scnprintf(hpp->buf, hpp->size, "%*s", width, text); } +static char *hex_str(u64 val) +{ + static char buf[20]; + + snprintf(buf, 20, "0x%" PRIx64, val); + return buf; +} + +static int64_t +dcacheline_cmp(struct perf_hpp_fmt *fmt __maybe_unused, + struct hist_entry *left, struct hist_entry *right) +{ + return sort__dcacheline_cmp(left, right); +} + +static int dcacheline_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, + struct hist_entry *he) +{ + uint64_t addr = 0; + int width = c2c_width(fmt, hpp, he->hists); + + if (he->mem_info) + addr = cl_address(he->mem_info->daddr.addr); + + return snprintf(hpp->buf, hpp->size, "%*s", width, hex_str(addr)); +} + #define HEADER_LOW(__h) \ { \ .line[1] = { \ @@ -306,12 +335,21 @@ static int c2c_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, }, \ } +static struct c2c_dimension dim_dcacheline = { + .header = HEADER_LOW("Cacheline"), + .name = "dcacheline", + .cmp = dcacheline_cmp, + .entry = dcacheline_entry, + .width = 18, +}; + #undef HEADER_LOW #undef HEADER_BOTH #undef HEADER_SPAN #undef HEADER_SPAN_LOW static struct c2c_dimension *dimensions[] = { + &dim_dcacheline, NULL, }; -- 2.7.4