Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp616186ybc; Tue, 19 Nov 2019 06:39:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwixNk038JZIJoVC/F7/Me47O2vC+HIiVeq+PbSEXgIK6FdsUSVOpZniDQkeqWXfwdiJOrF X-Received: by 2002:a17:906:37cd:: with SMTP id o13mr19770309ejc.148.1574174342638; Tue, 19 Nov 2019 06:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574174342; cv=none; d=google.com; s=arc-20160816; b=e8Afv/yvL156XUI6gHd4t+Vqu3ERcZ1N8R/X1NQJ74oULK49JowlOnh73sQffqNltP EPJ3xtnzrYezkzId3VxUTVcr9O7WI0RTQE7knuGxNlk673sXvBlwcliK5oi/QD6jl0o+ 7stJoxyGopBl0SO/V1rTW+laNueKFJAaNzsrH4tAZ+pD3+VAT/q6Zlo7eTFAm5KJssjr Z3Qj9qqCptVbXKMNi9OFm8yGHADVjiZSOeosHA5N41L5/pK7ASP4OLw0tu6fAs8rtIsk Lxu43quXdCfX5rRAVId+MiLFATVXF5BFekFXtPiyHz+KKmHsQOp6bJ9xPcj5u3e5XCqq blIg== 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=waLf2ca0luOSisg+LT5vo7Zc4l7InwX9syXLqnq/9W0=; b=WceNiFuYYa7zHSrefjf/fyiB4n9Kyx9uNexsBQ8pgoDiMuqXZTxuzxcMqMNqMEuGrq oUAOzQvrqO8C73WJAxI6vOxY07qIL0LyJw0M1cZl11As+DCNbsqoxWcl7Ba23ixblKoJ TsKTVaExxxHgEKL1subHHXGvCPZGTVPtgXIdhYA9whRc7cIn4/jLuzq7hr4qXqeXXvPF cOdlU+3UYjPFN3BHqd/FU34UjRmgLNZBAZ04V++Htr3JgWgDb3B9wO/oVuLA+Q6m53hE /7xmUn6l+0/LpZJmhRzgI4K0AyVD18w7S3IJfO2xKILjw6UowfSawWIEEEbJvwwzSOTd 7k6Q== 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 p17si13111939ejb.9.2019.11.19.06.38.38; Tue, 19 Nov 2019 06:39:02 -0800 (PST) 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 S1728165AbfKSOfJ (ORCPT + 99 others); Tue, 19 Nov 2019 09:35:09 -0500 Received: from mga04.intel.com ([192.55.52.120]:64765 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbfKSOfH (ORCPT ); Tue, 19 Nov 2019 09:35:07 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 06:35:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,324,1569308400"; d="scan'208";a="215552371" Received: from labuser-ice-lake-client-platform.jf.intel.com ([10.54.55.50]) by fmsmga001.fm.intel.com with ESMTP; 19 Nov 2019 06:35:06 -0800 From: kan.liang@linux.intel.com To: peterz@infradead.org, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: jolsa@kernel.org, namhyung@kernel.org, vitaly.slobodskoy@intel.com, pavel.gerasimov@intel.com, ak@linux.intel.com, eranian@google.com, mpe@ellerman.id.au, Kan Liang Subject: [PATCH V4 02/13] perf/x86/intel: Output LBR TOS information Date: Tue, 19 Nov 2019 06:34:00 -0800 Message-Id: <20191119143411.3482-3-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191119143411.3482-1-kan.liang@linux.intel.com> References: <20191119143411.3482-1-kan.liang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang A new branch sample type was introduced to require the LBR Top-of-Stack (TOS) information. For non-adaptive PEBS and non-PEBS, the TOS information can be directly retrieved from TOS MSR read in intel_pmu_lbr_read(). For adaptive PEBS, the LBR information stored in PEBS record doesn't include the TOS information. For single PEBS, TOS can be directly read from MSR, because the PMI is triggered immediately after PEBS is written. TOS MSR is still unchanged. For large PEBS, TOS MSR has stale value. Set -1ULL to indicate that the TOS information is not available. Signed-off-by: Kan Liang --- arch/x86/events/intel/lbr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 534c76606049..956802dff5f7 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -585,6 +585,7 @@ static void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc) cpuc->lbr_entries[i].reserved = 0; } cpuc->lbr_stack.nr = i; + cpuc->lbr_stack.tos = tos; } /* @@ -680,6 +681,7 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc) out++; } cpuc->lbr_stack.nr = out; + cpuc->lbr_stack.tos = tos; } void intel_pmu_lbr_read(void) @@ -1120,6 +1122,13 @@ void intel_pmu_store_pebs_lbrs(struct pebs_lbr *lbr) int i; cpuc->lbr_stack.nr = x86_pmu.lbr_nr; + + /* Cannot get TOS for large PEBS */ + if (cpuc->n_pebs == cpuc->n_large_pebs) + cpuc->lbr_stack.tos = -1ULL; + else + cpuc->lbr_stack.tos = intel_pmu_lbr_tos(); + for (i = 0; i < x86_pmu.lbr_nr; i++) { u64 info = lbr->lbr[i].info; struct perf_branch_entry *e = &cpuc->lbr_entries[i]; -- 2.17.1