Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4860DC433FE for ; Fri, 3 Dec 2021 16:22:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344607AbhLCQ0T (ORCPT ); Fri, 3 Dec 2021 11:26:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352758AbhLCQ0O (ORCPT ); Fri, 3 Dec 2021 11:26:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C97C061751; Fri, 3 Dec 2021 08:22:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2A3DDB826AB; Fri, 3 Dec 2021 16:22:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D24B9C53FCE; Fri, 3 Dec 2021 16:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638548566; bh=o8Ov1KCD5JfskNb1Eq6DEEuQ+aufK6N7Kjel5xo5kIc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MAekSrzSOYJG8ymGp0Tbfx6eVazph56R1R1JTsWiX0TvjSLNcckwz+T/wlIbtJVbw eqKDvBzozemVRTm69ivbUJVkrENLUv1Eeet+8h5c2TcMbMrLu0c6jdGBk1jf0/bI0h K14gz4kE+Tddjlo2pICJbf5tYzKKD9+BYNmlKEK7+EZtBwARTFREBUvFyTjSxza8ZS 2klyYmwARmpbRNh0UavNVMdIwDUwnG8LCcDocryFOLW51x6xOE4HPGIfRYd/ULD+ZE 667lL+LwbtPHMKnA3pTAG9isTVu38sBkd+N+DV0gBRVTM28YiuCWQguTxgfIbjHW0q Qr/WodEzs4BLg== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mtBKe-009dus-GP; Fri, 03 Dec 2021 16:22:44 +0000 Date: Fri, 03 Dec 2021 16:22:44 +0000 Message-ID: <871r2tmze3.wl-maz@kernel.org> From: Marc Zyngier To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Hector Martin , Sven Peter , Alyssa Rosenzweig , Rob Herring , Thomas Gleixner , Dougall , kernel-team@android.com Subject: Re: [PATCH v2 8/8] drivers/perf: Add Apple icestorm/firestorm CPU PMU driver In-Reply-To: References: <20211201134909.390490-1-maz@kernel.org> <20211201134909.390490-9-maz@kernel.org> <877dcnm2wt.wl-maz@kernel.org> <875ys6lype.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/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) 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: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, robh+dt@kernel.org, tglx@linutronix.de, dougallj@gmail.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 03 Dec 2021 12:04:35 +0000, Mark Rutland wrote: > > On Fri, Dec 03, 2021 at 11:22:53AM +0000, Marc Zyngier wrote: > > On Thu, 02 Dec 2021 16:14:01 +0000, Mark Rutland wrote: > > > On Thu, Dec 02, 2021 at 03:39:46PM +0000, Marc Zyngier wrote: > > > > On Wed, 01 Dec 2021 16:58:10 +0000, Mark Rutland wrote: > > > > > On Wed, Dec 01, 2021 at 01:49:09PM +0000, Marc Zyngier wrote: > > > > > > + state = read_sysreg_s(SYS_IMP_APL_PMCR0_EL1); > > > > > > + overflow = read_sysreg_s(SYS_IMP_APL_PMSR_EL1); > > > > > > > > > > I assume the overflow behaviour is free-running rather than stopping? > > > > > > > > Configurable, apparently. At the moment, I set it to stop on overflow. > > > > Happy to change the behaviour though. > > > > > > The architected PMU continues counting upon overflow (which prevents > > > losing counts around the overlflow occurring), so I'd prefer that. > > > > > > Is that behaviour per-counter, or for the PMU as a whole? > > > > It is global. This will probably require some additional rework to > > clear bit 47 in overflowing counters, which we can't do atomically. > > Ah; I see. > > To calrify my comment above, the reason for wanting the counter to keep > counting is to count during the window between the IRQ being asserted and the > PMU IRQ handler being invoked, and it's fine for there to be a blackout period > *within* the PMU IRQ handler. > > So for example it would be fine to have: > > irq_handler() > { > if (!any_counter_overflowed()) > return IRQ_NONE; > > stop_all_counters(); > > for_each_counter(c) { > handle_counter(c); > } > > start_all_counters(); > > return IRQ_HANDLED; > > } > > ... and I think with that the regular per-counter period > reprogramming would do the right thing? Yup. It looks like this works just fine. Thanks, M. -- Without deviation from the norm, progress is not possible.