Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6488138imu; Mon, 21 Jan 2019 09:43:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN5a5Kpr58x+0f3w5O2Xz9hsKgPYi7fv5blPyt3jZCOWa7p25Co8FuuGUup4i7QgGzUjZ6WA X-Received: by 2002:a62:5f07:: with SMTP id t7mr30311099pfb.108.1548092633361; Mon, 21 Jan 2019 09:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548092633; cv=none; d=google.com; s=arc-20160816; b=CFB543rGiY6kXDX77H5foFB03bPr2LFhWZLqe33CeRTZ8/j1Ccl5RVUMWGe6XGwoJP DZljSXvR6TTP7zRBLuSsGpBPkV2gXWPRqrnz3TmFTVuv42ILIOPeIjGCVvzJw7oCVyqt cbskFiszorZ3ZHofFzVPC52HMGVbi81Q+xlpC1gjAr0Z2WI/Ie6E8YfvgIMdPpYUBKuu bpGUPIIb/eNj3+n0IbgXXPKEFw/ds/ut7AGtKa2E94xsQP5z/V5JghdLlQ95UBWGb/9N ZYb1azZ0dmIhn4cIZ5Zeb3gQ4g33o90aBgz8oQv9o1K15c8Q5K/PB1u100vODxe2EGKd bEnA== 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=7jedQRFtPy1TGmor2UD/wN4jcYLGf+FHELC/B4qcgtc=; b=pWpZZ6erLOwZ3IqGV8wVbeoeCuVOPe/SLVAJZA8FjP5RBImI4Dsdh6R6cx2BQcsWtP t5m4KDk8vh8ooEiLmFCBq9Q7bTnXruc1VFGl0sYrfC2f2ElJAeImwTCDfSfLrcjhMkiT pps8PX9qNXeIPSwoysndnBTbhzWK+l0j/zZF/mKQNEyu5lbZUQft/byOSdpAbYp+/3Ci jNBRsyW/1/OaHbbqZXahh2p9R0hei8InpqrpzBwkVqWidU3oiy+uQQBB4RWh8dpjmjjB eiRkCTyp0dyXey6GdS/NgqRltM56Pq91N6cHZANo71v6TykLXhZ8Un5rHTtlAbTOXCTU ipgg== 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 d19si12764153pgg.314.2019.01.21.09.43.36; Mon, 21 Jan 2019 09:43:53 -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 S1726847AbfAURXa (ORCPT + 99 others); Mon, 21 Jan 2019 12:23:30 -0500 Received: from foss.arm.com ([217.140.101.70]:39692 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfAURXa (ORCPT ); Mon, 21 Jan 2019 12:23:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65DD115AB; Mon, 21 Jan 2019 09:23:29 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BC5593F614; Mon, 21 Jan 2019 09:23:27 -0800 (PST) Date: Mon, 21 Jan 2019 17:23:25 +0000 From: Mark Rutland To: Stefan Agner Cc: will.deacon@arm.com, shawnguo@kernel.org, l.stach@pengutronix.de, kernel@pengutronix.de, fabio.estevam@nxp.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drivers/perf: handle multiple CPUs with single interrupts Message-ID: <20190121172325.GD47506@lakrids.cambridge.arm.com> References: <20190121144111.22716-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190121144111.22716-1-stefan@agner.ch> 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 Hi Stefan, On Mon, Jan 21, 2019 at 03:41:11PM +0100, Stefan Agner wrote: > Currently, if only a single interrupt is available, the code assigns > this single interrupt to the first CPU. All other CPUs are left > unsupported. This allows to use perf events only on processes using > the first CPU. This is not obvious to the user. > > Instead, disable interrupts but support all CPUs. This allows to use > the PMU on all CPUs for all events other than sampling events which do > require interrupt support. Even for non-sampling events we use the overflow interrupt to ensure that we don't lose count across overflows, and without that interrupt, we cannot guarantee that the results are accurate. For example: Program counter to 0 Start program < counter overflows, no interrupt > < counter overflows, no interrupt > Stop program Counter reads as 5 ... which we cannot distinguish from: Program counter to 0 Start program < counter overflows, no interrupt > < counter overflows, no interrupt > < counter overflows, no interrupt > < counter overflows, no interrupt > < counter overflows, no interrupt > < counter overflows, no interrupt > Stop program Counter reads as 5 ... and thus cannot provide any reasonable confidence in results. In theory, we could use a hrtimer to periodically refresh the events to prevent this, but this would need to be set at some very high frequency to account for the fastest potential counter, and would significantly degrade performance. I don't think that's going to be reliable, and given that, I don't think that we can support muxed IRQs in this way. Thanks, Mark. > > Signed-off-by: Stefan Agner > --- > This has been observed and tested on a i.MX 6DualLite, but is probably > valid for i.MX 6Quad as well. > > It seems that ux500 once had support for single IRQ on a SMP system, > however this got removed with: > Commit 2b05f6ae1ee5 ("ARM: ux500: remove PMU IRQ bouncer") > > I noticed that with this patch I get an error when trying to use perf stat: > # perf top > Error: > cycles: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' > > Without this patch perf top seems to work, but it seems not to use any > sampling events (?): > # perf top > PerfTop: 7215 irqs/sec kernel:100.0% exact: 0.0% [4000Hz cpu-clock:pppH], (all, 2 CPUs) > .... > > Also starting perf top and explicitly selecting cpu-clock seems to work > and show the same data as before this change. > # perf top -e cpu-clock:pppH > PerfTop: 7214 irqs/sec kernel:100.0% exact: 0.0% [4000Hz cpu-clock:pppH], (all, 2 CPUs) > > It seems that perf top falls back to cpu-clock in the old case, but not > once sampling events are not supported... > > -- > Stefan > > > drivers/perf/arm_pmu_platform.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c > index 933bd8410fc2..80b991417b6e 100644 > --- a/drivers/perf/arm_pmu_platform.c > +++ b/drivers/perf/arm_pmu_platform.c > @@ -105,23 +105,26 @@ static int pmu_parse_irqs(struct arm_pmu *pmu) > return num_irqs; > } > > + if (num_irqs == 1) { > + int irq = platform_get_irq(pdev, 0); > + if (irq && irq_is_percpu_devid(irq)) > + return pmu_parse_percpu_irq(pmu, irq); > + } > + > /* > * In this case we have no idea which CPUs are covered by the PMU. > * To match our prior behaviour, we assume all CPUs in this case. > + * Multiple CPUs with a single PMU irq are currently not handled. > + * Rather than supporting only the first CPU, support all CPUs but > + * without interrupt capability. > */ > - if (num_irqs == 0) { > - pr_warn("no irqs for PMU, sampling events not supported\n"); > + if (num_irqs == 0 || (nr_cpu_ids > 1 && num_irqs == 1)) { > + pr_info("No per CPU irqs for PMU, sampling events not supported\n"); > pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; > cpumask_setall(&pmu->supported_cpus); > return 0; > } > > - if (num_irqs == 1) { > - int irq = platform_get_irq(pdev, 0); > - if (irq && irq_is_percpu_devid(irq)) > - return pmu_parse_percpu_irq(pmu, irq); > - } > - > if (nr_cpu_ids != 1 && !pmu_has_irq_affinity(pdev->dev.of_node)) { > pr_warn("no interrupt-affinity property for %pOF, guessing.\n", > pdev->dev.of_node); > -- > 2.20.1 >