Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5440259rwd; Mon, 5 Jun 2023 03:50:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Q+obvwRTPtjrjzf8kEhSV9/g3BopJNnRq1eVddoxff1guFVcfLyp4JYySg8hXm+meBQjB X-Received: by 2002:a92:c6c3:0:b0:32b:1536:f3e9 with SMTP id v3-20020a92c6c3000000b0032b1536f3e9mr17676456ilm.18.1685962252621; Mon, 05 Jun 2023 03:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685962252; cv=none; d=google.com; s=arc-20160816; b=VdBrSxD3D+2ZqGOX8KALiKFpI+rYYECjBQatYaXob/v0YF7ul4TuBNIPfaQFx4WmrO SXgNpKjXAKqp2fuLn2XPuhxJbF3SN/Wi5QqMfVNK1bnEWvAe1lQG/vPU6fSYFSKVZ2jv 96kKShGW3lbCLV7goUm7lgY/ZN5gCOlGVWQRoudrr0qN7YUefIDWebQKsNXL2MkfKmqa T14rJLI8HXfxXMyoH8j+xxh63strjwZzbO7wBcaC4N0l1QyfaIPqny8qj36+rOIvFgPF ByDqVq7Lo+2RptcWxBGSQt+x98UnRoa6UcLYGmWpXt4SfQYPB8fyvb0UgFP02ucJSyoK tnnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=b2pSoZ2MVUP/2fRl3RLOjQHQ8caqiz3LxI4BQNfXXW8=; b=uiBJezXatelJB8m58a+AkEV/Q1ADUjnx6KkFFIbKaYRbzAnmPQ47FaWSI6JJrY8Fzu 1ZvQNcD0YolIkJk0TT0bNORzbrm0OSTpI8jwET8lckcXL0S/PBsfz/fLru7PkkM/GIf9 n68W104cu1+HjoqcAuhqIrJ2UY4Ibj0blixLmaGKE/sSrQ7w3X2eFWRucogaMtziNV5l Vil8SIcMjUWL9GYFhhpKFszfzS6g4nUi8znrN+zZR23Yxlnjma7c9ujDReey+9/Nk2N+ RWtSiYgPeLrzxY1FciDBMTqA8rQHSpOcMu4GA4d3lIfy+GVrTpOfsf3UbzGW/ZTaKx70 hAyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=p+GOH75G; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020aa79e84000000b0064de770ec36si5097519pfq.353.2023.06.05.03.50.40; Mon, 05 Jun 2023 03:50:52 -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=@infradead.org header.s=desiato.20200630 header.b=p+GOH75G; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbjFEKOX (ORCPT + 99 others); Mon, 5 Jun 2023 06:14:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbjFEKOT (ORCPT ); Mon, 5 Jun 2023 06:14:19 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA84EE; Mon, 5 Jun 2023 03:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=b2pSoZ2MVUP/2fRl3RLOjQHQ8caqiz3LxI4BQNfXXW8=; b=p+GOH75Gz7cgdwRri2QfcUQqj4 4cOul7CanwFNKbNANL2U1MKV/ugc2zuCxoPZq7e5MRkcKvsPecTSPQK9Vd6vqHKHpswCX45l8ybay p0Ib4N16+cqKnj0otiwB8PxWpINGyMrjCtiwXIOAr+I0AbbSe7amnThBgGw1h+0dC+BsLduTSnU3R AaMjDUX4fxM/bQC+zJw4L/trRMRmy7Z3C/mz+yyLLgzWCA7x/5sF9N61DXp8DwvJ5QbjOtUixNtIF jcAB6HPAXgNqJpjRZW2VPWkJuenRXBiEvfnc3DbqKR96Ffig3uhTuhb5FW0b8x7r8OKqZvNOtOwP3 vneD+wGg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q67Dt-003KYD-2n; Mon, 05 Jun 2023 10:14:02 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 55C8D300188; Mon, 5 Jun 2023 12:14:01 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3A7D7244F040F; Mon, 5 Jun 2023 12:14:01 +0200 (CEST) Date: Mon, 5 Jun 2023 12:14:01 +0200 From: Peter Zijlstra To: Mark Rutland Cc: Krzysztof Kozlowski , Ravi Bangoria , jolsa@kernel.org, irogers@google.com, bp@alien8.de, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, "linux-samsung-soc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "regressions@lists.linux.dev" Subject: Re: [REGRESSION][BISECT] perf/core: Remove pmu linear searching code Message-ID: <20230605101401.GL38236@hirez.programming.kicks-ass.net> References: <3abd3693-ad87-9abf-a762-337076638fcc@linaro.org> <20230605092731.GZ4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230605092731.GZ4253@hirez.programming.kicks-ass.net> 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_NONE,T_SCC_BODY_TEXT_LINE 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 On Mon, Jun 05, 2023 at 11:27:31AM +0200, Peter Zijlstra wrote: > That said; given that this commit has been tagged twice now, I suppose I > should go revert it and we'll try again after a more thorough audit. I'll go queue this then... --- Subject: perf: Re-instate the linear PMU search From: Peter Zijlstra Date: Mon Jun 5 11:42:39 CEST 2023 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 clean. Reported-by: Nathan Chancellor Reported-by: Krzysztof Kozlowski Signed-off-by: Peter Zijlstra (Intel) --- kernel/events/core.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11630,27 +11630,38 @@ static struct pmu *perf_init_event(struc } 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; + + ret = perf_try_init_event(pmu, event); + if (ret == -ENOENT && event->attr.type != type && !extended_type) { + type = event->attr.type; + goto again; + } - 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 (ret) + pmu = ERR_PTR(ret); + + goto unlock; } + 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: - if (ret) - pmu = ERR_PTR(ret); - + pmu = ERR_PTR(-ENOENT); unlock: srcu_read_unlock(&pmus_srcu, idx);