Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp151338rwd; Wed, 24 May 2023 15:49:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bUAqjdUa+k3Whw4TlA7dp0owKPd3DDQBJGOph0dHXvueaNK0DQXb9VndbE+blh46N3kho X-Received: by 2002:a17:90b:3b91:b0:255:70e1:e46 with SMTP id pc17-20020a17090b3b9100b0025570e10e46mr10017071pjb.21.1684968558847; Wed, 24 May 2023 15:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684968558; cv=none; d=google.com; s=arc-20160816; b=y3ii10oxPujJue5v2qAGBJ4/eBLh7DbkS7H9sYw7MkbncpxasfD8IyVSnWz389Im6v jBj4uqldDSx/xZS5mtrDs65bkuHc3JUobQrTpMvjA7AD7oGYRC5A8vCszjiEnLZTWGCG GpOZfqKuPrzej8hv7AfceDBMFZAlUMf5NX60apC7+jxcIVqtiCh5Rq81bSKzw9oSuGgn qkHt/Mw1Bm25QmolG0y6gMJbWb+fdudwNvm+eFJiMUfoHdkWd+ZhuPgIA2yPro37Aj1o ZibHvt9AeeCk4Ipi9yWivYM7cNm/SBwD9ViXdLzLSs7nV8vUMyY+Hpb+BiUSfA+akpRC UYcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=Yt6BXRhpcaagH+Rv9t2cYW9/1vlblP5mhKX6P/6LKqg=; b=01SohEIih2ps7F5P1gDKik/Lzjh4bhQIlfsbV8Wxf+lUMkqUX5f9eK59e7HME08FsT x869ySmWLar9WpkBG+BiQa7MJ6ad+bSzeEBZaV4Pjt6TEJVY/mfqVbH3yNp3nfmC02/N N32dguF38hQ8fCgSw7BKcoyUZaQcU13WZ3OqVUZC7KCu0egm5o5VtMsmXfPbAFcGqdQq OWaMHxQu+k7b7imK0MnQma024NvmDbKLdxRzptPyIQSif83+cqdR7gNQrgUIljdtg8zS T69F1/tD+zEwmbrAj2MkQ7pEQxAzHnp6QRzO+4/QVwKRkQjxfLqmgLtG9lEM2fS4Ef9F xtEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=dJbzSZQQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y186-20020a638ac3000000b0053eef60f940si4003967pgd.765.2023.05.24.15.49.03; Wed, 24 May 2023 15:49:18 -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=@google.com header.s=20221208 header.b=dJbzSZQQ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238405AbjEXWW3 (ORCPT + 99 others); Wed, 24 May 2023 18:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238285AbjEXWVq (ORCPT ); Wed, 24 May 2023 18:21:46 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F367B1A1 for ; Wed, 24 May 2023 15:21:06 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-babb3528ce5so2695632276.1 for ; Wed, 24 May 2023 15:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966789; x=1687558789; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Yt6BXRhpcaagH+Rv9t2cYW9/1vlblP5mhKX6P/6LKqg=; b=dJbzSZQQie8CHjExrHF45ZUOMtyCX1iCnt44dhP0OcA5CdcTLww+elNVsvkuol2Vqo 6SAtAw+mNF64uiMUukV3FIbXgscnC1H8RCedPPxT5kIPawwbC1Azu8buOB18bZXd+OBh K3tOIFrGyS9Dw+tYYATG1AYjKwtz4qN4zHHTljemHMmZIW5OkZgdqresjHxIHakHZCzR EmD55LBaK2EO2bV3CAnhi+0njGSbHSFnrYT/+5aU0DvPHHsrzXclbobUBLfZRGF2mCZj 7JM5COM39iCmu26T0JCSACrCzOLBe9AmUPWFHwldn/SzoFkfA1BoWDjl8nwEoAD3lIb5 CapA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966789; x=1687558789; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yt6BXRhpcaagH+Rv9t2cYW9/1vlblP5mhKX6P/6LKqg=; b=Jaj09XycLnMAtaIeHq380/L3WOzmf0RAe55SBI+8e5qkWZWLpRXwbn77hL7ByJ4cNO lpO+hyMzX27BpYpHxO2YCUtBZhMPd0wwvjGV/SbFAXWtp0v4jv5koGW178XZ2q1HUK39 sIKGPx4dwGfpFwYoSvQVkYkGovF1hOv5BPjP8XEgVQucbkVI5f8gOnKEXs4EKPG1BD+f qjrME9ZtPZgBx5Bnu/uUu4R+0shMXmqMUVMS6JXYyXT6AWk7FVehP9dOHIyCuFrohnsx wbUWM7C4u3riTQmhNDVi0x1nJiDR7l/hC2em64ma8mevb8asEfXWo3M8V3Xb8EHY2tph kdwA== X-Gm-Message-State: AC+VfDwLX9HGMoa4a9xv7TAAyPETGJwe4ql7zB837Fy9hJ2gVtf+9KXN 7FOtxwC0mNoINOQWW+LMFObh5CnEO+8K X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:2414:0:b0:ba7:68ff:a441 with SMTP id k20-20020a252414000000b00ba768ffa441mr605861ybk.0.1684966789477; Wed, 24 May 2023 15:19:49 -0700 (PDT) Date: Wed, 24 May 2023 15:18:28 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-33-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 32/35] perf pmus: Ensure all PMUs are read for find_by_type From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 perf_pmus__find_by_type may be called for something like a raw event, in which case the PMU isn't guaranteed to have been looked up. Add a second check to make sure all PMUs are loaded. Signed-off-by: Ian Rogers --- tools/perf/util/pmus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 2c512345191d..6ecccb5ad03e 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -142,7 +142,7 @@ static void pmu_read_sysfs(bool core_only) } } -struct perf_pmu *perf_pmus__find_by_type(unsigned int type) +static struct perf_pmu *__perf_pmus__find_by_type(unsigned int type) { struct perf_pmu *pmu; @@ -150,6 +150,7 @@ struct perf_pmu *perf_pmus__find_by_type(unsigned int type) if (pmu->type == type) return pmu; } + list_for_each_entry(pmu, &other_pmus, list) { if (pmu->type == type) return pmu; @@ -157,6 +158,18 @@ struct perf_pmu *perf_pmus__find_by_type(unsigned int type) return NULL; } +struct perf_pmu *perf_pmus__find_by_type(unsigned int type) +{ + struct perf_pmu *pmu = __perf_pmus__find_by_type(type); + + if (pmu || read_sysfs_all_pmus) + return pmu; + + pmu_read_sysfs(/*core_only=*/false); + pmu = __perf_pmus__find_by_type(type); + return pmu; +} + /* * pmu iterator: If pmu is NULL, we start at the begin, otherwise return the * next pmu. Returns NULL on end. -- 2.40.1.698.g37aff9b760-goog