From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32E93C48BEB for ; Wed, 14 Feb 2024 09:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tUOQwvLkdatQMNTQIlJSPgqf5Kiv6PaWEfjjgdtkccQ=; b=T8MbIQGyIPJluj KdQsesrKshlSdtaiONU2SjEavzuCkEBAmch+dO5uLAgPogY8e7LSUQJ8Z/i8v4f5FaSEVQCxiCFLf mwkiNAs42VW5gpCIfpMnhcCRFe8PP7DLfk+FmsMsbnMAoTWWAllrqcsXcHdd/m7L0DZrFQlyH/Mv5 ZgWKs75Iyno6HA8QTMwoV4dcPwXNjKUIVGyjZ6jdbh1iXjgYgo2CZSp9d107ZV/PPJiuRbupn7C7n VrIAf3PJmmLXWnmQRKV6uRb4RuojdmptBgb6TO6355v1FlvKMwKE6yceveVU8ADgPpRoRojN65XSs rtiIl/sDn5ji1VHzs/Dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBzE-0000000CSIB-2fBx; Wed, 14 Feb 2024 09:55:28 +0000 Received: from mgamail.intel.com ([198.175.65.16]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raBzA-0000000CSFd-3fA2 for linux-arm-kernel@lists.infradead.org; Wed, 14 Feb 2024 09:55:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707904524; x=1739440524; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=A/g1r9lBVBXaq+NvYx4KgeDD3Du8cdjmgJE9bAtv2zA=; b=Eh3169e6JkPN+YRHfG2rsdPTVkuMIDDPhUBqv+GYN/M0UhAHV26EmLy4 JXsHRCMEyvaOQFn0v34Om2P+/JwKJa89uFlxtJCE7CCOFymADViCnmMx4 ZBiVIBpvDmtR3c125bPQZDBzx5P0K4u+tSJRjqrn/FXLDrJI+Wsow1ujc 8iqYYUnL5dMda/nVw7YU4vRw0WwDZX0fl0/Hqpqa4n+vr+oqBx0vmOkEW Ntbhp+ZsCmIIV/2tVKK0ahQyE0kZLP3p0Fy9oErc+wNqNmOBV9G6wvvCZ FH7JTgiLMno9c9yPWTfqeCLYmvB7YTIBCJazR7jgzYP8y8/GvcOp0PqcL Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10982"; a="2085166" X-IronPort-AV: E=Sophos;i="6.06,159,1705392000"; d="scan'208";a="2085166" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 01:55:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,159,1705392000"; d="scan'208";a="3499569" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.54.38.190]) by orviesa006.jf.intel.com with ESMTP; 14 Feb 2024 01:55:24 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id B5A60300B65; Wed, 14 Feb 2024 01:55:23 -0800 (PST) From: Andi Kleen To: Ben Gainey Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, will@kernel.org Subject: Re: [RFC PATCH 0/2] A mechanism for efficient support for per-function metrics In-Reply-To: <20240123113420.1928154-1-ben.gainey@arm.com> (Ben Gainey's message of "Tue, 23 Jan 2024 11:34:18 +0000") References: <20240123113420.1928154-1-ben.gainey@arm.com> Date: Wed, 14 Feb 2024 01:55:23 -0800 Message-ID: <87r0hfwet0.fsf@linux.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240214_015525_019345_917CC988 X-CRM114-Status: GOOD ( 31.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ben Gainey writes: > I've been working on an approach to supporting per-function metrics for > aarch64 cores, which requires some changes to the arm_pmuv3 driver, and > I'm wondering if this approach would make sense as a generic feature > that could be used to enable the same on other architectures? > > The basic idea is as follows: > > * Periodically sample one or more counters as needed for the chosen > set of metrics. > * Record a sample count for each symbol so as to identify hot > functions. > * Accumulate counter totals for each of the counters in each of the > metrics *but* only do this where the previous sample's symbol > matches the current sample's symbol. It sounds very similar to what perf script -F +metric already does (or did if it wasn't broken currently). It would be a straight forward extension here to add this "same as previous" check. Of course the feature is somewhat dubious in that it will have a very strong systematic bias against short functions and even long functions in some alternating execution patterns. I assume you did some experiments to characterize this. It would be important to emphasize this in any documentation. > For this to work efficiently, it is useful to provide a means to > decouple the sample window (time over which events are counted) from > the sample period (time between interesting samples). This patcheset > modifies the Arm PMU driver to support alternating between two > sample_period values, providing a simple and inexpensive way for tools > to separate out the sample period and the sample window. It is expected > to be used with the cycle counter event, alternating between a long and > short period and subsequently discarding the counter data for samples > with the long period. The combined long and short period gives the > overall sampling period, and the short sample period gives the sample > window. The symbol taken from the sample at the end of the long period > can be used by tools to ensure correct attribution as described > previously. The cycle counter is recommended as it provides fair > temporal distribution of samples as would be required for the > per-symbol sample count mentioned previously, and because the PMU can > be programmed to overflow after a sufficiently short window; this may > not be possible with software timer (for example). This patch does not > restrict to only the cycle counter, it is possible there could be other > novel uses based on different events. I don't see anything ARM specific with the technique, so if it's done it should be done generically IMHO > Cursory testing on a Xeon(R) W-2145 sampling every 300 cycles (without > the patch) suggests this approach would work for some counters. > Calculating branch miss rates for example appears to be correct, > likewise UOPS_EXECUTED.THREAD seems to give something like a sensible > cycles-per-uop value. On the other hand the fixed function instructions > counter does not appear to sample correctly (it seems to report either > very small or very large numbers). No idea whats going on there, so any > insight welcome... If you use precise samples with 3p there is a restriction on the periods that is enforced by the kernel. Non precise or single/double p should support arbitrary, except that any p is always period + 1. One drawback of the technique on x86 is that it won't allow multi record pebs (collecting samples without interrupts), so the overhead might be intrinsically higher. -Andi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel