Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1566322rwd; Thu, 8 Jun 2023 21:46:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51SpFthKQMRGtviMSp24x6ZHEi2otV+VVxEoFOIDyhaD+pr8se8ZiwD/9vzq0CUVwLwAbj X-Received: by 2002:a05:6358:c529:b0:129:b8ef:cb18 with SMTP id fb41-20020a056358c52900b00129b8efcb18mr308360rwb.24.1686285982227; Thu, 08 Jun 2023 21:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686285982; cv=none; d=google.com; s=arc-20160816; b=UnYabOAeCtvI2I6yZRGxhrVWzTtnEjoYXyAWqWrhzj0rhSP1eN0MMPnhm9lB89rhM9 UndQksTQTGfF3/uy+3jujLe4LUMFxJ2ErwHBk0CBI+oFR+6yO01Dj/9udW2J8DgvnOsC FkyoGehPeuGgO94qaptYpcohAs0Lm1Jc7JIS7Dcs2tKsO2IBK0qkLYk1tElAaJbi4DK/ uPc7ZafaACJoaDjpuQ2bCgDafZQCupYcFlc1MhWf2KKLbQzOfxb/hnDmxvc5/eMjQTsA wWpIuHpaSyS78ZVU7dJgpC/dIJtXAVTiJ3j/Q3nCcxfzjeLLs3kxU9MaZ1LA4vuVHxAB MX4w== 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=Eqwwmy3myXe1eInB5h0Xl3V4kC8jitTdMQUXND1mDtE=; b=UJl+Lt8wff2fu7NjNbKgdtqv2JQdpPCdgCJ/G+SFCACIl19kmqJXQQ6CcIw/8glIgZ bnjgCeGpZ3BqxwsgQsH+3D2hpul9pCqoMHwGzHybAffRbSGIgGUigtMhbx1W01jEW0NB 6lEqYluVRFo77yuXQ3O5+v9RlZ5QOPJSD9fr0glIR00d+55GFmd5h9Yu2B4FMYsX06CL QjvgdgCCXeNDZzR8us9+r58n22saDIE7N7QzJsQJtWBshscqhgQNmNs1JOacktVYLggA pyista5xl9D+C3WLoK4yyEI5Y58m4JObPdlw3dJjGFHy5wfKaDgaCR7R0/A8vzpRV8nl 6bfQ== 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 s204-20020a632cd5000000b00541cfaad532si2015603pgs.613.2023.06.08.21.46.10; Thu, 08 Jun 2023 21:46:22 -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 S237871AbjFIEa1 (ORCPT + 99 others); Fri, 9 Jun 2023 00:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237095AbjFIEaT (ORCPT ); Fri, 9 Jun 2023 00:30:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDDC330C1; Thu, 8 Jun 2023 21:30:17 -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 9F847AB6; Thu, 8 Jun 2023 21:31:02 -0700 (PDT) Received: from [10.163.44.201] (unknown [10.163.44.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 988423F587; Thu, 8 Jun 2023 21:30:12 -0700 (PDT) Message-ID: <006be03c-43da-6482-6bc4-83fe65dcd706@arm.com> Date: Fri, 9 Jun 2023 10:00:09 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH V11 06/10] arm64/perf: Enable branch stack events via FEAT_BRBE Content-Language: en-US To: Mark Rutland 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 References: <20230531040428.501523-1-anshuman.khandual@arm.com> <20230531040428.501523-7-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 6/5/23 19:13, Mark Rutland 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; > > It's a bit unfortunate, because where this matters we'll always be losing some > branches either way, but I guess we don't have much say in the matter.