Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp465850ybx; Wed, 6 Nov 2019 03:31:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzzOEW+8V5kzDr7T3lD3wN/djyfoBtKKf6RCpJHiNcfQzNw5hzif2XzMZ2rprtkdvG7jTPi X-Received: by 2002:a17:906:4913:: with SMTP id b19mr12654198ejq.61.1573039912074; Wed, 06 Nov 2019 03:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573039912; cv=none; d=google.com; s=arc-20160816; b=ldWcBvxwjPDSFZ31vAFTrC4oxZc89YJ5ob30VsnRZR4TOScwBNr+TWBBtde6SnPDZb TbORms4bjeOr35pNbBuo14W3rmPpw3zz9/ouf013IDPLXexVSzPeXdx9VKclxsglAyj5 K5xxKaj7O8A00l0aeh+2lA8nEuRGMnPG7L6A5EWtf0E02FDbV9lfIlpp0IrCrCuU8fa3 BPjtC3ZbQhokgwzM3Clqvig6uDoR30yqmbrCvtjGt3G6mfiDp7rrtmkn4MzS4s7BmpE7 XpYbDiHdLxpQ8O0eH5rtUkR8oF8qRXbvc9dNQwneFCxjH9cDV8SwhF8hM9DNn19LWT56 qZ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kAXJJYUXqVHbtA0ESs6TTAR2rRcOUFiJHBJExBkfHLA=; b=mjcm+UkhwZJD2IHxC2olh8Kj2TrrbcpfUV3F720LLiLSDmJoz/kg0/1qQ6xn7LBYO9 ZFTB0JF+YjWepS7CLcGEFiquUROA6IeP24QsYLsQcfppBrs/jo63k0frjkQjjyWieaUC cU+0cWsWUwDRVzmY1H8UjA5BFDMv5lfm+Ar7XDB5k87NbAhdBkpyBnwi7X2lV3TOKXhS 2Ggtm+R+rxrLTmn/efYdKNhIVWRjLuueR+hjrtOHoh7xcLkMNETUWnri7QAqzVSRXf4G rPw6N4b9scrW9XttFq8syB7bYa+HnQvys3RWviW9GL+CBA5Nx6wY51/tnO9mP03H7o6S 99yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qp18si10313933ejb.100.2019.11.06.03.31.28; Wed, 06 Nov 2019 03:31:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729911AbfKFL2k (ORCPT + 99 others); Wed, 6 Nov 2019 06:28:40 -0500 Received: from foss.arm.com ([217.140.110.172]:38280 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbfKFL2j (ORCPT ); Wed, 6 Nov 2019 06:28:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ED8BC7A7; Wed, 6 Nov 2019 03:28:38 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B3DC83F6C4; Wed, 6 Nov 2019 03:28:37 -0800 (PST) Date: Wed, 6 Nov 2019 11:28:29 +0000 From: Mark Rutland To: Ganapatrao Prabhakerrao Kulkarni Cc: "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "peterz@infradead.org" , "mingo@redhat.com" , "will@kernel.org" , "corbet@lwn.net" , "gklkml16@gmail.com" Subject: Re: [PATCH 1/2] perf/core: Adding capability to disable PMUs event multiplexing Message-ID: <20191106112810.GA50610@lakrids.cambridge.arm.com> References: <1573002091-9744-1-git-send-email-gkulkarni@marvell.com> <1573002091-9744-2-git-send-email-gkulkarni@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1573002091-9744-2-git-send-email-gkulkarni@marvell.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 06, 2019 at 01:01:40AM +0000, Ganapatrao Prabhakerrao Kulkarni wrote: > When PMUs are registered, perf core enables event multiplexing > support by default. There is no provision for PMUs to disable > event multiplexing, if PMUs want to disable due to unavoidable > circumstances like hardware errata etc. > > Adding PMU capability flag PERF_PMU_CAP_NO_MUX_EVENTS and support > to allow PMUs to explicitly disable event multiplexing. Even without multiplexing, this PMU activity can happen when switching tasks, or when creating/destroying events, so as-is I don't think this makes much sense. If there's an erratum whereby heavy access to the PMU can lockup the core, and it's possible to workaround that by minimzing accesses, that should be done in the back-end PMU driver. Either way, this minimzes the utility of the PMU. Thanks, Mark. > > Signed-off-by: Ganapatrao Prabhakerrao Kulkarni > --- > include/linux/perf_event.h | 1 + > kernel/events/core.c | 8 ++++++++ > 2 files changed, 9 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 61448c19a132..9e18d841daf7 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -247,6 +247,7 @@ struct perf_event; > #define PERF_PMU_CAP_HETEROGENEOUS_CPUS 0x40 > #define PERF_PMU_CAP_NO_EXCLUDE 0x80 > #define PERF_PMU_CAP_AUX_OUTPUT 0x100 > +#define PERF_PMU_CAP_NO_MUX_EVENTS 0x200 > > /** > * struct pmu - generic performance monitoring unit > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 4655adbbae10..65452784f81c 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1092,6 +1092,10 @@ static void __perf_mux_hrtimer_init(struct perf_cpu_context *cpuctx, int cpu) > if (pmu->task_ctx_nr == perf_sw_context) > return; > > + /* No PMU support */ > + if (pmu->capabilities & PERF_PMU_CAP_NO_MUX_EVENTS) > + return 0; > + > /* > * check default is sane, if not set then force to > * default interval (1/tick) > @@ -1117,6 +1121,10 @@ static int perf_mux_hrtimer_restart(struct perf_cpu_context *cpuctx) > if (pmu->task_ctx_nr == perf_sw_context) > return 0; > > + /* No PMU support */ > + if (pmu->capabilities & PERF_PMU_CAP_NO_MUX_EVENTS) > + return 0; > + > raw_spin_lock_irqsave(&cpuctx->hrtimer_lock, flags); > if (!cpuctx->hrtimer_active) { > cpuctx->hrtimer_active = 1; > -- > 2.17.1 >