From patchwork Fri May 26 21:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13257402 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 97AA2C77B73 for ; Fri, 26 May 2023 22:41:20 +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=ZipqBr/007idffDN+qPVaw+Ew78PcKkiDVrGjSLLZZo=; b=qDP+Po4zsdOo0q Ie4l9/3XjgKEzspUKJ4DBaB7BIF/l6F+kigup7ZoV+BT6/2y4kmEDOskeEHW9GA8lTlqBA3BQyJ+I 0wV1phFW/2a3oHOE5pZwN1BHo4BGlw8Ogao2sQLZ5fxwYqRKiQL9jqfsAk64McYSukKx886ymqAKy 9OOPnVMyhZrWCowUmCyeb5+f3Jk1sQfoE0wjhpIBSu/9rs0ey6OjM3UVpKGn9xxB+vFEI4dj+lP+r KEvix6anhgyhh29+kFTHNMOoQ4tXlJ/nnmI4mKIX97zoiWVyjinfy8ZgXTF5FKqudja072kaILXqE ZnB8XQ37KMBZJXKenQ0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2g78-004A4L-1q; Fri, 26 May 2023 22:40:50 +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 1q2g6j-0049t9-3A for linux-arm-kernel@bombadil.infradead.org; Fri, 26 May 2023 22:40:26 +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=cwNQ71nzWAtCurlrP6FCuEtDPR9XmwsHJykHXM8qing=; b=jGZRiGclY6XF4MIHR0W6BMh2yU Yr+oT6PH/IbLHdrpifFjzzX7umMAie95gZ3HUPj6F1M1FubJ0Nk1zkHncWq87sZ2EdhWdRyNiGNJ7 Q4bFQu7WMHuU45jh9CoAtRvOQZgvQFB5nSijM1+ihQLRA4kj3ghY8AnO5ocgIEa8LK9ont83RTIlJ OoMgLt7xdae9bwuE+sDKG9zp8/w5StqKWWym5EbnB/8wARf7xmASYzTzPWl7dKT0pI6TrLVL2bbyc 3XXXJOUdaqAiM8uyhUbXiAKj5Fx5mmIHPebcQPdX3uOftfo2g+MY6XYTOWgH20kDhjxr3Lo+LOR4Q QbflH1FQ==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2fOf-007irt-1B for linux-arm-kernel@lists.infradead.org; Fri, 26 May 2023 21:54:55 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba802c775caso2665542276.2 for ; Fri, 26 May 2023 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138092; x=1687730092; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cwNQ71nzWAtCurlrP6FCuEtDPR9XmwsHJykHXM8qing=; b=0ZoF1unr/orlOsISPFYBj91qnKAXDq0B3EiiKU5OTSFpjOBXJA0aWUu1j90QwPC9U5 zQZY2svERZPcvFvL5HADSim5BXMLe99VMVh5TaUANLTqD7x57rwQnP1Yj6t1NAJZ1BB9 s2feus1/WhOreHXwAcdg/EC9WX3hMLCAq32rjeeqqhUEz1bGCoUAKsC9/ygb8/bPWQRY JKzFdUN8fKyeG+O7DZke/2EGzjVo/PX1PD3tMR3oHXRh/0Bu1UyUfE+STE6HwpM4LzL7 qV8BwVBzee3XEg2GNqk8HKXajmUgGUssAU+mSA+Ysk8uY/HepVstX0wwIYt+3XZa4buC 3wBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138092; x=1687730092; 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=cwNQ71nzWAtCurlrP6FCuEtDPR9XmwsHJykHXM8qing=; b=ZZMGPARIpD6WH8fDmw5J3bqK/7qOCiGaF9k7wxjKjm23xzAsiydz4yMN+Wtu01ggbF /jt0eWKmjL9TU1Vj54KxwJwNzv0CN9Ybr2cOOWS0Gt/sFwriH+N160tVcBJgxAMstpWp 6QbdR1u2ww0O0jNo7WC1VWwZuWVqQsB+i9K6zHdBJrAYGX8vilAfsAcEsAz0fmuR+vem Xf9eygi+zLfjmGZdwfChJokE2ZxOV8+AnT32qSI/LRE0YyHYTLLyQX6zQSuj2AhKRQHp g1hTIu6i+qxZEKKQG77EBXiHMB/lVatzQ9aT8Y/8aItld/hZiWIPVm8VeZoSeCcvB/SH KFiw== X-Gm-Message-State: AC+VfDyIKE64tpUHUGPY0mDbgw3XLCNsq4hLNCvlBeJlfHVGqBpOami2 7eEkoI1sinOqiF2P4ciJA42zZ5VNZC9I X-Google-Smtp-Source: ACHHUZ4HPM1O+jGGQYqWpg/LatJr3hW14F3fnfsoBZ0mfOfU/MqJU94PR4Mc+EfWfWfhhCNIIU52c8Dpgsvi X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:2646:0:b0:bad:41b:f343 with SMTP id m67-20020a252646000000b00bad041bf343mr1730299ybm.1.1685138092595; Fri, 26 May 2023 14:54:52 -0700 (PDT) Date: Fri, 26 May 2023 14:53:52 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-18-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 17/35] perf pmu: Rewrite perf_pmu__has_hybrid to avoid list 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_225453_508930_A87E308E X-CRM114-Status: GOOD ( 14.21 ) 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 Rather than list empty on perf_pmu__hybrid_pmus, detect if any core PMUs match the hybrid name. Computed values held in statics to avoid recomputation. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/pmu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 83c7eeb8abea..5a7bfbf621d0 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -60,8 +60,6 @@ struct perf_pmu_format { struct list_head list; }; -static bool hybrid_scanned; - static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name); /* @@ -2013,12 +2011,20 @@ void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, bool perf_pmu__has_hybrid(void) { + static bool hybrid_scanned, has_hybrid; + if (!hybrid_scanned) { + struct perf_pmu *pmu = NULL; + + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (pmu->is_core && is_pmu_hybrid(pmu->name)) { + has_hybrid = true; + break; + } + } hybrid_scanned = true; - perf_pmu__scan(NULL); } - - return !list_empty(&perf_pmu__hybrid_pmus); + return has_hybrid; } int perf_pmu__match(char *pattern, char *name, char *tok)