From patchwork Wed May 10 13:33:41 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: 92111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3634540vqo; Wed, 10 May 2023 06:43:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4A05V6FDXLAtHvIwof4TUy1eWgIvkSWHGBw0knBmF6LBbqkXzBfxFpti6E9Eu1oRhbYzOt X-Received: by 2002:a05:6a00:a15:b0:63b:8f08:9af3 with SMTP id p21-20020a056a000a1500b0063b8f089af3mr25417581pfh.7.1683726226817; Wed, 10 May 2023 06:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683726226; cv=none; d=google.com; s=arc-20160816; b=a4GgXai5GJ2+QtvCB1BXpuaB6m/LSpDmnWPD5332nD3F8L/ZoNrdhfVxAPbqQS2t3t KWIVoDmJx72lwBC9RbXq0IC4KqB+B/aKwakhVpj1XlLUn4yNp41BLX80jGMc72cSxDkK DHB4Dsa9gUANTJs0uNGxP3/Z+29kbNR8mcCp00Owqo07+NROMIyY38W3STnAhdMy3oS1 C4REqAFMTiU/hx59yfgIS9KhDxs3Wcqh54s6ScovREPfzOOXSfZMrf4taLhIfoD6vRZ2 6wgVr66OpHkTt7yWSXYV3+1ESUXwxPQ2D0lTNQ8mkQxbu/dmOi/UQh2J3hHGJ8KTii9s Ykvg== 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=qADTTeN46tJznf0RtUMYpgdOlRKAf0uSFMM7i3CA1bM=; b=qABrvDEMAd2gXZzQmU3Y7AiatsHtvkt0/t/08VFGFJxanYis3pVJIgaAL/wSDQxR6+ GP8jY/LPvYKdGVchTtXejh0se5Yc6y05SzAKmCrVIVT7A9chtCOxrfH7W8MMLHz/c1Pw 04y/yED8cJ5qfM1rZfeHwQWGj1gKgAwNm9vctMU2hzqdEOI1MN3zdb4ERClMudoDyIuD un6tWkrZ2Im8enk1uWWc6TdM4etKHggkdxF6q4lbjGitgbjUSRAFO3Ize0gdSy0WyEkR hi83nZGkEGJtMg/H9vXN9siLlFA4aodKZlA+oY1yzWRF1VeV8yd1UROPPbLOO0uk5mOD 598A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vTRknf9o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GgFvvgJe; 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 w12-20020a63934c000000b0051ae6c4084dsi3779614pgm.512.2023.05.10.06.43.32; Wed, 10 May 2023 06:43:46 -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=vTRknf9o; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GgFvvgJe; 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 S237139AbjEJNdv (ORCPT + 99 others); Wed, 10 May 2023 09:33:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237038AbjEJNdo (ORCPT ); Wed, 10 May 2023 09:33:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014AF98; Wed, 10 May 2023 06:33:42 -0700 (PDT) Date: Wed, 10 May 2023 13:33:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683725621; 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=qADTTeN46tJznf0RtUMYpgdOlRKAf0uSFMM7i3CA1bM=; b=vTRknf9ohHDkFAi3ChtsEE7D+hLUQZGui6yb6fPwVigf0noDOKY+X7OjKc8kPotBKqe/LT FTgGEm3YTMK6s91UoFd8jvLwuL+det+39dkKDZQEXOXrjDMRCtSUHjobmkUcAa4ObiYGO3 juQIqgpYKysdpuXWE7/T/kRxpDhboyNlLp9f6V93pjiQWZJgsG2S3bekr06aN/f3NsZxDT enVfhaCsIu/4WA3oIsUZnQ2H/DV3SHNjM0NPm4y2KT56catUR/O75HTlZF3kxfM/UJXeQM tgk+HdMX+en43j5lfA2Ai/4NoQlsg7ZL7sNywJXyGfBoMJ2APN1n3VrTb7pB3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683725621; 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=qADTTeN46tJznf0RtUMYpgdOlRKAf0uSFMM7i3CA1bM=; b=GgFvvgJeOV9+aCLW+SlAQ1sp0yzyaJuBy+B/Zm390LLOHKhSIAc+182MSfKASIvF49LHjU 8Ckkf8h/yJlzBLBQ== From: "tip-bot2 for Ravi Bangoria" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Remove pmu linear searching code Cc: Ravi Bangoria , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230504110003.2548-4-ravi.bangoria@amd.com> References: <20230504110003.2548-4-ravi.bangoria@amd.com> MIME-Version: 1.0 Message-ID: <168372562124.404.3938002441520901647.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?1764961343251387091?= X-GMAIL-MSGID: =?utf-8?q?1765514911996508035?= The following commit has been merged into the perf/core branch of tip: Commit-ID: 9551fbb64d094cc105964716224adeb7765df8fd Gitweb: https://git.kernel.org/tip/9551fbb64d094cc105964716224adeb7765df8fd Author: Ravi Bangoria AuthorDate: Thu, 04 May 2023 16:30:02 +05:30 Committer: Peter Zijlstra CommitterDate: Mon, 08 May 2023 10:58:31 +02:00 perf/core: Remove pmu linear searching code Searching for the right pmu by iterating over all pmus is no longer required since all pmus now *must* be present in the 'pmu_idr' list. So, remove linear searching code. Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230504110003.2548-4-ravi.bangoria@amd.com --- kernel/events/core.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index c01bbe9..231b187 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11630,38 +11630,27 @@ 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) { - 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; - } + if (!pmu) + goto fail; - if (ret) - pmu = ERR_PTR(ret); + if (event->attr.type != type && type != PERF_TYPE_RAW && + !(pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)) + goto fail; - goto unlock; + ret = perf_try_init_event(pmu, event); + if (ret == -ENOENT && event->attr.type != type && !extended_type) { + type = event->attr.type; + goto again; } - 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); + if (ret) + pmu = ERR_PTR(ret); + unlock: srcu_read_unlock(&pmus_srcu, idx);