Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1238665rdb; Sat, 7 Oct 2023 20:39:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6hGKJAbwUM3T5vHXL3TRXA2ZlaJZYMheyzVzkSSrHMZZ9g/8sy0NPvktxROGPUSoGVhxG X-Received: by 2002:a05:6830:10d0:b0:6bf:5b30:5b69 with SMTP id z16-20020a05683010d000b006bf5b305b69mr12746643oto.17.1696736378618; Sat, 07 Oct 2023 20:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696736378; cv=none; d=google.com; s=arc-20160816; b=CeJ8wn1eZ/qlOzVJX+Wh3vwFq9ZWkVcsrxjQvU++Wy/pNv+CjwHejIMBqBwVpA0re1 wx7aYLTbWZ1w4Dif7F75kLbFSImcFWTNOvp+auzgiizU/FgXVDmfkoMB2b9ubjVCxzQ/ GbAndaT5pd7BBvep7+4g6PoJqJ2N1necYsTNQBOjAmgqPHQLzCHHbi7kU4eDkot+wOru 3lLveUznG894zxEOwXIvLfgzfTUJoDTDWI6gIVceI5n4WynMxpnK5Hho8Cs4xDXYTxzT b6vSRauGykfX5Fs6w7C/visU1PEPwlBy7EEytyyZ8Utu4jQfGhr/55f02tRMDTxEI+FS vHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=ylzNKLGVeAh/ldTx0yKlUga9N/KlAm4RvWdfVRz7SHY=; fh=nT2wTZgXEMIxp+FtTDyH16GzTOUAWXhJhssHDYMKbso=; b=j9RIbNSGO6v+7eVVAUns5dDUH8rh3QztvFrBymwGlekFdaa23O6LkFvvu2xAvnfOnw SRUB1fXIW4vhpZQbawQA5kn3S071fCFOP6tL/ep6z+wGbh2tBYK4l7c5JKxdk/NEXj+d NOkft3m8TMKHwHUWtypJ6n3FtbXZtqtqvrGOlHuAnBkJoGJpWkzuIRXFQrIiRzh428Za si8uiEkfGXQe4d+LzjygX62Y6aym5m/H5R29xmAjXC/pBHffg6b4sNlCmVCD3pGbbRY1 yAO1+qgyAhYyiwn9730rnlhr8E9aqA/FM4g1g7jkrY1+lv39KIeHY7FAZlZ5hUeWd4GZ aUwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id g67-20020a636b46000000b0058933a74376si6786321pgc.70.2023.10.07.20.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 20:39:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3A22D8051ABE; Sat, 7 Oct 2023 20:39:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344345AbjJHDj3 (ORCPT + 99 others); Sat, 7 Oct 2023 23:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344309AbjJHDj2 (ORCPT ); Sat, 7 Oct 2023 23:39:28 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A534AB9; Sat, 7 Oct 2023 20:39:26 -0700 (PDT) Received: from kwepemm000003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S379T3S4JzTmNK; Sun, 8 Oct 2023 11:35:57 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) by kwepemm000003.china.huawei.com (7.193.23.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sun, 8 Oct 2023 11:39:21 +0800 Subject: Re: [PATCH v1 6/7] perf pmu-events: Remember the events and metrics table To: Ian Rogers , Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Thomas Richter , Ravi Bangoria , Kajol Jain , Jing Zhang , Kan Liang , , , , References: <20231007021326.4156714-1-irogers@google.com> <20231007021326.4156714-7-irogers@google.com> From: Yang Jihong Message-ID: <39b28ad5-8086-76ed-a4c6-bfc8271d226b@huawei.com> Date: Sun, 8 Oct 2023 11:39:20 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20231007021326.4156714-7-irogers@google.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000003.china.huawei.com (7.193.23.66) X-CFilter-Loop: Reflected X-Spam-Status: No, score=2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 07 Oct 2023 20:39:36 -0700 (PDT) X-Spam-Level: ** Hello, On 2023/10/7 10:13, Ian Rogers wrote: > strcmp_cpuid_str performs regular expression comparisons. Avoid > repeated computation of the table by remembering the table in a > static. > > Signed-off-by: Ian Rogers > --- > tools/perf/pmu-events/jevents.py | 48 +++++++++++++++++++------------- > 1 file changed, 28 insertions(+), 20 deletions(-) > > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py > index fd009752b427..8d8d5088c53c 100755 > --- a/tools/perf/pmu-events/jevents.py > +++ b/tools/perf/pmu-events/jevents.py > @@ -978,28 +978,32 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, > > const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) > { > - const struct pmu_events_table *table = NULL; > - char *cpuid = perf_pmu__getcpuid(pmu); > + static const struct pmu_events_table *table; > size_t i; > > - /* on some platforms which uses cpus map, cpuid can be NULL for > - * PMUs other than CORE PMUs. > - */ > - if (!cpuid) > - return NULL; > - > - i = 0; > - for (;;) { > - const struct pmu_events_map *map = &pmu_events_map[i++]; > - if (!map->arch) > - break; > - > - if (!strcmp_cpuid_str(map->cpuid, cpuid)) { > - table = &map->event_table; > - break; > + if (!table) { If there is no matched table in pmu_events_map, perf_pmu__find_events_table() will enter this branch for repeated search each time. Or do we need to use another variable to indicate whether the search has been performed? Thanks, Yang