Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1095081ybc; Tue, 19 Nov 2019 14:29:22 -0800 (PST) X-Google-Smtp-Source: APXvYqx7x3sxV1I5kU0BXq56rG7RED76GSyo1ekgbEXZowH9yml6y3DNMfOwZNkFY8S+icgRaxM1 X-Received: by 2002:a17:906:f90d:: with SMTP id lc13mr99569ejb.154.1574202562164; Tue, 19 Nov 2019 14:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574202562; cv=none; d=google.com; s=arc-20160816; b=WBgMpckCJKVv0+JEu41LpGKmMXxK7P2ryGqKV3GMDNrRhOOacE2l6IQwA93sZU7zFn 4d9RYNxTcPmnrj1QKGKVldu/FBYeXBuaqEmgkDDrTRIq9AnLMJt/JmYWaGPZeleCu/sZ lDLzLvBVi5Vpb59Bgkyo33ySYkCG/6N7vj0akIjKmireERqQ1eBEqkJZExRy6YvfXeCz k2kTiOLVGtCVvflGfM8hoS8g5DfUgtYEjicolaKRtM8OS0WOdmkwVlBr2GmvaNjkpX5J rMdNXB8gCx7YX4BR6cxrGwsgX1D1XBTc+4emIhIJWsZywrHvm7FeU8v7Kn3irDOtzQcl 2c6w== 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:from:references:cc:to:subject; bh=QnPp6LpEcx0KVXJcpRfOI3/WKOr7bScC8pUsU3DrZWY=; b=j2inx9UULnAIvlwLBTYT4z5psgvmp/Z0QJKS9Aw9LpruQrqcvtpp/WedLjNCa2vl/x usg3zDmkxM1GxpCumn8a3SrC1oHoAlncV6JYS0Y6sh+2ehIGyMr+XlIDygrgd3B0uIPS 36F1royp/Kokjh0z4JJmCaURgQNCfeW//V1dX9n+GtVgS22Uzeq9lpP3jqjvT6+TuUzH vH+xB6ks13Wk+id4WqzkYwZXZMOUSQMkaRJ5cyJvnUfb6qvtxbXKwULGCprZMX/6rFuD dpoGYhodNO9d8WcC6FGYQLUzI+Mm1OvhUEFb9AjH5QQ3/8fXBf3ZY15P3JTRYT4fT4O5 M3XA== 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 s46si18661836edd.336.2019.11.19.14.28.57; Tue, 19 Nov 2019 14:29:22 -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 S1727403AbfKSWZs (ORCPT + 99 others); Tue, 19 Nov 2019 17:25:48 -0500 Received: from mga11.intel.com ([192.55.52.93]:6439 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbfKSWZs (ORCPT ); Tue, 19 Nov 2019 17:25:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 14:25:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,219,1571727600"; d="scan'208";a="381165579" Received: from linux.intel.com ([10.54.29.200]) by orsmga005.jf.intel.com with ESMTP; 19 Nov 2019 14:25:47 -0800 Received: from [10.251.19.22] (kliang2-mobl.ccr.corp.intel.com [10.251.19.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 0C4EC5800FE; Tue, 19 Nov 2019 14:25:45 -0800 (PST) Subject: Re: [PATCH V4 01/13] perf/core: Add new branch sample type for LBR TOS To: Stephane Eranian Cc: Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , LKML , Jiri Olsa , Namhyung Kim , vitaly.slobodskoy@intel.com, pavel.gerasimov@intel.com, Andi Kleen , Michael Ellerman References: <20191119143411.3482-1-kan.liang@linux.intel.com> <20191119143411.3482-2-kan.liang@linux.intel.com> From: "Liang, Kan" Message-ID: <6c233145-fb30-b629-2290-8595e192ba82@linux.intel.com> Date: Tue, 19 Nov 2019 17:25:45 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 On 11/19/2019 2:02 PM, Stephane Eranian wrote: > On Tue, Nov 19, 2019 at 6:35 AM wrote: >> From: Kan Liang >> >> In LBR call stack mode, the depth of reconstructed LBR call stack limits >> to the number of LBR registers. With LBR Top-of-Stack (TOS) information, >> perf tool may stitch the stacks of two samples. The reconstructed LBR >> call stack can break the HW limitation. >> >> Add a new branch sample type to retrieve LBR TOS. The new type is PMU >> specific. Add it at the end of enum perf_branch_sample_type. >> Add a macro to retrieve defined bits of branch sample type. >> Update perf_copy_attr() to handle the new bit. >> >> Only when the new branch sample type is set, the TOS information is >> dumped into the PERF_SAMPLE_BRANCH_STACK output. >> Perf tool should check the attr.branch_sample_type, and apply the >> corresponding format for PERF_SAMPLE_BRANCH_STACK samples. >> Otherwise, some user case may be broken. For example, users may parse a >> perf.data, which include the new branch sample type, with an old version >> perf tool (without the check). Users probably get incorrect information >> without any warning. >> >> Signed-off-by: Kan Liang >> --- >> include/linux/perf_event.h | 2 ++ >> include/uapi/linux/perf_event.h | 16 ++++++++++++++-- >> kernel/events/core.c | 13 ++++++++++++- >> 3 files changed, 28 insertions(+), 3 deletions(-) >> >> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h >> index 011dcbdbccc2..761021c7ee8a 100644 >> --- a/include/linux/perf_event.h >> +++ b/include/linux/perf_event.h >> @@ -93,6 +93,7 @@ struct perf_raw_record { >> /* >> * branch stack layout: >> * nr: number of taken branches stored in entries[] >> + * tos: Top-of-Stack (TOS) information. PMU specific data. >> * >> * Note that nr can vary from sample to sample >> * branches (to, from) are stored from most recent >> @@ -101,6 +102,7 @@ struct perf_raw_record { >> */ >> struct perf_branch_stack { >> __u64 nr; >> + __u64 tos; /* PMU specific data */ >> struct perf_branch_entry entries[0]; >> }; >> > Same remark as with the other patch. You need to abstract this. > The TOS and PMU specific data should be limited to x86/event/intel/*.[ch]. > If we change tos to a generic name, e.g. pmu_specific_data, can we still keep it here? If not, I think the only way is to introduce a new method, e.g. output_br_pmu_data(), at struct pmu. When outputting the sample data, the generic code will call event->pmu->output_br_pmu_data() to retrieve the TOS in Intel code. I think it's too complicated. Thanks, Kan