From patchwork Fri May 26 21:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13257424 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 DBCAAC7EE32 for ; Fri, 26 May 2023 23:05:58 +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=dP/XDUvIk8AUkdR0OogCE3YGOM1f0w2hYTxKxXZkW4w=; b=Kqmi8Ac/PGbSNR ZiwAcp1y/ijeVkrmeGFKPkmMXKle2TITmY6CDg1mhgpW0vaXZ3+32z+FY/ntEq78XDcjnyv8r4f6y HcFu2tKisS9orfkiWn24oUJOg1meAmkxRQws59P5PMicxcbs3gVGH2P277bmUqPBoB9emoutu1kxf ImZxCw3jxzYGRmWiQgkwjoB0D5k1JK7KHShf5ZgF8VJltzkAK4iYrhjsZ39prnxNZk75U5WG8xH9M ItN2rRK0j1K8M+V9cy5OJpV/cEED5OhP4V0p9JywHBlvc44tPenrFFCGZlc5G1gcnjlUKVJbBlJkh /NLZf571n94OccxLqM+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2gVG-004ErS-10; Fri, 26 May 2023 23:05:46 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2fOk-0043B1-0e for linux-arm-kernel@lists.infradead.org; Fri, 26 May 2023 21:54:59 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-babb3528ce5so2622130276.1 for ; Fri, 26 May 2023 14:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138097; x=1687730097; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=csOWTo951DO4baytRGvCV+AGtywhGll+tnrLNxjPQY0=; b=j9NAAVXq5iGO4JhTa7MDsqCpgld3dg374djTNEgrNq8tyZyjPTnlp3eazGoLfZr3RK IkEh8Xa9RttPpnUSLFgXiMejZ6BUZ9sKk6d48yN9TF1JzCCP7dz5ClHlU8c9hD1mnKWh DaSelOVeHG9WXCdD09QHcmDrSZs+iZW/DMyZEPx5xrgB6Xxp46jryiTZWUzt7auxYmP3 hTYCfePL36YKY3tU7vCBSGErERVzdvrcWnFVss48XlHn72LdegcAc+zpzq0N7mhbm5pU B/wOu6p5OR7eXgI5UWfesif2QOnxNDkZRsg1N3u/6X6bJomR03NBuhOox9cbMslglvhs u3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138097; x=1687730097; 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=csOWTo951DO4baytRGvCV+AGtywhGll+tnrLNxjPQY0=; b=FlCZt5r7uxJTIjTKMWsXMdp3Ls1uV2ILnKynrQIuKOrdoVIg8F+20pnzA3zdpPOwbt +Ac8pHSaKPy9wKbS3f9xJwz9PBCmUs/hH/OoNuIA+hC8ELhHEQ0s+zeAPd/xwO+f1SZW AhTKzUaKRt5+te/vlS/P2IpCQZvhcbEpV9SnyJ8XW5Rrf9GtIX9y0arIVDcDaB9Lq9OQ AWcD4zfziaG2TKhNQTJl1zUKlvxixEfrnISmA4zke9wKz36RbQ/YrD6Bx6O3g442I+yr isV/hReaD+KYW9JjKWd+2klCEa9BANtoH/1NcsiX3p927HHu7A9/o/VQRoW5iYVVzSL9 wC9Q== X-Gm-Message-State: AC+VfDwzC1JugtuvHyvlJyNBM3tRFiJUwRmMIrWjfCGrQABtOHLGGU1y kebrxaanEjHr9MoSFpbs+aXhV4BsNSYZ X-Google-Smtp-Source: ACHHUZ6rK9vXFFe6bA1cOlIdln1XgJFys+yiHDV71eOLRBfjur55rI9Xe7Cku48l9+iEiobNEnOmOe69OKPH X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a05:6902:1341:b0:ba8:2e79:c193 with SMTP id g1-20020a056902134100b00ba82e79c193mr1253603ybu.12.1685138096930; Fri, 26 May 2023 14:54:56 -0700 (PDT) Date: Fri, 26 May 2023 14:53:54 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-20-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 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-20230526_145458_246405_BA30DB94 X-CRM114-Status: GOOD ( 15.67 ) 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 Reviewed-by: Kan Liang --- 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;