Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2318113imm; Thu, 20 Sep 2018 11:07:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbJSLncDWV6u3GU6x11B3jimaXEVNoWNclPglR+6YoG7F/bTXG8spFXgn4KBuOJ73gnrVDO X-Received: by 2002:a63:8c4:: with SMTP id 187-v6mr4686400pgi.396.1537466826351; Thu, 20 Sep 2018 11:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537466826; cv=none; d=google.com; s=arc-20160816; b=hGSVJ1P8wnZ/5VXC+Ni5RpbEUORQ+NMVs0N64klE/HkFP+CC6hJmiJIwGQgAl1FOXT qjbp6Q1RNIAJIYHMKptc6C5lxn82vi0G/b+d5k1s1eAt3njjbrr6J+TUGkfQ7MoO5pJ/ +XgKd2b43tGa8Zr6YCk/PGKOYvY+OIZ4PczI6FqFCTGSKwuWqK94t4WWbVgdHA1gMVmd kzr1SQ26Fry9I7n5Wh8UxWA+07a5KUwJaqM+/8XuWJ1oQRCWTrfcTPYYgKwOOrJywPWv RL13jFAPBCLndxTd7eARUlPAUZIjWgYGn0V3Nb8XwSFj9WV0W0HiTHa6l50Zx2NqGKWw LcLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nmfM9EQmfnbnQS4Tefk9fsTKUqwd60X6/V9RfkYYViE=; b=EWUEUTBEefeYQ2qTIP35mAL+i9E1svsmC7bfGm0tghe05ELawWyntENCju4ljT4vdm g1JkeQbe3XYXy498eTLucxAZ/X3OYXNYVt1xiQN2Dhxks52W03QiQKmuNn91U8Ij7XVp jNMV5QKNOlKERz7chQGz2fZAbiAzAE55r/s+PwbCdP6v2jPmo19UdhbujN+L5kaF+InV c3xfX9ndVMVovJmK67bH0vQA5uJ6VtXdGCajW7LeztSP3OyeOa0UkarcLPykuDLSrPFM vbo3/dddfWqSOCd0SC3UqyL/pKOuqZMEs2CENdmI51cDrVhal+mRkFhb5EPcnAe2Cdrl +Ddg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a31-v6si23522779pgm.114.2018.09.20.11.06.44; Thu, 20 Sep 2018 11:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388107AbeITXuc (ORCPT + 99 others); Thu, 20 Sep 2018 19:50:32 -0400 Received: from mga14.intel.com ([192.55.52.115]:43500 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731448AbeITXub (ORCPT ); Thu, 20 Sep 2018 19:50:31 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2018 11:05:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,281,1534834800"; d="scan'208";a="93486358" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.126]) by orsmga002.jf.intel.com with ESMTP; 20 Sep 2018 11:05:42 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id AB7F3301A93; Thu, 20 Sep 2018 11:05:42 -0700 (PDT) From: Andi Kleen To: acme@kernel.org Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH v6 5/5] perf, tools, script: Support total cycles count Date: Thu, 20 Sep 2018 11:05:40 -0700 Message-Id: <20180920180540.14039-6-andi@firstfloor.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180920180540.14039-1-andi@firstfloor.org> References: <20180920180540.14039-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen For perf script brstackinsn also print a running cycles count. This makes it easier to calculate cycle deltas for code sections measured with LBRs. % perf record -b -a sleep 1 % perf script -F +brstackinsn ... _dl_sysdep_start+330: 00007eff9f20583a insn: 75 c4 # PRED 24 cycles [24] 00007eff9f205800 insn: 48 83 e8 03 00007eff9f205804 insn: 48 83 f8 1e 00007eff9f205808 insn: 77 26 00007eff9f20580a insn: 48 63 04 81 00007eff9f20580e insn: 48 01 c8 00007eff9f205811 insn: ff e0 # MISPRED 31 cycles [7] 0.71 IPC 00007eff9f2059c0 insn: 44 8b 62 08 00007eff9f2059c4 insn: e9 67 fe ff ff # PRED 55 cycles [24] 0.04 IPC 00007eff9f205830 insn: 48 83 c2 10 00007eff9f205834 insn: 48 8b 02 00007eff9f205837 insn: 48 85 c0 00007eff9f20583a insn: 75 c4 # PRED 68 cycles [13] 0.23 IPC Signed-off-by: Andi Kleen --- v2: reflow line --- tools/perf/builtin-script.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6232658c6f31..53dc27e63d98 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -913,7 +913,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end, static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en, struct perf_insn *x, u8 *inbuf, int len, - int insn, FILE *fp) + int insn, FILE *fp, int *total_cycles) { int printed = fprintf(fp, "\t%016" PRIx64 "\t%-30s\t#%s%s%s%s", ip, dump_insn(x, ip, inbuf, len, NULL), @@ -922,7 +922,8 @@ static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en, en->flags.in_tx ? " INTX" : "", en->flags.abort ? " ABORT" : ""); if (en->flags.cycles) { - printed += fprintf(fp, " %d cycles", en->flags.cycles); + *total_cycles += en->flags.cycles; + printed += fprintf(fp, " %d cycles [%d]", *total_cycles, en->flags.cycles); if (insn) printed += fprintf(fp, " %.2f IPC", (float)insn / en->flags.cycles); } @@ -979,6 +980,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, u8 buffer[MAXBB]; unsigned off; struct symbol *lastsym = NULL; + int total_cycles = 0; if (!(br && br->nr)) return 0; @@ -999,7 +1001,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, printed += ip__fprintf_sym(br->entries[nr - 1].from, thread, x.cpumode, x.cpu, &lastsym, attr, fp); printed += ip__fprintf_jump(br->entries[nr - 1].from, &br->entries[nr - 1], - &x, buffer, len, 0, fp); + &x, buffer, len, 0, fp, &total_cycles); } /* Print all blocks */ @@ -1027,7 +1029,8 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample, printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp); if (ip == end) { - printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp); + printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp, + &total_cycles); break; } else { printed += fprintf(fp, "\t%016" PRIx64 "\t%s\n", ip, -- 2.17.1