Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4487689rdh; Wed, 29 Nov 2023 02:59:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFelbU9BbWsU7/k4GwmP/k59kw/ui5NmkZlHDIL05Lkqje8+o1RU4qfYfw4U1Uj9z1J6iuJ X-Received: by 2002:a17:902:efc5:b0:1cc:32b7:e5b9 with SMTP id ja5-20020a170902efc500b001cc32b7e5b9mr17581757plb.67.1701255577959; Wed, 29 Nov 2023 02:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701255577; cv=none; d=google.com; s=arc-20160816; b=Vl58cmGt5zhA9jLZkmVMsQgW6eeXTaJliFAFy65giQeGuo9ytpWlwpsJQsSb4ZV1Ij r3aCrlt7rJZghmw4l3RZE6fHPnGh8AYGTFJ/L6d8+B7jI06GhzG/rDdAKy/sFI4CVSaK N3pSIF7SYnY3gDA6xKKZfTNgwUHjUI2Vngch4/OUhYQxOeGOfR2WWLcwehJ/g1cIRoFg kM+q9PCeszxz9DikCGYplZCna2XMkyxpuCJ3omj4UX/dNy26158mMwTXrBm2l+Mh4GFc SqUgoVfYqrBWxgefqMbtid6wIaSX2Q25RqhGxT4VX2T3/MNM/aqqvMei/k5ey4oF8Q2X dQoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KigNA1TZVqFp7ATaA0tVgaRfg+vW2ATtcc+1Uw9papU=; fh=BSBYHoVGaYZ/C53vH4IUohKqBB7En35K3txGf//c7uE=; b=WMUsZlKK8lqggTsUAe3tF1MhM3YeuF8gXH72+WX2mwR1vVlkeo+v/FAuQJ8U1z8M8E qvElXY/FJdYmJ+gc1VtvikRRKnF+yIRuaqSFDa0PTY7diFUz50nItMlSwnhyP7aLOLfO AdySwp0cuWeT6f+/5fHo/cowB8v3mVw7RlMIGBfVVM+15S163Fv7igmzaw8Ml3h7d1NP nAhCXzHaDsG5HDa3uzxJ0zh+b8njD7KZQNBgOnfRpa4y/9/zudjMcK1XVKWu96MfDob5 gWF8D8pWzAH6EOxjaGb45+FBkHill1ub7Pr8Hf+ZbO2qxrR6tFVfwLEs0Tb+XyBp7r8A x5Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Q2NbVUFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l14-20020a170903244e00b001cfdb31375fsi5684907pls.368.2023.11.29.02.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 02:59:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Q2NbVUFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 78B75803BA9F; Wed, 29 Nov 2023 02:59:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjK2K7W (ORCPT + 99 others); Wed, 29 Nov 2023 05:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjK2K7V (ORCPT ); Wed, 29 Nov 2023 05:59:21 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 286D295; Wed, 29 Nov 2023 02:59:27 -0800 (PST) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 02:59:35 -0800 (PST) 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.