From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795016153; b=i5obx8YVDr1z1oseKIj6Ksi2tiSCHhJjrytnY0y2oxi4AMFApEY6kW7T19eOrkXrLJEc lHj34DNTPQZL5yZQ3jvi1eBLGdkE/T2i/6ESiDd/MEkr0vbM8tF+3kXkRsrVtA7IO3Vsa AAOlvkmlfslUL85Ev+WTbcFpT7lClHQvC+lZxOnwmflQhAyx32pkIQLCaMywJ/WWdtUXQ e/+kMtLObtkGnA7WTTkhFmMdWiTaIWqiDJBRGPhYIypisiZzfIpEKEYEHFZWco/wxzC17 xMphBnWJssDdkrS93ZRdone6k+pzBjiUa7ssH1GMJfr9BhN4pGv5o7A9IkldDrm6XxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795016153; h=Received:DKIM-Signature:Received:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-SA-Exim-Connect-IP:X-SA-Exim-Rcpt-To:X-SA-Exim-Mail-From: X-SA-Exim-Scanned; bh=PhnMB43dmhhOP+uEehjfYbWyisR+iluGA4pbiWpu2q0=; b=oYlkJgsDpX+kh6FGSKUYt+2vs70RaG++5xmHuIef8wjKNV1UuiqbCh1OSWfjEaMyrnLU sFr1IaWa1Ly3/TuGwz8tbUGK1juMiSp+LZJ0MPVcXbMNfZuTOVraDFhcyLDYscIubWgVl 2sV5NrdLIPhJ/8eQ7u3mXUyPebOB1SSVXhKrYeKC0Hv/wkqnsuYBJsOJI4V3YrVdpAmDu /SvqJ6MpSP6v0YGxv0MEMFThpFia/tDph0BN/+TLDm7nLlggTDQCKdz8RUaaVAaB7pvq+ 4ovCOqv2V6HEDwvzeHJwtUsMRWMP3/vFFpKdRGzaSRhM4Rd3I7zy9MtJlEukBGuCcvQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YEiwg4VY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83D72606A335; Wed, 18 Nov 2026 15:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YEiwg4VY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D4D01F000C6; Wed, 18 Nov 2026 15:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795016153; bh=PhnMB43dmhhOP+uEehjfYbWyisR+iluGA4pbiWpu2q0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=YEiwg4VYtGuqGQJP5AIPXvqqK8mL8uNE+40MF1Ru0rtQdXp4Xd4OzqIn6c3xS/zz9 Tj24RvH6VjLdr9XTcDeGOKiexcgoAP3L3NGDGjhbmlmlubZq3ytpi2LJUp6Qi8cdqX uxiMy4jgVMCaDWY5OOUDlx2vkx1rMTEt/YycTBdLzayKz/LYgULi9ApJ17qghFnQ8Q WfCBGXbeJBGzc1d9OGXfDB7+wUSZgw1ypZS+7uJPXhXLpJtmeXMqC60z7h59GKVlos W0yxzBWnuGgX7UKaWOw05nuX4ZdwPYXr/IJGp/zkHNKDAafpU4vlR799d26p8xbRup O/e8Y8TTy3IAg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xThhP-000000000We-1Pzi; Wed, 18 Nov 2026 15:35:51 +0000 Date: Wed, 18 Nov 2026 15:35:50 +0000 Message-ID: <8633sy17ah.wl-maz@kernel.org> From: Marc Zyngier To: Myria Sarvay Cc: Will Deacon , Mark Rutland , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sven Peter , Janne Grunau , Neal Gompa , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Yuvan Shen , Nick Chan Subject: Re: [PATCH v2 03/15] drivers/perf: apple_m1: Support per-implementation event tables In-Reply-To: References: <20261107-m3-plus-pmu-events-v2-0-acf1e78da039@gmail.com> <20261107-m3-plus-pmu-events-v2-3-acf1e78da039@gmail.com> <864ide1hb1.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: myrialsarvay@gmail.com, will@kernel.org, mark.rutland@arm.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, sven@kernel.org, j@jannau.net, neal@gompa.dev, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, yuvanshen09@gmail.com, towinchenmi@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 18 Nov 2026 13:36:23 +0000, Myria Sarvay wrote: > > On Wed, Nov 18, 2026 at 11:59:30AM +0000, Marc Zyngier wrote: > > > > Looking at the following patches, I feel that this series is taking > > the long route to get to a relatively clear point: most of the > > invariant that we relied on for M1, slightly relaxed for M2 (counter > > width), are even more relaxed for M3+ (event width). We therefore need > > to indirect things. The way you do it is to mirror the current setup, > > with a whole set of callbacks per implementation and a bunch of > > additional helpers. > > > > But instead of having a set of helper functions, one per > > implementation, with an ever increasing set of parameters, it really > > feels like we could do with a more data-centric approach where we have > > a single data structure describing an implementation, containing all > > the relevant data (pointer to the event mapping table, flags, bit > > indices for the user/kernel/guest/host attributes, and so on. We could > > then have a single set of callbacks that work on everything. > > > > You could convert M1/M2 to that, then just add the relevant > > descriptions for M3+, which should just add data and the init > > functions, nothing else. > > > > Does this make sense to you? > > Hi Marc, > > It does make sense, and should reduce duplicated code, I'm just not > confident I have the right idea as to how to implement it. I don't want > to duplicate a lot of the generic arm_pmu code, so it looks like it'd > probably have to be modified to allow passing a hardware specific detail > struct to all the callbacks, likely stored as a new field (void *) in > the arm_pmu struct itself. Does that vaguely sound right to you? I'm not sure we really need an extra field. arm_pmu already has a pointer to the platform device (pmu->plat_device, also as pmu->dev.parent). It means you can use dev_{get,set}_data() on the attached device. That's a bit of pointer chasing, but nothing that we can't easily swallow if placed behind a convenient macro. > > Also, with this rewrite, if we're going to make the code a whole lot > more generic, and take hardware specific data from a static struct, > would it make sense to rename the driver/all the callbacks while we're > at it, now that we're adding a lot more than just M1/M2 pmu events? I don't think names matter much. If I had my way, all variables and functions would be called "bob". I'd suggest you look into the refactoring without worrying about the naming, and if that's the last problem we have to solve, we'll be in a remarkably good place! ;-) Thanks, M. -- Without deviation from the norm, progress is not possible.