From patchwork Wed May 24 22:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13254574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A68FC77B7C for ; Wed, 24 May 2023 22:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ez3wJ2v2gPcFIxOEyvjspraktzMsUU1plNUBeRmbMfI=; b=CuKQkWsef1TFtz 4T6NiAFUiXfFpRBt/ZRBpL8ZKcMI9JDKEwsw6By9W0C3bYdHc9/l5Mpohtlufak3EDsrrN2s43uvC /isIfnu5mHGLDL1Nn2VBKYTAJ2mIwJQbohYkKDTDNDPGiu95L2Mn2I5RjQtaz+6T7AtjI5QYy2/U+ 0Fo9WHIXT2QOS/oL/aY0+w9DsWom7DNSHUDsRGVZChVNAHrjN+bQpoIz7kyGe2HUjAUFgHK6elyyX bfpslLcRPoud9bT9fJCkwu8Yzvyl/mtzLmIuuMhuwJjCOG7cKdeyy/bvF+r7Xw2b0hY2lP+p6fxIt jgS7JuGyv5wFqduBevnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1xAN-00EpOu-1f; Wed, 24 May 2023 22:41:11 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1xAH-00EpKk-1M for linux-arm-kernel@bombadil.infradead.org; Wed, 24 May 2023 22:41:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/eS5iHSDHpFh4XdVaHBCbrVny8PCbF73cyIUIzaUWEw=; b=KPrt1BMO3nYQyNHJZ5t524xZyR 3L1idBkfGtt3hR6t6ZkhCPHeExcIIhK6jNCP0u0zhfjVeO6ORLG3eSkiaQg5KO6ae4wos3JTE7kwR HC3KHWTofylBmUf4VZI72G7y34QqAHQCLl0MK6yJ3WegRRdwOYi/VgJ9D33Hps670BHbyaDEX5Pjo eFiRBHVVnBJd433XZrnBHy44VujPRCOrsYsz7wVnzrzjkbhFuQGo118gdEg8naJ1i5L7ZSTHIaIs5 xZ3Tx2bNUfNeOSEzYhhzf//IL9FYFi9VWzqzIdSfAfH/DWGvq8RlF+WcNStD0fQxaNRf/GfeBnTXp FeSlkdhg==; Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1wpG-0056co-1d for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 22:19:28 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5653c160973so29010027b3.3 for ; Wed, 24 May 2023 15:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966759; x=1687558759; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/eS5iHSDHpFh4XdVaHBCbrVny8PCbF73cyIUIzaUWEw=; b=NOCz+nx/NdHrPcizU4MdSkA0WBYp0H9Nf+F0NieGY60JSYl6AF2S+CnMb/dlfziqBk SNH4dssbJwRHXcvUoZ75cIaneT6FAyO+RD40b3bYt/ivPRlyaUhPjcWffNE4plZNHk7B 85Pk3dn4eV7+z9VbZe3ftQwYaRLvlEoPyUrJecJI4zZjFdpsXLXrNFLGCCTR8yD47+lw 1lDf48a8NZvNawqoBz8WAQLdrQLFWRHgitHfKcAoqr17q16mRxGZ8JMqhlJB2UzXb7N8 oDKXnLY5ppa/bPZUkg0E5pzMtux5QWv/od7FtU+msEMoASarZrFObKcNTb6XkZJNtm8l F4Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966759; x=1687558759; 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=/eS5iHSDHpFh4XdVaHBCbrVny8PCbF73cyIUIzaUWEw=; b=ZftBR5rZYrCOL7wv0MyJYDtTuJQXf21ZudMR8UALFcwc46qFj/FhqCJUnqzme+HvCc mW0ADJXzl3ndQ143yvlpC9cKk6eUVERKTTuc2w7TExdpb+VhjCR05Ji4Egy82dnQjMYc AZBNXKOw9O2vAcVJCIOUwMV83dHasrTUyxCozn+v/QazEyZe3g2q1MXORIkaFm+dd92M U0znTyjzMCM21Iv1cGbOhpepMb8UUTlmonHbE94z2ZVoExG139JK8uwX6t5FDZuHlfGV 2fYSs6a0cRWdMbX32ytOJ0imT49Z6Uokm1t/MTQskYOcyws6B+zilRLGAK2wNkDbHgZG Thew== X-Gm-Message-State: AC+VfDy7facUJn3Yv5X9vG7GXB3C6lbG5oSAnvLBW3SPYOgbTmSLZpy7 iVst/itcGyb3ZOPxvXNdCz9HLAeXgAlA X-Google-Smtp-Source: ACHHUZ5rsi2pKjCTlzd+MdEj65Y6PrSrlVw2S+xS+bJJXjv14kZ8uWv5F1wr1NxRMs43HWII98fVEDfi8AHZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a81:de06:0:b0:55d:955b:360 with SMTP id k6-20020a81de06000000b0055d955b0360mr11554971ywj.5.1684966759076; Wed, 24 May 2023 15:19:19 -0700 (PDT) Date: Wed, 24 May 2023 15:18:15 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-20-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 19/35] perf topology: Avoid hybrid list for hybrid topology 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230524_231926_257865_81D3B1B3 X-CRM114-Status: GOOD ( 16.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoid perf_pmu__for_each_hybrid_pmu in hybrid_topology__new by scanning all PMUs and processing the is_core ones. Add early exit for non-hybrid. Signed-off-by: Ian Rogers --- tools/perf/util/cputopo.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c index ca1d833a0c26..a5c259bd5cc0 100644 --- a/tools/perf/util/cputopo.c +++ b/tools/perf/util/cputopo.c @@ -12,7 +12,7 @@ #include "cpumap.h" #include "debug.h" #include "env.h" -#include "pmu-hybrid.h" +#include "pmu.h" #define PACKAGE_CPUS_FMT \ "%s/devices/system/cpu/cpu%d/topology/package_cpus_list" @@ -469,11 +469,17 @@ static int load_hybrid_node(struct hybrid_topology_node *node, struct hybrid_topology *hybrid_topology__new(void) { - struct perf_pmu *pmu; + struct perf_pmu *pmu = NULL; struct hybrid_topology *tp = NULL; - u32 nr, i = 0; + u32 nr = 0, i = 0; - nr = perf_pmu__hybrid_pmu_num(); + if (!perf_pmu__has_hybrid()) + return NULL; + + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (pmu->is_core) + nr++; + } if (nr == 0) return NULL; @@ -482,7 +488,10 @@ struct hybrid_topology *hybrid_topology__new(void) return NULL; tp->nr = nr; - perf_pmu__for_each_hybrid_pmu(pmu) { + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (!pmu->is_core) + continue; + if (load_hybrid_node(&tp->nodes[i], pmu)) { hybrid_topology__delete(tp); return NULL;