Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2543763rwd; Sun, 21 May 2023 23:55:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zPOLzgvAg5rcQuepQFgf65OfcBwimjhpZgOMIgc2ocKmT7SWpXMU3fKQhO0L+wrQRlAfS X-Received: by 2002:a05:6a21:6d92:b0:10b:4330:1de6 with SMTP id wl18-20020a056a216d9200b0010b43301de6mr3748850pzb.10.1684738558579; Sun, 21 May 2023 23:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684738558; cv=none; d=google.com; s=arc-20160816; b=oDutTq9s6AVbxifYVP4fzyuMejuz8V+EhSaJgbgf1e9BFdMAtqZ7iDgk4QFF6AN4zZ XBixk1KDAiIoE39fJSW69y5RL7Qn9maCxbfEjiaAu8UH1Cc0AFyRps9UFE8Q24pcstmp 1kcv82Vrl5wUbs14UTJzrZQ12yntTve5HiahO4uM55TSkwiQIMc0fXj8IItRAq9uWWw2 HoRFNkZwG97QebTBBfSRkIysUwvV8pvWZCjhtNH+yaMCNLc73swNsClyEdfIifTgeCeO bUPhhOhqwRb8shg5qMAd4kND134vt2nyaR2QHyLauboritgQ6PxRmZtuk+My+u9/VrRi 1Zpg== 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=AR9zIJFSwa/PWauN3jIDvjQbr00g5VzBP70Tf1LOL1E=; b=dGp70znqe5ZvSJAG0jT8Z4Of4chmgeuQFI18mClvYnlS6g5YetDB0Hix8teuQ25CK4 Vvt3KcyE82HTO0oDvOAj7u6hCOLQh2UmibB+2Rf2EdvLLhVS8s5YQ/XVq4MjZIAQXhp5 FCP/Fy6KgMaKTa2A7ClPxhUirn5m+YPKoXD9iiRmbaGROrrNdRfiMXQFnnq61+4DXZ5X 1kU4wxXoZFHVr0dDAEF2QZFeR/wKgH+ZI0UWbzCYGIme9BoXtzBzjkQwBKVy7gMPs6Xu hOERT0ZqJZwfiv1BkjbJ0bt5AUYw2X2jg9Kz605EZ2tXAoZ9Y6Wrjkk14ChTksaH5K0l 7HSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=rQdTaU9C; 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 ft8-20020a17090b0f8800b0023d3fad2294si4134520pjb.10.2023.05.21.23.55.43; Sun, 21 May 2023 23:55:58 -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=rQdTaU9C; 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 S232170AbjEVGrQ (ORCPT + 99 others); Mon, 22 May 2023 02:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231872AbjEVGqI (ORCPT ); Mon, 22 May 2023 02:46:08 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEC8B1735 for ; Sun, 21 May 2023 23:44:53 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba8bab3b392so6666442276.1 for ; Sun, 21 May 2023 23:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684737870; x=1687329870; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AR9zIJFSwa/PWauN3jIDvjQbr00g5VzBP70Tf1LOL1E=; b=rQdTaU9Co7hmCz7sZhlTtMZNm3PLADpPrQkIYy4P6ZRDmrhzsp6Xf0YAjRm0wBZdn+ 6xDYWZ++iJgI6JA/TGL8WcomWza08xozk8lfhLPjUgoHYFyir2BnZuybBvqke06qMHiL Ks4GWm+M4VtI/9tZt17Lc5EgktlOwb2PxgJuYJvEljGKwIkIAmtJkdUurOIUjmzFgkyi u9cG90qy2vNY6gDgClRU/aMiY994YcRs9Y/JPbQTmuzIwlqn75sDUp+W1KRj6BpWpW+t FVrnRzdTvlOE7agFuNOID8UTjbXD2bmq8YnConWaa1Uwsej2BW3iD0MJjU0dy9mKbCxo K1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684737870; x=1687329870; 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=AR9zIJFSwa/PWauN3jIDvjQbr00g5VzBP70Tf1LOL1E=; b=JOUlEyeus0k+Dl4RnKZ+TBdVkS0CICBZp94uze3g0SHFOWtRpsdpSXbpqi2m37Rqsy 99jSfSYXvZtVKtnizUdlPQaBvl9rMpEcqAzIykZG+butSnbaPC+RXqH333+MoM8j7B+F hF4nzSNe5ty2ZyThdv5VopWFEq18XYpaorc12AdC9iNDTN9n9q5sJiSr2wzhmAPcr5mN dDQ5NmBO+Kcit2BN3E746n3IIrPl9U60eMrR3c19W9d8ltGgjlMKUAyp09Vxcx8766rr efZ45dlmvJdQQWmjXe6RTdCbAonFcj533esMmLB2H/qd3RgGYrp5Q23e5nUsxaDziJyh Cg3w== X-Gm-Message-State: AC+VfDxNEE4XeCNiiiYs60T5ccf02HvY3CVxfaOy3EFJ5885Hbo4Z3iq zK/UJ8H+s2srR+oRFeZDxdPZ9+oUZ1Cf X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:48d9:8c21:e099:7301]) (user=irogers job=sendgmr) by 2002:a05:6902:1343:b0:ba8:4d1c:dd04 with SMTP id g3-20020a056902134300b00ba84d1cdd04mr6161248ybu.1.1684737870515; Sun, 21 May 2023 23:44:30 -0700 (PDT) Date: Sun, 21 May 2023 23:43:30 -0700 In-Reply-To: <20230522064330.189127-1-irogers@google.com> Message-Id: <20230522064330.189127-24-irogers@google.com> Mime-Version: 1.0 References: <20230522064330.189127-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v2 23/23] 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 22e9e46ab765..ce75c7adca84 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