Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1860989rdb; Tue, 3 Oct 2023 03:28:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdaOdwIudNHzMVlERT/B3xtiAlF4flM7hqbJbY03betubNl/WQmruUc8rBh2MXQaXAJnl+ X-Received: by 2002:a05:6358:7245:b0:13f:2833:bf41 with SMTP id i5-20020a056358724500b0013f2833bf41mr15446372rwa.23.1696328886617; Tue, 03 Oct 2023 03:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696328886; cv=none; d=google.com; s=arc-20160816; b=odYnRRq+MLNPSWg4Hx+j2syGhtu5EmKxIgi0HCRjIg5+d/3CVDIzHUSiR0HGita026 zRYfocCo6N0hGTSr7CbbnmwUM8590twQbXf5UOgUSg5fEZC2MHujq2N3/btXJXdQIvUU rk/8tAYqt6ZzsFxOKYKfBehy7v9sdcwpnLTFGy/5JMIk3HVNMm8W+XDXiUxw5dxleW/O vH0QPu91ijS8uGkE9IfYAit1GSm1Okac3O5B2MzQoLbgLf6/4nizxlI0X4kMXoAQ0+9Z 3HZBapHzYysJRUMAXLOm7VF9Y+Nz/maqY0nKi311DEjrrZxg5d5T0oiKougG+dSHgy4G 9JUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6qb4WZ92U8yIFE7GYSvrq4aS/hQetxiLq3tL2nxTeg0=; fh=drxRf27tFlMHHReZo6yF3EarHrc8k8R6YQtCQ2ZPdWo=; b=CsDft1UT6H7jsXCPrieGYW7srGXtVAzyVtzGGQ/lgUL8GBFX938k+kZXJwRE9Vc4Y+ gOOLGiWR8fkYINDAcU3c/LL68qgqEvAzPDh2eVvD69ceVYtd5uAFtqhCVUzko5ONKkWF jRR57XuKTnlHGv+GtHWKVvxYual0smrxmjVnxzNn6tg40mTcMSjsNuvuIyld7SHaOqgM g95zCZtadkpAYfulVNz37bqbivK//Ny6KILuDJFsCxyFL3XoBixEku0WW9QbX1U5bNzm nw4xx+PzMbvxV97zSTIY2llQenapa8TGzhaRPdunAZz4QbmPkI5hCJbPNwW8NUQ7jlb3 EEMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=gkvUCEwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ey27-20020a056a0038db00b0068e4c3f3ac2si1093403pfb.245.2023.10.03.03.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 03:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=gkvUCEwW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B37C58023995; Tue, 3 Oct 2023 03:28:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231616AbjJCK1y (ORCPT + 99 others); Tue, 3 Oct 2023 06:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjJCK1x (ORCPT ); Tue, 3 Oct 2023 06:27:53 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151B3B7 for ; Tue, 3 Oct 2023 03:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6qb4WZ92U8yIFE7GYSvrq4aS/hQetxiLq3tL2nxTeg0=; b=gkvUCEwWmEDjsOagl1Wah+jnga vuOazKXCqy9IiKzCgpJlZVnqcbONeyv47g+baPnwDFvwIYrR0Lpwnup6QSSmNU+MX4IQWMLHRs3Gf nUPdZHoqwYWkM8OYKyOBrxTpHQrk8R2zqSW2zz19PtlluqtKS74Wu8lJUobKDBqzWzjmRQOPW7TXR lv6P+TUdrnGZkOSyc3wPrrz9+SBgpiWmyMPbdwDFIpApUui8qjhHWxV3VCOOBnSN7N5PWu/Pc7jX1 kjm7SYMbByAeTe57AwdJCCWatIX9m40kzMKrDY7K/s1IhMdPvmrKFhNW7B28AcXM2imUrN+LiWvhi 8vDEk57Q==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qnccm-009oOa-1p; Tue, 03 Oct 2023 10:27:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 822BC300348; Tue, 3 Oct 2023 12:27:33 +0200 (CEST) Date: Tue, 3 Oct 2023 12:27:33 +0200 From: Peter Zijlstra To: "Liang, Kan" 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 Subject: Re: [RESEND PATCH V3 1/6] perf: Add branch stack extra Message-ID: <20231003102733.GC1539@noisy.programming.kicks-ass.net> References: <20230911154822.2559213-1-kan.liang@linux.intel.com> <20231002154535.GB35785@noisy.programming.kicks-ass.net> <20231002213752.GB1539@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 pete.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 (pete.vger.email [0.0.0.0]); Tue, 03 Oct 2023 03:28:03 -0700 (PDT) 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. 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.