From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60A4CC433F5 for ; Wed, 13 Oct 2021 17:26:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 342766109F for ; Wed, 13 Oct 2021 17:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238032AbhJMR2q (ORCPT ); Wed, 13 Oct 2021 13:28:46 -0400 Received: from foss.arm.com ([217.140.110.172]:42826 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhJMR2n (ORCPT ); Wed, 13 Oct 2021 13:28:43 -0400 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 4A45A1063; Wed, 13 Oct 2021 10:26:40 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.73.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2ED533F694; Wed, 13 Oct 2021 10:26:35 -0700 (PDT) Date: Wed, 13 Oct 2021 18:26:33 +0100 From: Mark Rutland To: Rob Herring Cc: Will Deacon , Peter Zijlstra , Ingo Molnar , Catalin Marinas , Arnaldo Carvalho de Melo , Jiri Olsa , Kan Liang , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , Vince Weaver , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 2/5] perf: Add a counter for number of user access events in context Message-ID: <20211013172633.GB5400@C02TD0UTHF1T.local> References: <20210914204800.3945732-1-robh@kernel.org> <20210914204800.3945732-3-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210914204800.3945732-3-robh@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 03:47:57PM -0500, Rob Herring wrote: > For controlling user space counter access, we need to know if any event > in a context (currently scheduled or not) is using user space counters. > Walking the context's list of events would be slow, so add a counter > to track this. > > Signed-off-by: Rob Herring Reviewed-by: Mark Rutland Mark. > --- > v10: > - Re-added. > - Maintain the count in the perf core > v9: > - Dropped > v8: > - new patch > --- > include/linux/perf_event.h | 1 + > kernel/events/core.c | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 12debf008d39..4f82a4d47139 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -821,6 +821,7 @@ struct perf_event_context { > > int nr_events; > int nr_active; > + int nr_user; > int is_active; > int nr_stat; > int nr_freq; > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 744e8726c5b2..01290d150da3 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1808,6 +1808,8 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx) > > list_add_rcu(&event->event_entry, &ctx->event_list); > ctx->nr_events++; > + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) > + ctx->nr_user++; > if (event->attr.inherit_stat) > ctx->nr_stat++; > > @@ -1999,6 +2001,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) > event->attach_state &= ~PERF_ATTACH_CONTEXT; > > ctx->nr_events--; > + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) > + ctx->nr_user--; > if (event->attr.inherit_stat) > ctx->nr_stat--; > > -- > 2.30.2 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F39FC433EF for ; Wed, 13 Oct 2021 17:28:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 546A06101D for ; Wed, 13 Oct 2021 17:28:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 546A06101D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UYa6ExYTqmkxYjdiazKcyAjBl9ACKHbqLfDagAlhCws=; b=BFIGvejGPKsnGI Eo1dL6cew/JcqaXm/FFxazZQDiFbtkYr1geQWA+D3eyI7MBQLN62Ik/n86DBMQPsvcYwpns+Wq0V5 pOVg/VoVTHaydkzoMLltu+JPDI/VIMBspO04ZENrFh7KhA0sh2741OcvxAx1i105Ggq63oMmYA8ID Muwt7tWRezwLhJCk8CB96GOWqH7TPF+iSSDK45hYmv49+agq3DTRrIJ27w6ipEPETAZ05B72lBLA3 QhTPeSDZVKwHjj/n3eNpVyGHuITjPtnLeaEPF3J0FkmIGB2RwVxsx+0WF1UaS6rUJPlrkyF14b8tS Q5LLh7NRhBcGYP6bqq7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mai1g-0008vT-E0; Wed, 13 Oct 2021 17:26:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mai1d-0008up-15 for linux-arm-kernel@lists.infradead.org; Wed, 13 Oct 2021 17:26:46 +0000 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 4A45A1063; Wed, 13 Oct 2021 10:26:40 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.73.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2ED533F694; Wed, 13 Oct 2021 10:26:35 -0700 (PDT) Date: Wed, 13 Oct 2021 18:26:33 +0100 From: Mark Rutland To: Rob Herring Cc: Will Deacon , Peter Zijlstra , Ingo Molnar , Catalin Marinas , Arnaldo Carvalho de Melo , Jiri Olsa , Kan Liang , Ian Rogers , Alexander Shishkin , honnappa.nagarahalli@arm.com, Zachary.Leaf@arm.com, Raphael Gault , Jonathan Cameron , Namhyung Kim , Itaru Kitayama , Vince Weaver , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 2/5] perf: Add a counter for number of user access events in context Message-ID: <20211013172633.GB5400@C02TD0UTHF1T.local> References: <20210914204800.3945732-1-robh@kernel.org> <20210914204800.3945732-3-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210914204800.3945732-3-robh@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211013_102645_127491_C93ED603 X-CRM114-Status: GOOD ( 20.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 14, 2021 at 03:47:57PM -0500, Rob Herring wrote: > For controlling user space counter access, we need to know if any event > in a context (currently scheduled or not) is using user space counters. > Walking the context's list of events would be slow, so add a counter > to track this. > > Signed-off-by: Rob Herring Reviewed-by: Mark Rutland Mark. > --- > v10: > - Re-added. > - Maintain the count in the perf core > v9: > - Dropped > v8: > - new patch > --- > include/linux/perf_event.h | 1 + > kernel/events/core.c | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 12debf008d39..4f82a4d47139 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -821,6 +821,7 @@ struct perf_event_context { > > int nr_events; > int nr_active; > + int nr_user; > int is_active; > int nr_stat; > int nr_freq; > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 744e8726c5b2..01290d150da3 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -1808,6 +1808,8 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx) > > list_add_rcu(&event->event_entry, &ctx->event_list); > ctx->nr_events++; > + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) > + ctx->nr_user++; > if (event->attr.inherit_stat) > ctx->nr_stat++; > > @@ -1999,6 +2001,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) > event->attach_state &= ~PERF_ATTACH_CONTEXT; > > ctx->nr_events--; > + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) > + ctx->nr_user--; > if (event->attr.inherit_stat) > ctx->nr_stat--; > > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel