Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp454058ybl; Fri, 9 Aug 2019 08:27:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6DFI33aLX2c42hutyvfWfbYvgSFsWWlYmwZXTDEKOov1VhdPbpZwPNwp+4emvEJJjDTgg X-Received: by 2002:a63:e306:: with SMTP id f6mr17664663pgh.39.1565364479039; Fri, 09 Aug 2019 08:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565364479; cv=none; d=google.com; s=arc-20160816; b=ANlaBt87pLwxbSOARXUmHgvXHcXcXXQ6Iz7GVajM8ohuPqR0czGqGfgZlapqNigQHD R32B4Cv/lN1+BUilSaHJ/1/1BlttbO4huJJp7+Rmi2ZZyjcQ6BDcFDDEedoMp/+URGY1 UNOZUk82/lypMSHWRXev8J6tfSrynwdmyXARH60+AfO5wTF0VsIZ60xOqDwVoX014ul+ g1X6ffQLZIEEq9ssd84om3/pl2TB4Esr2KPHtbgn0G9K1vLt47dD0bRHD2SyYK2Lfdu4 6uOTEYZ1lIaeKv25Uef00l13RUvnH5DeSDDqqJ25HKqszx5LEMN7MXqNgaKg04MaNH0v H/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject; bh=mzOCaSwbyM9g3w7EXnWR/ETn3o/7unL+mc5WNUkZVvU=; b=TQ7O/m+MPs14rfwVCVZ10yWsEblQ91iRTfr0ag7+gn84t52YXvPuBw0vX+tcV54/lq HFh/y1oJo3KwmW+AIXEkoZOykIGVQpDWtwmsrasxeYipyvEYiTob2Aj03fAMxUDcxqae PMSOeMZLRsaHXGLQDib7tll2GGKqapq4MR/Vng8FvZxNJT4zgt80bTaprEM1ZB7te1Cd pDBAZjr2pknYYC9mN3YuCowwZF/MwwzdfvX3z7SUH+PH9CJqkNhkffVvI+V9y9OKy6eX SI1X0voimt5vE+Q9WKEkMYAyr5oUN7A16utDA8GNWSg5KTOlzUe0qIArjHt9iUtmrlL7 Lynw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f37si4629803pjg.61.2019.08.09.08.27.43; Fri, 09 Aug 2019 08:27:59 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407394AbfHIP0g (ORCPT + 99 others); Fri, 9 Aug 2019 11:26:36 -0400 Received: from mga01.intel.com ([192.55.52.88]:27708 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfHIP0g (ORCPT ); Fri, 9 Aug 2019 11:26:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 08:26:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="177666378" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 09 Aug 2019 08:26:35 -0700 Received: from [10.252.0.91] (abudanko-mobl.ccr.corp.intel.com [10.252.0.91]) by linux.intel.com (Postfix) with ESMTP id 235B4580417; Fri, 9 Aug 2019 08:26:31 -0700 (PDT) Subject: [PATCH v1 2/3] perf report: dump LBR callstack data by -D jointly with thread stack From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , Kan Liang , "Jin, Yao" , linux-kernel References: Organization: Intel Corp. Message-ID: Date: Fri, 9 Aug 2019 18:26:30 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make perf report -D command print captured LBR callstack chain when it is collected together with raw thread stack data: 2752673087247083 0x5d10 [0x548]: PERF_RECORD_SAMPLE(IP, 0x4002): 5841/5841: 0x40121f period: 1543862 addr: 0 ... FP chain: nr:0 ... branch callstack: nr:3 ..... 0: 00000000004011d0 ..... 1: 00007f393c388411 ..... 2: 0000000000401098 ... user regs: mask 0xff0fff ABI 64-bit .... AX 0x34e7 .... BX 0x7fff5f6dd3c0 .... CX 0xffffffff .... DX 0x34e6 .... SI 0x7f393c5268d0 .... DI 0x0 .... BP 0x401260 .... SP 0x7fff5f6dd3c0 .... IP 0x40121f .... FLAGS 0x29f .... CS 0x33 .... SS 0x2b .... R8 0x7f393c526800 .... R9 0x7f393c525da0 .... R10 0xfffffffffffff70a .... R11 0x246 .... R12 0x401070 .... R13 0x7fff5f6ddcb0 .... R14 0x0 .... R15 0x0 ... ustack: size 1024, offset 0x130 . data_src: 0x5080021 ... thread: stack_test:5841 ...... dso: /root/abudanko/stacks/stack_test Signed-off-by: Alexey Budankov --- tools/perf/util/session.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index b9fe71d11bf6..82e0438a9160 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1051,23 +1051,30 @@ static void callchain__printf(struct evsel *evsel, i, callchain->ips[i]); } -static void branch_stack__printf(struct perf_sample *sample) +static void branch_stack__printf(struct perf_sample *sample, bool callstack) { uint64_t i; - printf("... branch stack: nr:%" PRIu64 "\n", sample->branch_stack->nr); + printf("%s: nr:%" PRIu64 "\n", + !callstack ? "... branch stack" : "... branch callstack", + sample->branch_stack->nr); for (i = 0; i < sample->branch_stack->nr; i++) { struct branch_entry *e = &sample->branch_stack->entries[i]; - printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x\n", - i, e->from, e->to, - (unsigned short)e->flags.cycles, - e->flags.mispred ? "M" : " ", - e->flags.predicted ? "P" : " ", - e->flags.abort ? "A" : " ", - e->flags.in_tx ? "T" : " ", - (unsigned)e->flags.reserved); + if (!callstack) { + printf("..... %2"PRIu64": %016" PRIx64 " -> %016" PRIx64 " %hu cycles %s%s%s%s %x\n", + i, e->from, e->to, + (unsigned short)e->flags.cycles, + e->flags.mispred ? "M" : " ", + e->flags.predicted ? "P" : " ", + e->flags.abort ? "A" : " ", + e->flags.in_tx ? "T" : " ", + (unsigned)e->flags.reserved); + } else { + printf("..... %2"PRIu64": %016" PRIx64 "\n", + i, i > 0 ? e->from : e->to); + } } } @@ -1217,8 +1224,8 @@ static void dump_sample(struct evsel *evsel, union perf_event *event, if (evsel__has_callchain(evsel)) callchain__printf(evsel, sample); - if ((sample_type & PERF_SAMPLE_BRANCH_STACK) && !perf_evsel__has_branch_callstack(evsel)) - branch_stack__printf(sample); + if (sample_type & PERF_SAMPLE_BRANCH_STACK) + branch_stack__printf(sample, perf_evsel__has_branch_callstack(evsel)); if (sample_type & PERF_SAMPLE_REGS_USER) regs_user__printf(sample); -- 2.20.1