Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp194719ybx; Wed, 6 Nov 2019 15:30:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzLAdqvw2By2TPZIQz6kA5qs2VZncwv6uT0GaqXqvuSga83vQtUia0Qxc+2WgUTtmQOVH4Y X-Received: by 2002:aa7:dbd4:: with SMTP id v20mr430525edt.58.1573083031775; Wed, 06 Nov 2019 15:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573083031; cv=none; d=google.com; s=arc-20160816; b=o/6f7P5luV0aQU9kQPZI6YV/vKoiISw2kAIOQ2o9D7MiAp8tlutcI+ZzdOVZ9FI0MP Ltj/16ZptLFIvOvfJ/ysZwNrjjaKkkRybyufM9qmvS3FrJ8TSCXAG1gFgrWQqN2ieByL rREwxXcb5OmsU928zxL8GSHSGRqtvQPIQlJqim38WHClycWFC/BmP41TKdb22bi1gbka zai3NmuSQuV6hy9MhwXBSfjzTclOrgOB+8sl+nfQlCDvWhFORykDcpB5rOI5yNuoAY9n x7UaDRViZvVrEHEVXF1v2P06ADYQbm3SFg0Ha5y/EZd6m6IIjdmm2bmP8XVkf0bui1Qj MU4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wsGkky6yfeJ+ut8glQWS3HkTq744rNXXFxtFxOcqi6E=; b=nrEgqr/YU5RjFxuZa87kWz3gQcPEsqTxvfKrIjXpwdFKPnGNjQS+6DUrF/oAwVJanO 1N4tRsg9kaGv1jlj5kSxtrUTaxIy/e4AmteBF4H7g2Zs+ury9ECbC1agPJNhHDwsFAvi FHpqKE/1urXq3opGCKl/P0XtHkKQu60IWYAS/zxlTcDzBUO2bEjhjhENjWZKhSYumtp9 SmBx/nDQ3Pc4TvjRYy2vcScvfwENiBdSqx9B9M3Km8kg88ewAUNm3BukPZarMsYUd6nO Kr6dRh/BECEAFSzgQnT+q+XwH96PNJ08XVTHnsu1OLBxwOS5IDbLz6QbyyKLE67DJyHQ dnTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JUXKo99u; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si236047ejd.305.2019.11.06.15.30.07; Wed, 06 Nov 2019 15:30:31 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JUXKo99u; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbfKFX27 (ORCPT + 99 others); Wed, 6 Nov 2019 18:28:59 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:33767 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727316AbfKFX27 (ORCPT ); Wed, 6 Nov 2019 18:28:59 -0500 Received: by mail-yb1-f196.google.com with SMTP id i15so238336ybq.0; Wed, 06 Nov 2019 15:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wsGkky6yfeJ+ut8glQWS3HkTq744rNXXFxtFxOcqi6E=; b=JUXKo99uMkVxowlJ3qm1o6kw842BvWhmlNS5Z9hyRW0pcJphoXOcCtnUNtfx8IdPpR oySoQsb3lPIh+NM2b8zCSRhLOFT75guRcYd72Ts72gYIuaxUBsRjPqNCrElolRdmbi3E cTkFII1BHLz7OoDVHGOip9fuVLPcoQjm/Gi019NG/gIAXNd7Jy/L2kFziZmD22JV2Woe igAfYSWRe5lE2vascU6L0OmI4tkSH8zacRn77dFgUbztKeXyLUT/HwoKtl7OFODUxaEv MruH3USO7MVQaKrCNOxZNubsnMJhoYa+UfquEtgRfwjKRBuo3hJLYEnqthAnmXfvpdp0 YEKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wsGkky6yfeJ+ut8glQWS3HkTq744rNXXFxtFxOcqi6E=; b=pPEp3qheNX8lxj8zg6Pvamc+e3a060oCePxLSSIpPB56gZ9BNDLS3CXUtKwd6M0f4A rqGbOuUl2NoswjE6DZuNbb9ZmPzu6gBKelUaBiLDfcVWBNYt+dAJYoiL06Pk2okKaI/n GNwK+HjuTvQgFj07f6FYe7WZx0OYKPhZ2TZec7wmKle0sZmk2DsZDO32T4IbTY/qGnXS MewRE53R9f8fl3Idi1u/+fTBpwbMTUz3ZWLQzJCDqVbjVod+Op0m04SHQFuXz6Mc3doV cUsywFnYZhK3y2ud8a3IlhMnDxdG3S2wFWhXwjPoWtCwJ9N+TXXDiK3wOZyYJAKIkbj6 Beow== X-Gm-Message-State: APjAAAUf6uu77CZOev0db+NNItMyvFrdOnCVRzwIUBBc3QbzYTy5sFxq FtK1bQKjtGVQHJuf0RL0qBlTjVzu3BJglPtMWow= X-Received: by 2002:a25:774b:: with SMTP id s72mr613338ybc.287.1573082937865; Wed, 06 Nov 2019 15:28:57 -0800 (PST) MIME-Version: 1.0 References: <1573002091-9744-1-git-send-email-gkulkarni@marvell.com> <1573002091-9744-2-git-send-email-gkulkarni@marvell.com> <20191106112810.GA50610@lakrids.cambridge.arm.com> In-Reply-To: <20191106112810.GA50610@lakrids.cambridge.arm.com> From: Ganapatrao Kulkarni Date: Wed, 6 Nov 2019 15:28:46 -0800 Message-ID: Subject: Re: [PATCH 1/2] perf/core: Adding capability to disable PMUs event multiplexing To: Mark Rutland Cc: Ganapatrao Prabhakerrao Kulkarni , "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" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, Mark, On Wed, Nov 6, 2019 at 3:28 AM Mark Rutland wrote: > > 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. As said in errata, If there are heavy access to memory like stream application running and along with that if PMU control registers are also accessed frequently, then CPU lockup is seen. I ran perf stat with 4 events of thuderx2 PMU as well as with 6 events for stream application. For 4 events run, there is no event multiplexing, where as for 6 events run the events are multiplexed. For 4 event run: No of times pmu->add is called: 10 No of times pmu->del is called: 10 No of times pmu->read is called: 310 For 6 events run: No of times pmu->add is called: 5216 No of times pmu->del is called: 5216 No of times pmu->read is called: 5216 Issue happens when the add and del are called too many times as seen with 6 event case. The PMU hardware control registers are programmed when add and del functions are called. For pmu->read no issues since no h/w issue with the data path. This is UNCORE driver, not sure context switch has any influence on this? Please suggest me, how can we fix this in back-end PMU driver without any perf core help? > > 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 > > Thanks, Ganapat