From patchwork Tue Jun 6 08:18:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 103647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3242225vqr; Tue, 6 Jun 2023 01:46:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RqDxZi039psn/f2j4kg+rhGCrstPQQdrNE5Wls+NgBtOb9i7AS9b+yMnP3BVoI2Kiddup X-Received: by 2002:a05:6870:5156:b0:19f:9dc5:c0b with SMTP id z22-20020a056870515600b0019f9dc50c0bmr1584254oak.12.1686041191589; Tue, 06 Jun 2023 01:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686041191; cv=none; d=google.com; s=arc-20160816; b=zteTiNrCjF/mm9yqsOWdZVo3dQ189Uf77S8biwDXOugOBGmZfRNT29ibcyIi7owyDa FKWfnHecULQ0koHyJREhVJO7KrUVo6nSblZ0jK1K+o+5O+clFI6lbFKXFCnRZJecGRV4 QmzcJ2l02HvoSmPeEhDnUUCc0H+skikMxAg3citxpY2WGAkARXuL8a6e+ryXEVDqDfJr J4cFP9WSRPg1MZuqi91qbuMuV6uVbnwR2Zjh51aghOE2ARYv9R8n46NmV4FyPEOi9Qgq m7Y3faQly+7A8muwS9UgWvOCFfN8CLaNkAMlKh5RWrtnrrh/Fp53Sw30N8GUmIuJQHPT z3RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=loGpNdhbZ2dJUcxifiO+fpK1K/ID5CqdSLfcmB+jq1I=; b=RaaQ6RUe1CpAjcymymPBeEhJXFatjWLUvM18UR6utBvSRQcgMdB8ysLGCW3eWABJjZ a3Qb3PTJ7Gd6cZsFHtE312+aY0TXScRfVpYEcS3Xa0llDGG4xu/icb0C5BywUoZVFRD6 pylsKjYO55SDLV4Cejzl6atuHLUh1wEANVjEwui5G+xw4jxORas+yHyzMa9Vq4xmB9sb gC76/W5ucIwsKRr0Es74U2lt1MRFF4Gpzonu//o5nLWVVZC9xi9nmAnKSjtA4CWjYrUz dC86Vdo8Xcm5zT6idH+kMJRJPNl/yorymezRo+gRXlhVXET08SD57fr7975cj5s6Jten /zhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GgogaaHT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a637352000000b0051394ccd19csi1174979pgn.55.2023.06.06.01.46.19; Tue, 06 Jun 2023 01:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GgogaaHT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235629AbjFFIS4 (ORCPT + 99 others); Tue, 6 Jun 2023 04:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235987AbjFFISq (ORCPT ); Tue, 6 Jun 2023 04:18:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5117518E; Tue, 6 Jun 2023 01:18:44 -0700 (PDT) Date: Tue, 06 Jun 2023 08:18:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686039523; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=loGpNdhbZ2dJUcxifiO+fpK1K/ID5CqdSLfcmB+jq1I=; b=GgogaaHTQPfiKBzoSVKpwHt3PCTaE/7QDSKf/NQVSKnZo/uN5n+xYflJUIMTAGQaMW05Ej 2i4F9QugWfvxYQZneN7kJHa2SCrAN9h7NKv6gw6DwuApmM8eb+mDz4ohBFjw9DKtxtO9a3 Ulyl5+N/zRRD1TQ+N/f3fuG+qwIv/h/B6eb7OBSH02dNbh9YoVIxu3jgToVo3OY2mIuL+0 0Mzn0s0UlC6d/3Fqb9elHsDTn2ayQ024kKNSWCEY0bHxdlsGYmEUwBsvGLoiW9SUqAPBtT JjkVWb+g+KjOUdDnKi3/KXoWXnNptQ6iXtSdO74WdandLCUWhCgElA7l6gtxNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686039523; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=loGpNdhbZ2dJUcxifiO+fpK1K/ID5CqdSLfcmB+jq1I=; b=vzW2RcWE4SkiQ8S83SYsZJcIrtz/4zjo+CoCkV4ye+G6ARa5tSvSk1f/LjWyUGyiHPxbET Afzvs7Qlu19CFvDA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf: Re-instate the linear PMU search Cc: Nathan Chancellor , Krzysztof Kozlowski , Mark Rutland , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230605101401.GL38236@hirez.programming.kicks-ass.net> References: <20230605101401.GL38236@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Message-ID: <168603952210.404.6172864840237247274.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767942328697883170?= X-GMAIL-MSGID: =?utf-8?q?1767942328697883170?= The following commit has been merged into the perf/core branch of tip: Commit-ID: 228020b490eda9133c9cb6f59a5ee1278d8c463f Gitweb: https://git.kernel.org/tip/228020b490eda9133c9cb6f59a5ee1278d8c463f Author: Peter Zijlstra AuthorDate: Mon, 05 Jun 2023 12:14:01 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 06 Jun 2023 10:09:21 +02:00 perf: Re-instate the linear PMU search Full revert of commit 9551fbb64d09 ("perf/core: Remove pmu linear searching code"). Some architectures (notably arm/arm64) still relied on the linear search in order to find the PMU that consumes PERF_TYPE_{HARDWARE,HW_CACHE,RAW}. This will need a more thorought audit and cleanup. Reported-by: Nathan Chancellor Reported-by: Krzysztof Kozlowski Acked-by: Mark Rutland Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230605101401.GL38236@hirez.programming.kicks-ass.net --- kernel/events/core.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 231b187..c01bbe9 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11630,27 +11630,38 @@ static struct pmu *perf_init_event(struct perf_event *event) } again: - ret = -ENOENT; rcu_read_lock(); pmu = idr_find(&pmu_idr, type); rcu_read_unlock(); - if (!pmu) - goto fail; + if (pmu) { + if (event->attr.type != type && type != PERF_TYPE_RAW && + !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) + goto fail; - if (event->attr.type != type && type != PERF_TYPE_RAW && - !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) - goto fail; + ret = perf_try_init_event(pmu, event); + if (ret == -ENOENT && event->attr.type != type && !extended_type) { + type = event->attr.type; + goto again; + } - ret = perf_try_init_event(pmu, event); - if (ret == -ENOENT && event->attr.type != type && !extended_type) { - type = event->attr.type; - goto again; + if (ret) + pmu = ERR_PTR(ret); + + goto unlock; } -fail: - if (ret) - pmu = ERR_PTR(ret); + list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) { + ret = perf_try_init_event(pmu, event); + if (!ret) + goto unlock; + if (ret != -ENOENT) { + pmu = ERR_PTR(ret); + goto unlock; + } + } +fail: + pmu = ERR_PTR(-ENOENT); unlock: srcu_read_unlock(&pmus_srcu, idx);