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 X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C145C433F5 for ; Tue, 14 Sep 2021 20:51:08 +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 12D9961164 for ; Tue, 14 Sep 2021 20:51:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 12D9961164 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Usx2eEVEU4J6WGlQ9pPnZWYAU9jrKdNPKkLwYsde0gg=; b=emwPvWgnw4HqLl yQvMZvwxAUChyMUE1raWVWcEUqkB6Rd72ZU0pjqUn+b9u85iq6yaAypzppUo8dDcGwSktSiHM71rO +4e601z9xWVNK5tqsKVy+AZTra5PbLPZS6kA2egV36NYMVfMIiin2Gfp6mdXFoSisnhGI23vdKu/T oAQd1N6vZF2zID+DEzfsVgGyYeeV8F95WohSXAsFb1x7bgLYln/x/DPfH4KXfgYykyHg7mLwVHgzg nx5Kx4xk+TXdjRMxOUpxlgMzotHVQJqpkHbx47JJBfNIy8gYVa1XcWdrkLTEH4Karzn5NZ1hd+0HA cxCHau7Jw5RF94dhnQuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQFMD-0073UY-CI; Tue, 14 Sep 2021 20:48:45 +0000 Received: from mail-ot1-f44.google.com ([209.85.210.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQFLl-0073FC-Lr for linux-arm-kernel@lists.infradead.org; Tue, 14 Sep 2021 20:48:20 +0000 Received: by mail-ot1-f44.google.com with SMTP id i8-20020a056830402800b0051afc3e373aso415207ots.5 for ; Tue, 14 Sep 2021 13:48:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4do6ZA0TOFP4Hz327TP/A6q+bKxaXa1iSI4FOzJa60=; b=QFHCM2ls4pZOCTR1sOGbVcfQ69itgZEOI/Tilos7DWj4HuZCOoXaJjcU848io25AH3 6K4O9ImcJWji0Gd6//ur04MAsYvkfMJCIdVCkc9J8EUi/gxX/hZRkic/SJKp4BQJJpKR 99eihhxxsMAAvyBDfUsq/ZeromrLanLgNo5OLfZtotyn141FSOF7AfmkZpUHxAQbHo+c bDZQcM9yN5ev9bbfA7SqeljXY/o8pJJBIDES6WwN66nrQel7zixv+FBxB9X3136rrftq zfLWlL1m7brWx8eeo1J7XWhSFM63G/6/HzDD8y0ZOzkJG9ceqXFtD5lf2GhVJFAsSrac icaQ== X-Gm-Message-State: AOAM533W0Dmr1+l7rimfbyIQoiSell2DQoveNdzC/EzCa7hB39eGjG11 OEj4UPcVlPfJidYiPmYEGg== X-Google-Smtp-Source: ABdhPJyEXtSPTKolZuuw+LNsDBA3Aao0tZ3BSBbYdafbVuFccEagg74RqQYQT16YdRlPbxBLKKGPBg== X-Received: by 2002:a9d:6d02:: with SMTP id o2mr16293329otp.302.1631652483786; Tue, 14 Sep 2021 13:48:03 -0700 (PDT) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id y14sm2883236oti.69.2021.09.14.13.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:48:03 -0700 (PDT) From: Rob Herring To: Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar Cc: 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: [PATCH v10 2/5] perf: Add a counter for number of user access events in context Date: Tue, 14 Sep 2021 15:47:57 -0500 Message-Id: <20210914204800.3945732-3-robh@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210914204800.3945732-1-robh@kernel.org> References: <20210914204800.3945732-1-robh@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210914_134817_757605_92BBCA1E X-CRM114-Status: GOOD ( 15.04 ) 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 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 --- 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