Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3090952lqo; Tue, 21 May 2024 06:45:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpDowacCU6hGRlGliJNHHEUl2L0A7oG80v5NlG5NCWccC3/2PLep/lqBHPsgEcmxm4so8yZEcr/j6yZvDM380/+yYrdTHogpBzoMYxRw== X-Google-Smtp-Source: AGHT+IHFh3SfW4TQdJY1BB9s53WnxMzfzUEW9SxhNNuA+julYY0g79vHPBZyV+SBTogPxUFvt8Wp X-Received: by 2002:a17:902:a710:b0:1ed:7cdf:f331 with SMTP id d9443c01a7336-1ef44050e9dmr303154865ad.68.1716299113811; Tue, 21 May 2024 06:45:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716299113; cv=pass; d=google.com; s=arc-20160816; b=0y7IuExd/Dj/Xb+Sm/kATfjzhKS2YDUPL4O/hCkisVMGVadmlTpnIFoTcasjyFqF5Q /FgjjbjICWQ/1EXMeDLPgrPZJgU7IynJiqDmiodTUS5C1mUbedIRTf2APyQ4izkT1VL/ wkwCAxFiSiLwpeyX16NThRZ8puPrkXmmHjppbMxZwwAyG+VxtinXmzpxzyXknfJD6W7u rBbtjqTmot4BmMTzb9HBjxqOgBwuRPSTSHI8CASzLtw69JhXPZLNXTMA+AvQtkGkm7gX VPqY6uwrQmUTjVBkBJa8h6qwgxAkQEQnYL+LW2P0mB8JGX13MUAhbDYieIY4Jl4y/R5u eNAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=cPOvCgQ8WRhATJImY1hDNo4wiSwN4Wg9sRXtZLgNmQo=; fh=XyYG+DTEv7U3MexF6seUqbajj2uqohswa3kNzR7G4T8=; b=gDqY23zRjkz47s/Y/4/mUBIZ6e6WAMsih1LeRo3hxE+D7Lhe5a5L2AkPGdE3G0WlNh 0FJ36X61iIIskFayHesSbbCB4czAOK5FdVIGTzbhqxBsJHOuoJHOZm+K6VxlZ97adUMv Bn0syJFTOPVTXppwCoER8NqM/q1gGRBybahsbVW0xRuJaMUK7418WFqMgGRBh33RHsyp ydDGuC4Vuugt+O1LVTzjJbMSwpgEtV6KK61QgQxKyMudp9FrYUpaZvCKZVD+Y7ZV6rdi 9VfZGAqR//Gr3kCCg4gd2A5fjVdfl8JJuyYOu2r9DhK/oK+gLTMw+M4XmPqhVfLafmOk xtAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-185031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f2f95b5c0esi46441475ad.114.2024.05.21.06.45.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:45:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-185031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 754BAB223FE for ; Tue, 21 May 2024 13:45:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A19787CF39; Tue, 21 May 2024 13:44:56 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CF3471B48; Tue, 21 May 2024 13:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716299096; cv=none; b=hkAH603DTHaZSg3PVACUvYIMWUIxDDF8rZE2c6D+3SQ4K3f/9c3arUOBaPNuElyeu/t9y7WfQh7SEWV+1POlUOe5ZzovMDuNlxDA3ySp2H2RTHc39HJpgtE3vSrYpfmEoRjHmzsaKGRataHZToewoSLpI6WJllZ0A7M/CxCaQNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716299096; c=relaxed/simple; bh=H48cizhNNLDxjU+31xIZUJnQnKmSiED2ZFACjcWGzz8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L9oQofuP5h3u8Q9so1K7nIJ2RsmE4+AmNFr+19SF9OHBGcNPMD06vt8IpWbywDvUVINBpABtyoC/F4whbfUkQ42jZqARMVbl12stc+bx1PZ0E5kPqPdKLvcwY+Vj6i1hb65vShQb/5LK6nD8F23Hg3JubkpVgAVeImQsyIb15so= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 F2DACDA7; Tue, 21 May 2024 06:45:17 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB4663F641; Tue, 21 May 2024 06:44:51 -0700 (PDT) Date: Tue, 21 May 2024 14:44:49 +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 V17 3/9] drivers: perf: arm_pmu: Add infrastructure for branch stack sampling Message-ID: References: <20240405024639.1179064-1-anshuman.khandual@arm.com> <20240405024639.1179064-4-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240405024639.1179064-4-anshuman.khandual@arm.com> On Fri, Apr 05, 2024 at 08:16:33AM +0530, Anshuman Khandual wrote: > In order to support the Branch Record Buffer Extension (BRBE), we need to > extend the arm_pmu framework with some basic infrastructure for the branch > stack sampling which arm_pmu drivers can opt-in using a new feature flag > called 'has_branch_stack'. Subsequent patches will use this to add support > for BRBE in the PMUv3 driver. Please, just use ther *exact* wording I asked for last time: | In order to support the Branch Record Buffer Extension (BRBE), we need to | extend the arm_pmu framework with some basic infrastructure for branch stack | sampling which arm_pmu drivers can opt-in to using. Subsequent patches will | use this to add support for BRBE in the PMUv3 driver. At this point in the commit message, the 'has_branch_stack' flag doesn't matter, and dropping the 'to' after 'opt-in' makes this painful to read. > Branch stack sampling support i.e capturing branch records during execution > in core perf, rides along with normal HW events being scheduled on the PMU. > This prepares ARMV8 PMU framework for branch stack support on relevant PMUs > with required HW implementation. Please delete this paragraph. > With BRBE, the hardware records branches into a hardware FIFO, which will > be sampled by software when perf events overflow. A task may be context- > switched an arbitrary number of times between overflows, and to avoid > losing samples we need to save the current records when a task is context- > switched out. To do these we'll need to use the pmu::sched_task() callback, > and we'll also need to allocate some per-task storage space via event flag > PERF_ATTACH_TASK_DATA. [...] > /* The events for a given PMU register set. */ > struct pmu_hw_events { > /* > @@ -66,6 +78,17 @@ struct pmu_hw_events { > struct arm_pmu *percpu_pmu; > > int irq; > + > + struct branch_records *branches; > + > + /* Active context for task events */ > + void *branch_context; > + > + /* Active events requesting branch records */ > + unsigned int branch_users; > + > + /* Active branch sample type filters */ > + unsigned long branch_sample_type; > }; At this point in the series I understand why we have the 'branches' and 'branch_users' fields, but the 'branch_context' and 'branch_sample_type' fields haven't been introduced and are not obvious. What exactly is branch_context, and why is that a 'void *' ? I can understand if that's a PMU-specific structure to track the active branch records, but if so I don't understand why 'branch_sample_type' isn't folded into that. Mark.