Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1223963lql; Tue, 12 Mar 2024 10:35:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw9+Z3cXMirKJ9QGSNG1eSxVM8kB4tUTC60CyOWWIQkCj29xsweRlPqjS/Rv+V+wboQB0hMWjrwbBpscSn+zVMv0rKYubGVhtZiKrzHw== X-Google-Smtp-Source: AGHT+IGjXeBC4HkSFx1euSw3dlg0D4j/BUSRKn5KaYoq/yolucYCHN7itOeBT5ecNkQR3rRF0F+v X-Received: by 2002:a05:620a:1599:b0:788:6e05:78a9 with SMTP id d25-20020a05620a159900b007886e0578a9mr6369340qkk.71.1710264903752; Tue, 12 Mar 2024 10:35:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710264903; cv=pass; d=google.com; s=arc-20160816; b=gP74aMkcHzZbyMLCbs8ORihrx03k99xz4xu7JJzEs+imyF5ODT6pgOX6PHxD+kTByo 0gXMSK9AZt4wGRwquGXQm/QgPqw1kccV1Wj6R6Wg2ov7cF8veFVCb/j+W6zXp+RuGU6E uIwXTht7C5V8CIIQ1dx8sG18s7RGx7QlHKL3Uzk3gDsXDvJigr1LS6O7++vMvdrJ3NoZ /M+oXziwfJcq8eUNadRVvK4HG/JnGERSLBtr4pIUhondQpGtSrG5InW8oJb0aC2bytrK Zy76uTSolLmn/7Y+6ZX8at+p37/qIqGsERQWvfIY29UXywBFyOi8ksIQnO6+0+uf1YCq hocA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=owgSs6h54qaL0Iu/1bQvvBuShnx4pP5jWVyWif3YPpE=; fh=3SlCtb7gAd2C6Wzcs3sLv5dQhSDlRzf/+NQZwZZwN+Y=; b=FqtC9cwNQdNd35NwYQkepkjZNIO87bgNe3FiZ/huggTcpeP8ok8zyKs+CRl49d8VKQ cEUcYlL1oK6I4aq7nhYEVouzYlcCkcNtJdrLqXzJ08XEnw+CveCEp1Y4gPdjJtLQtaR8 nU/0fJOvGaSLI8IO0TsiP1M+HO96w43mMCOupBAnzxQQ7uCHXOi2fGmxY9MsZwpHjce8 M75Aej/TPgdKPkei3gSuSDrzqglEaCBOcUHwh9HEvu1FrVlRfv3KSb81hY+TPtSkhWQW Yp8U5JY4Lx6WKl+MF0ZVDexoApVX3MS/g+Zk+BUFMAXLW6mKFaA9b8oAJLKz0AYHfL7S sAKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-100604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ea24-20020a05620a489800b007882ce1bff1si8677938qkb.743.2024.03.12.10.35.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 10:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-100604-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 79C371C20F5D for ; Tue, 12 Mar 2024 17:35:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33426139591; Tue, 12 Mar 2024 17:34:32 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39FFC13956C; Tue, 12 Mar 2024 17:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710264871; cv=none; b=j7QUHPEkvkofdF8yQYq/RDTG9uoFpWxj3K2etgNVeom76bQqbOcCjRTRitsXgjHYUybHI0Dw0M1yr1cc3rYan8mnjbbxjDvH2VNgDeHbI3XP2fwy3PXvEz+7qWt4KJWvHNG7FKLAGSDgNTGaeld9crSx+Cq+bKSnzqWDCvpt5c4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710264871; c=relaxed/simple; bh=G61qQSbKIc/00ZL3F3yoF/s/9tEIXEVun3SaCdru6+0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hEnecvSIGr1uB6WhaUm0vAkewEBWjPuUlTxX31ZwCz6zRNDFFBfhb4iLlLwIid00T5vIo3GPEgybhCfAJHt6asRwxaPJ1el7umv2nYNp5MkTGRqQNLM/nPuiPjLTxyDf57j4xkOS+AJnMaZPAIc3jPvjfqgRBq+eU4mzH3W/E5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 B54E015DB; Tue, 12 Mar 2024 10:35:06 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 847BC3F762; Tue, 12 Mar 2024 10:34:27 -0700 (PDT) From: Robin Murphy To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Will Deacon Cc: Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-perf-users@vger.kernel.org, jialong.yang@shingroup.cn Subject: [PATCH 02/10] perf: Add capability for common event support Date: Tue, 12 Mar 2024 17:34:04 +0000 Message-Id: X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Many PMUs do not support common hardware/cache/etc. events and only handle their own PMU-specific events. Since this only depends on matching the event and PMU types, it's a prime candidate for a core capability to save more event_init boilerplate in drivers. Signed-off-by: Robin Murphy --- include/linux/perf_event.h | 1 + kernel/events/core.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d2a15c0c6f8a..983201f21dd2 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -291,6 +291,7 @@ struct perf_event_pmu_context; #define PERF_PMU_CAP_NO_EXCLUDE 0x0040 #define PERF_PMU_CAP_AUX_OUTPUT 0x0080 #define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100 +#define PERF_PMU_CAP_NO_COMMON_EVENTS 0x0200 struct perf_output_handle; diff --git a/kernel/events/core.c b/kernel/events/core.c index f0f0f71213a1..7ad80826c218 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11649,6 +11649,11 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) struct perf_event_context *ctx = NULL; int ret; + /* Short-circuit if we know the PMU won't want this event */ + if (pmu->capabilities & PERF_PMU_CAP_NO_COMMON_EVENTS && + event->attr.type != pmu->type) + return -ENOENT; + if (!try_module_get(pmu->module)) return -ENODEV; -- 2.39.2.101.g768bb238c484.dirty