Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1937208rdb; Tue, 3 Oct 2023 05:57:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFufrGcsM78CnsLJHGItb4q6T3Ph+IwdLUK7TYGPqtV6a1ZBH6cCE16XxJwq88eZVt/f9Um X-Received: by 2002:a05:6358:9886:b0:143:897e:6e31 with SMTP id q6-20020a056358988600b00143897e6e31mr16259530rwa.7.1696337863711; Tue, 03 Oct 2023 05:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696337863; cv=none; d=google.com; s=arc-20160816; b=Sp9FXav7LLkkwCWaP3doj2Cczu5C2DYxh9hXBXtWg5pF4Lgygg3E44HZh+9dDsRfpD iMZlv5cnSCKrar6AKVYjILgaOifGYYY9v54NPvMytlF4InvgsnJPoq+d8DP2gL5pc2Qm BEzvS89+42MSrdtwDBSgYNTOgthWbSHdw4DeBp/hMTTcStQNaWpsm5GPCEChovU6g+mB g4zULEIGTNHLBwhTFM6T1Wr6mvvJz1MTmguwopVJoLBvUTIRBbjBNOYLh3st6exnNrSr e2xC17uV1y3DziGX6Xk/+4ic4gvE5RVcmk1C9hFrZb/44wWMGy+D1nPx9RYlEBcjBmTL R2vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=RpYPD2M6mIzNnxmc8dnpIP5Me4gPgPdO12X4VrYuzbw=; fh=9foxVoOM1kI3M7WtfeUJVBjkbMLubgC8QGFu2ecKPoA=; b=Xm/VkB9BaGi0WRaBTU4qPuYLAC6pksX4xFnuvBW23sGH39CSkYoa/ZMOVzNaanOxv7 j1FBi9jIy/Jbrq4VQEzjdn/NHGu3MWQgUHtRb2yCwqmKlcCyWiYVmucwTMJiuBwhR33D vaz87lRM8DPVwX5FM7aF2id6iimqIPzb7zCEP4EM9gNSb8uAsVo8i56o7oYLTlaWx0FT wXGLjQYFfRybRv4NPs3LCm8BNy9xRd6d2C36y9E9w4+cdQQaepvgL1SAs+AAJ0hIhpRh JRPOgPoRsO22Y5OajqPakUkysnzMCvrOaOb58zY4ABx/2iEFpZ8WI2QuAqBUkNHCWf7I VksQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="R67/aelC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id m68-20020a632647000000b0057755b2f032si1470988pgm.542.2023.10.03.05.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 05:57:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="R67/aelC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EBB388096FE1; Tue, 3 Oct 2023 05:57:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjJCM5d (ORCPT + 99 others); Tue, 3 Oct 2023 08:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjJCM5c (ORCPT ); Tue, 3 Oct 2023 08:57:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529B09B for ; Tue, 3 Oct 2023 05:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696337847; x=1727873847; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=o/mh9hb5YaYdyMWIuqazNV+KdQvIMuDcQZAsPPctTTs=; b=R67/aelCANeWjp/nCN3NgEWc1LGETNFcxYbx2KzloJElIFoZsG8idN6C cRDPOXxsi9X8jKHraVHKabiVUXaKuPNumx3qKj1k3FK4f0AfnsyQkHxxy L9mXSf4LemlJ5eERaXshlcsoVJyAemXq6gNsG2XuNvVDQgzVdiB/7uFKE sK9pg9FyI/ahiH8Pdx0c439Gq/Lj3t/Yqbx4PkDmmIw6lyKhzBgkcefJT i1tXgD479pbRI8Cg9behlDO4nRMWryPjnrdXczeQEqG8qwQbg26kttzlp 61sPF+adzTUvTPuq90SpOZFbK9/+/A3ZovO/n/kYoMI6wIsDKezu75Xcp g==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="367916445" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="367916445" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 05:57:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="780294465" X-IronPort-AV: E=Sophos;i="6.03,197,1694761200"; d="scan'208";a="780294465" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2023 05:57:26 -0700 Received: from [10.209.133.202] (kliang2-mobl1.ccr.corp.intel.com [10.209.133.202]) (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 7CF0B580C73; Tue, 3 Oct 2023 05:57:24 -0700 (PDT) Message-ID: <3d0e9d76-b20c-2f44-cff6-0701f4487048@linux.intel.com> Date: Tue, 3 Oct 2023 08:57:23 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RESEND PATCH V3 1/6] perf: Add branch stack extra Content-Language: en-US To: Peter Zijlstra Cc: mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, ak@linux.intel.com, eranian@google.com, alexey.v.bayduraev@linux.intel.com, tinghao.zhang@intel.com, Sandipan Das , Ravi Bangoria , Athira Rajeev References: <20230911154822.2559213-1-kan.liang@linux.intel.com> <20231002154535.GB35785@noisy.programming.kicks-ass.net> <20231002213752.GB1539@noisy.programming.kicks-ass.net> <20231003102733.GC1539@noisy.programming.kicks-ass.net> From: "Liang, Kan" In-Reply-To: <20231003102733.GC1539@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 05:57:40 -0700 (PDT) On 2023-10-03 6:27 a.m., Peter Zijlstra wrote: > On Mon, Oct 02, 2023 at 08:57:57PM -0400, Liang, Kan wrote: > >>> Did I already say that the ISE document raises more questions than it >>> provides answers? >> >> Yes. Would an improved CPUID enumeration can address the questions? For >> example, the CPUID enumeration can give the maximum number of counters >> and supported width? I think we can discuss it with the architect. > > So.. no. Suppose another arch goes and does the same, but with a > different number and width of counters. They won't have CPUID. > > I'm thinking we should do something like expose branch_counter_nr and > branch_counter_width in the sysfs node, and then rename this extra field > to counters. Sure. I will expose them under the "caps" folder. > > Then userspace can do something like: > > for (i = 0; i < branch_counter_nr; i++) { > counter[i] = counters & ((1 << branch_counter_width) - 1); > counters >>= branch_counter_width; > } > > to extract the actual counter values. > > > So then we end up with: > > * { u64 nr; > * { u64 hw_idx; } && PERF_SAMPLE_BRANCH_HW_INDEX > * { u64 from, to, flags } lbr[nr]; > + * { u64 counters; } cntr[nr] && PERF_SAMPLE_BRANCH_COUNTERS > * } && PERF_SAMPLE_BRANCH_STACK > > Have it explicitly named counters, have only the one flag and have sysfs > files describe how to decode it. > > Then for this Intel thing we have 4 counters of 2 bits, but if someone > else were to do something different (both Power and ARM64 have this > branch stack stuff now) they can describe it. > > It is a bit wasteful on bits... but at least its clear I suppose. Yes. I will send a V4 with the above suggestions. Thanks, Kan