Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp457395rdh; Thu, 23 Nov 2023 08:24:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7ck8Dv91LXce/Pbssjr1Fv3HLzZF+/XWVdrvwHgUjrLJv0PmZdXwADX8dXD0wLVmDUzbQ X-Received: by 2002:a05:6e02:154f:b0:35b:2e81:7272 with SMTP id j15-20020a056e02154f00b0035b2e817272mr160599ilu.2.1700756641365; Thu, 23 Nov 2023 08:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700756641; cv=none; d=google.com; s=arc-20160816; b=OFEoWKA348WRNPi7KaC3xaQcYen2UhBnH0/C22BsaOsxoLE7SdRG6rG3MmEEaBH0Wl kWCzIqF7WVIpU4MFiuBFeAQ4z6sW2SVCbn4NKpOvuTZ9f0hzKuBeNSubrtc5HWMZ/Sfv 4ay7wWWkAOi2HFZZlgvm9Nq4IQgBKLxWmiwGFJ1zJP8l8mDgo1SeryFxSN7bTX6W2a7l ha4kbHUJ12g2dM1L5TXRFrKbWvs++u61JodmP8QOO/3DiXe7MTKcuZIcYaea3nVFMRiD WpCmBGx6xinHnCaoib7/Bq2XAM2r9ZHzU9p+4mrtdtsWNggxO6P8kznoiyrEM1aOHNod QTmQ== 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; bh=wRBkk0p9ZRck5sgIE75M/Wfhu2iN5PdRsa76tRlTIy4=; fh=BKtvGj5BDohiJLp9kBrMDW9wK59fRCzJWq2d1yYGwIc=; b=H7FYdHX/3+6S80q9bS916WmQE7JFtZ9xh+rDEzqrFHvA0d/rsaV3l/i5S/X0RQ38kM mve53CBcpD2fXnCTZVpWaGMqkNCzystAWblWd4RfJLfNLZXFijiAMWmPukTWfgpXFKDq SFILWilKrRvAgIoYdHXUgUcetRhkoq9c6y4I86klTHRR+jBKLxz0TFt4r7b7jgubLK+l n1XQI/tXR3PcNsXPgpRe+QjfTZGxxVexhIN6BOccGEsXxyMeKFOytoSxVM2bOlaDtcEc IDk/DThzxPv1i9NvwWytwj4sW8vprT/Tr1fnwO1RBYZJXR4RLmSD276kNLDRILFW2c/k EADA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u2-20020a631402000000b005b9377ee20csi1546305pgl.701.2023.11.23.08.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 08:24:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B06BD8027F06; Thu, 23 Nov 2023 08:23:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjKWQXn (ORCPT + 99 others); Thu, 23 Nov 2023 11:23:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjKWQXm (ORCPT ); Thu, 23 Nov 2023 11:23:42 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A39C51A8; Thu, 23 Nov 2023 08:23:48 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D33DB106F; Thu, 23 Nov 2023 08:24:34 -0800 (PST) Received: from [10.57.3.62] (unknown [10.57.3.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90ABC3F6C4; Thu, 23 Nov 2023 08:23:46 -0800 (PST) Message-ID: <047fae8f-86fd-6181-9599-a653fe2b3d9c@arm.com> Date: Thu, 23 Nov 2023 16:23:45 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [V14 0/8] arm64/perf: Enable branch stack sampling Content-Language: en-US To: Anshuman Khandual Cc: Mark Brown , Rob Herring , Marc Zyngier , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com References: <20231114051329.327572-1-anshuman.khandual@arm.com> From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 08:23:58 -0800 (PST) On 22/11/2023 05:15, Anshuman Khandual wrote: > On 11/14/23 22:47, James Clark wrote: >> >> >> On 14/11/2023 05:13, Anshuman Khandual wrote: >>> This series enables perf branch stack sampling support on arm64 platform >>> via a new arch feature called Branch Record Buffer Extension (BRBE). All >>> the relevant register definitions could be accessed here. >>> >> [...] >>> >>> --------------------------- Virtualisation support ------------------------ >>> >>> - Branch stack sampling is not currently supported inside the guest (TODO) >>> >>> - FEAT_BRBE advertised as absent via clearing ID_AA64DFR0_EL1.BRBE >>> - Future support in guest requires emulating FEAT_BRBE >> >> If you never add support for the host looking into a guest, and you save > > But that seems to be a valid use case though. Is there a particular concern > why such capability should or could not be added for BRBE ? > What's the use case exactly? You wouldn't even have the binary mappings of the guest without running perf inside the guest too, and at that point you might as well have just done the BRBE recording from inside the guest. My particular concern is only about the effort required to implement it, vs its usefulness. Not that we shouldn't ever implement the fully shared BRBE between host and guest, we could always do it later. My idea was just to get BRBE working inside of guests quicker. >> and restore all the BRBINF[n] registers, I think you might be able to >> just let the guest do whatever it wants with BRBE and not trap and >> emulate it? Maybe there is some edge case why that wouldn't work, but >> it's worth thinking about. > > Right, in case host tracing of the guest is not supported (although still > wondering why it should not be), saving and restoring complete BRBE state > i.e all system registers that can be accessed from guest, would let guest > do what ever it wants with BRBE without requiring the trap-emulate model. > >> >> For BRBE specifically I don't see much of a use case for hosts looking >> into a guest, at least not like with PMU counters. > But how is it any different from normal PMU counters ? Branch records do > provide statistical insights into hot sections in the guest. > There is a big difference, PMU counters can be used to infer general things about a system without any extra information. That's something that could be used by a monitoring task or someone looking at a guest running a known workload. But for BRBE you need the binaries, mappings, scheduling events, thread switches etc to make any sense of the pointers in the branch buffers, otherwise they're just random numbers from who knows which process.