Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2020632rwd; Fri, 9 Jun 2023 05:44:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6fiobSYuonxUPL8bC/sNFB8HI8V5RNf4X/Uaa5ErPwMM555NdFLvbvatZUZ9bwM+mQ2J8k X-Received: by 2002:a17:902:da83:b0:1ae:4562:14f1 with SMTP id j3-20020a170902da8300b001ae456214f1mr991046plx.9.1686314683695; Fri, 09 Jun 2023 05:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686314683; cv=none; d=google.com; s=arc-20160816; b=ziDVfghKq59fFGBLDJGgG1nZPfhl9hQo5gTSMBz/U88FsKv+z09DtSP0Sw1f/tw1JB q++/ZvNE9unfTMQ0ywHzSMXAhtTCO050YCXEV+7Sc4SQoAlLSm7ItYhhqQLqFW4eJ7EN 5dtYQa2awelnmIXF+K0rEg5F4GqygCrlM6OJRU7WD8TmO+B4fYnikTh1TaUMZaes5ArL e1mQEqUWuJdoX66FzAIY9bArKLPiySFhPaC4l0fw/hVi/xyIQNnTQ2zfNJEyxqmh6itO DBKVy0+83u0dEmooV+xP6v3AoRp3VQaZkFFXkTH8TRU3oKI4M0lOmKHTRHZpSa+Cr1XH YfQg== 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; bh=Dr2tGvhJCeM8Lh6sFt3LWjFOL3at4uroe0AtpkB06to=; b=O2Ao8NQ8ENe6qL25sec3Jao+o1+jahsSbd2ESu1dWpD/jmcL8R+TMLU507XVzGnaEX ODwCAMcXEFEh77xvJVI3mSEMacKIuWZ9rgdnIKPZekQs6838TOW/MUYliLWEddVG7NMD wfpWdp6nvG2Y6+CqktKOe6d6YHOe5M5HCQ/jIQM7J5T5dc7GXekiszD6v3a3whRxomnW J2xLluUG075YFPiEaSy/T5Q20XRTmxZiSOQc0ESxZgpsNvBcOpznQd4kG5qET92zkioJ bdjbko9vFrI+Y+vltlt2iTIQ1PIhcNQEjPOsPkRE/BUOnIamktMyEuxTXuu7wixmIF6L AHEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a170902e84800b001ae8c22791asi2701671plg.477.2023.06.09.05.44.30; Fri, 09 Jun 2023 05:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239626AbjFIMhm (ORCPT + 99 others); Fri, 9 Jun 2023 08:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjFIMhl (ORCPT ); Fri, 9 Jun 2023 08:37:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00F7A1A2; Fri, 9 Jun 2023 05:37:39 -0700 (PDT) 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 04D55AB6; Fri, 9 Jun 2023 05:38:25 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.38.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEE0D3F6C4; Fri, 9 Jun 2023 05:37:37 -0700 (PDT) Date: Fri, 9 Jun 2023 13:37:32 +0100 From: Mark Rutland To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, Mark Brown , James Clark , Rob Herring , Marc Zyngier , Suzuki Poulose , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org Subject: Re: [PATCH V11 06/10] arm64/perf: Enable branch stack events via FEAT_BRBE Message-ID: References: <20230531040428.501523-1-anshuman.khandual@arm.com> <20230531040428.501523-7-anshuman.khandual@arm.com> <006be03c-43da-6482-6bc4-83fe65dcd706@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <006be03c-43da-6482-6bc4-83fe65dcd706@arm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 09, 2023 at 10:00:09AM +0530, Anshuman Khandual wrote: > >> +static u64 branch_type_to_brbcr(int branch_type) > >> +{ > >> + u64 brbcr = BRBCR_EL1_DEFAULT_TS; > >> + > >> + /* > >> + * BRBE need not be paused on PMU interrupt while tracing only > >> + * the user space, bcause it will automatically be inside the > >> + * prohibited region. But even after PMU overflow occurs, the > >> + * interrupt could still take much more cycles, before it can > >> + * be taken and by that time BRBE will have been overwritten. > >> + * Let's enable pause on PMU interrupt mechanism even for user > >> + * only traces. > >> + */ > >> + brbcr |= BRBCR_EL1_FZP; > > I think this is trying to say that we *should* use FZP when sampling the > > kernel (due to IRQ latency), and *can* safely use it when sampling userspace, > > so it would be good to explain it that way around. > > Agreed, following updated comment explains why we should enable FZP > when sampling kernel, otherwise BRBE will capture unwanted records. > It also explains why we should enable FZP even when sampling user > space due to IRQ latency. > > /* > * BRBE should be paused on PMU interrupt while tracing kernel > * space to stop capturing further branch records. Otherwise > * interrupt handler branch records might get into the samples > * which is not desired. > * > * BRBE need not be paused on PMU interrupt while tracing only > * the user space, because it will automatically be inside the > * prohibited region. But even after PMU overflow occurs, the > * interrupt could still take much more cycles, before it can > * be taken and by that time BRBE will have been overwritten. > * Hence enable pause on PMU interrupt mechanism even for user > * only traces as well. > */ > brbcr |= BRBCR_EL1_FZP; Thanks; I think that's a lot clearer! Mark.