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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39EF4C4167B for ; Wed, 29 Nov 2023 10:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RD+gC7tEwDS3lP/VVkJbKTcwIk8oQO4kbawjoWDwvQ4=; b=3+tUUxbYXcIlPf dXqrCNHJkkc2Tgh7BYKpbi/BEQ5VIHrB9aPE2tTqsFanO5rtCYq029+Zf+brie0QyFMXZWiwRDA+w w9jdKeP/He+THUng77Ng2qz4am4xl01gZyjI0lgO/cBZTxSnyloJQHmGEhTcj2U+zCUBJSf381/V1 baTWGhl5ZtuTl4bcvRrqPlttJ/z/ePcQoo5rbbbQ5EA0bwyzJp4wbs715DPVQNHLALewd3uFb4NuO Y7DNF9Ayr2LMj9sLCbU5mueBhPXs686nNjJp8OFXBtV431s1YSBJe0Th+bT49T/8eI39p9aq66x6R ADe7T3kgjOA9yA3jv/3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8IHC-007ssF-1p; Wed, 29 Nov 2023 10:58:42 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8IHB-007ss6-0i for linux-arm-kernel@bombadil.infradead.org; Wed, 29 Nov 2023 10:58:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KigNA1TZVqFp7ATaA0tVgaRfg+vW2ATtcc+1Uw9papU=; b=Q2NbVUFMfdymSbxHURADyz+2dQ gbloL7jZqkpqjodYwok3ql66wYy7cdufNcJCC2EZfTYZLQyR/x16CzXMCFWFAQ3xgYLkmVqdyBUVL SD/WEF1Px2v/ctRMyjh4QZt853ckle8P++uVw2YAyyTUTNP5IwmiX0ev188ZEFO1lJtV6566KeSGu azaZQxJrOH6ovUcIMOTCL4Me2IJuKOJxtMyQroIbFOezolfDgAK2wHEhkImI+LwO3rXB5XBgHi7tU EGgIQAFXLUKMXOUSyXIwwYAspPX0mlLRGJs0LSa0MlK/S9XbzLVn6AUhHZ0SfWb53PlCWcSCwHUBa Bz6/9MZA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1r8IH7-000Jr8-0G; Wed, 29 Nov 2023 10:58:38 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id B7D0B300487; Wed, 29 Nov 2023 11:58:36 +0100 (CET) Date: Wed, 29 Nov 2023 11:58:36 +0100 From: Peter Zijlstra To: James Clark Cc: Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Yicong Yang , Jonathan Cameron , Will Deacon , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH RFC 2/3] perf/x86/intel/pt: Add support for pause_resume() Message-ID: <20231129105836.GF30650@noisy.programming.kicks-ass.net> References: <20231123121851.10826-1-adrian.hunter@intel.com> <20231123121851.10826-3-adrian.hunter@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 29, 2023 at 09:53:39AM +0000, James Clark wrote: > On 23/11/2023 12:18, Adrian Hunter wrote: > > +static void pt_event_pause_resume(struct perf_event *event) > > +{ > > + if (event->aux_paused) > > + pt_config_stop(event); > > + else if (!event->hw.state) > > + pt_config_start(event); > > +} > > It seems like having a single pause/resume callback rather than separate > pause and resume ones pushes some of the event state management into the > individual drivers and would be prone to code duplication and divergent > behavior. > > Would it be possible to move the conditions from here into the core code > and call separate functions instead? > > > + > > static void pt_event_start(struct perf_event *event, int mode) > > { > > struct hw_perf_event *hwc = &event->hw; > > @@ -1798,6 +1809,7 @@ static __init int pt_init(void) > > pt_pmu.pmu.del = pt_event_del; > > pt_pmu.pmu.start = pt_event_start; > > pt_pmu.pmu.stop = pt_event_stop; > > + pt_pmu.pmu.pause_resume = pt_event_pause_resume; > > The general idea seems ok to me. Is there a reason to not use the > existing start() stop() callbacks, rather than adding a new one? > > I assume it's intended to be something like an optimisation where you > can turn it on and off without having to do the full setup, teardown and > emit an AUX record because you know the process being traced never gets > switched out? So the actual scheduling uses ->add() / ->del(), the ->start() / ->stop() methods are something that can be used after ->add() and before ->del() to 'temporarily' pause things. Pretty much exactly what is required here I think. We currently use this for PMI throttling and adaptive frequency stuff, but there is no reason it could not also be used for this. As is, we don't track the paused state across ->del() / ->add(), but perhaps that can be fixed. We can easily add more PERF_EF_ / PERF_HES_ bits to manage things. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel