Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4498792rdh; Wed, 29 Nov 2023 03:17:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsDJL1xuIQUFhIxzW2y/5vRf0wVzOd78mFDL1uVdcrKiFEpcdSDZfn5sM0H8bo8gHwygtR X-Received: by 2002:a17:90b:1803:b0:283:2932:e904 with SMTP id lw3-20020a17090b180300b002832932e904mr18477772pjb.2.1701256639203; Wed, 29 Nov 2023 03:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701256639; cv=none; d=google.com; s=arc-20160816; b=xGF317Ut74jPGk1JrRkVXIv9BtpuxSEuD/WWDC+N0VqGUW0jQxHKBMKGrQd+SZh1e/ FmKw4A8/S2E1xONwr9jPF4c5jOu5BDgS7SzF5R/TJiYKtCqECOzi+M1ujNWirfC6NVi6 dXv8rTtaw76M/jwP0WNgwQpG5YOF28H03OKtITmuquJzT4kKB+RrTSuIKKfjARdpqGcA wOhzq3zkXBK0Lw2iKgCxbbbG5yUxL+2xsc+w5rtPl1XFUTd5++/7cSWNmcGj+YQbr5xJ 4dmELJH6gT5Lvpv15Cqg6f+XxfRWOq27YmRg9LYZbjIluKlM4FJEiKO5BS0Q7FI4TTL4 no7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=KL1lBWVIzxkjprWFSXwKYqDjVQmv6WGW0s2D7LRZmp0=; fh=E1n50UHBtrIj+0a81aVZOQS4ukZ9EcEh2/J2sq9nrAE=; b=WMzt1rZKX9RVX2fP/iN8zovyamACSk/iD5rgDSB9fijN+gXnc6GZGgs9Vl5870HKxS GKzCpTKSgu80ffRS3V+pLzJDMJXguEEeF1JQA/y5hb6MV9pLONOj2nXSy2UjwDCV77W2 xqDVUAlW/GApOa4E16wy+XWroHBZy7ha6/BJMO/d4ic+mpNyira5McEfWxYJ3LSL/Fq5 pg1EsrowalatA1Y/tQDITMy7ZmxBT+gRBTQnrNnayVCi+rzlByHhkpHSvX84ZOJMINFy d84Ps2Pi28vnNi8rzWZ3ku1cWRbZ/8nQsu3uW/7KkcaLBIHyfn1s4nS7R1YhH/Q9/LlH Of0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GaDH74bV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a13-20020a17090ad80d00b0027769032e57si1109856pjv.52.2023.11.29.03.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GaDH74bV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6FC7D808577C; Wed, 29 Nov 2023 03:17:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbjK2LRH (ORCPT + 99 others); Wed, 29 Nov 2023 06:17:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjK2LQg (ORCPT ); Wed, 29 Nov 2023 06:16:36 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 047EF272C; Wed, 29 Nov 2023 03:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701256554; x=1732792554; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Snyvtn6d97iK8ZN3iP+Df433igWMIBGX4EIT1w9z9j4=; b=GaDH74bVv0VtUgeiGOmUksgtSgRYeVqWZJ1EbmEgRFW7dWJ9j6mXGf74 QMPibST3a8UlYSqGFTKhMyYzyNYHWgjBIw0N1iGJl23FlKkitYVMef1jM JBZwlXssoFudaKOxIgAwXSeuuhq91P+buYsdZ33/OJlhpWHpadnwl0fun koms/we61XAuymQfR9hwv/eos35AUdpXg/iwRsvLeHuk+OAoY7z14K0NF ApchvqNpqqaZmTR4W0WuiJOce6m0t1wQPE9YsdsL5wfcb3eI/wl4bjp8u xDDYhyWykvfYOxAAf7RY9bqPqcaxxmfA4xJNlIP4gHG4gJ6undZh1511x Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="6411062" X-IronPort-AV: E=Sophos;i="6.04,235,1695711600"; d="scan'208";a="6411062" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 03:15:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="1100493916" X-IronPort-AV: E=Sophos;i="6.04,235,1695711600"; d="scan'208";a="1100493916" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.43.226]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 03:15:47 -0800 Message-ID: <842ce784-fbd2-4667-a5f7-aaa10a1108dc@intel.com> Date: Wed, 29 Nov 2023 13:15:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 2/3] perf/x86/intel/pt: Add support for pause_resume() Content-Language: en-US To: Peter Zijlstra , James Clark Cc: 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 References: <20231123121851.10826-1-adrian.hunter@intel.com> <20231123121851.10826-3-adrian.hunter@intel.com> <20231129105836.GF30650@noisy.programming.kicks-ass.net> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <20231129105836.GF30650@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:17:17 -0800 (PST) On 29/11/23 12:58, Peter Zijlstra wrote: > 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. > > I am not sure stop / start play nice with NMI's from other events e.g. PMC NMI wants to pause or resume AUX but what if AUX event is currently being processed in ->stop() or ->start()? Or maybe that can't happen?