From mboxrd@z Thu Jan 1 00:00:00 1970 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 02DACC7EE33 for ; Sat, 27 May 2023 07:40:50 +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=wUivAvyymkh0Gc5hWBH4CGQWiLZlsMErmyY3WmfRl9o=; b=KChwcbw3Zf0pwK hGyFV0wI60I0TgGJ+pwTznbJvTlwrgJZ1ocgQx9Mf+uE93wvHLPy320gkZAmWdJ2R7/NwGW8xeEuP l0HqCz2d+N7gcQhFe2MBR6MEAQ/3nudkJJXzBql6EYrfl32uf2Y4P0ilE+4O2Cg3ylAr6okALUix7 7xbJKzLaDRLUXbwOsd6d5TAd+vhXr0SfaAnCNpBvZCFaWvgVpqCEz1J2dxgbBFrcjX4Et1CyjKvVx 2rtNA6FA4wzzbXH95S6CfAyzBZ3iIWWqjtAFv4GtYTOAJkmxEDCUED5hZCtOZ1LPnjOxv+trTzuoA YNnWj1Qel1Yz4mc7F/0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2oXG-0059VN-0j; Sat, 27 May 2023 07:40:22 +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 1q2oX8-0059Sz-24 for linux-arm-kernel@bombadil.infradead.org; Sat, 27 May 2023 07:40:14 +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=kWjpW1u76sBxbsm1hYEhA0qZQ3555o3L2cIJC7DUwoI=; b=nu7BmB+7BjaPEKjepJojQfUZsI npxPCQ+mZw9T6AP46xIXekYmwsKl3TLECtG9prfsQ/QY0lxhJYG+zOIUs36TAFxKv3uYfQ+IC4sZE ngyVNZqmtqPIBW6N7fu0desI1DmTOxAD7MLKPO0EYaB3tUky+UVFSoMPOe5oXquPwVzZSKTdWTivM vmSzvTn+xO8E/gwkz1ygQOCIb9RQPUOLBqGQYTrHrzZyAMVeH3Wh7mcAxjXK2Bhv8mLYMG1viBHBw HtsaeS84l0kcEmDfSGJYe3Lo2dLgn/J5rVa3fHJOIVf1PtdCcorC7aftcfm06BH4VkZXzweG86aed IUzN9UKg==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2oH6-009Lkv-2Q for linux-arm-kernel@lists.infradead.org; Sat, 27 May 2023 07:25:42 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5653213f5c0so30400927b3.1 for ; Sat, 27 May 2023 00:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685172219; x=1687764219; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=kWjpW1u76sBxbsm1hYEhA0qZQ3555o3L2cIJC7DUwoI=; b=wBi4n8uFTdA3TszUXpCO8GKYB2uqcL4Vn0FqZlNbP1LOQK1BVmm7fF3l2JaCleCDC6 33wxtblEfCpqmbkyharFERKKEItaJEJAgPnDVWqK5Nq/2j4d1CWYZPudPXsTbuOzIyKZ wQdtuDG0uOcF6RR5xCksRwyUT4pEuoHvB4brApBxYHVzaQb5uc7udU5MiNWxh3PNYk2B Wh18NBKanrun3bGONgRozrXoYFsw2jb20t7Xk/3BS1x1UAQC+L1GcjdXGHejgYRM+93T Sf58Fu/qAZ/kAEAa8d6AovzKAWeoflzGzliHn239rljOJ6T5rGHSIeUsvNFEtU79wFeD k+yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685172219; x=1687764219; 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=kWjpW1u76sBxbsm1hYEhA0qZQ3555o3L2cIJC7DUwoI=; b=TeWpf9E2wgJqGFOxMi3r3nT7iInPobJKX/RWN+pQF265Bn91cWm5PurzPeVyQOgOss YGz94buCJSAjPkmXJKBINPGUZN1INIxMgWZQhXPC6L3VNnG16eZrXeMMQoP1XSJgrrgH 2RwQFLsekQtPYpfEMCJEnS6rx8V9awXzlj1s/DtZJU+ZoRD0UWGdf3JeA5XlR1zWaQyx bSxTqVxiQo3Nd75xDtAfdCvyGpJD7JyjzP2ZiwiopHx1pUYzN0YMZgE0k0QZw1atg2WZ jCHp9a4I2WCl/daPRLMDscMKQdmLS77yngDMN9VVT8/Oq2iGJ88IOrG50EFUrRsIHi4/ yuiA== X-Gm-Message-State: AC+VfDyUdKxRZ/ALjd8nTVYXhpHaPivq5Eq9qZt/c7NAmyBQvIza0Fhp l/qbSS5J21zhQ1CZqdTpdn5V/wNfNF0x X-Google-Smtp-Source: ACHHUZ7i1HCsYIElA4iQQBEJl+fhXqsKclMNBO4YCra2KTWKzYk4pfQkBbhwUQG7aKApbscqoqRV5WKo/Zp0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a81:8d44:0:b0:561:81b:7369 with SMTP id w4-20020a818d44000000b00561081b7369mr2447926ywj.8.1685172218828; Sat, 27 May 2023 00:23:38 -0700 (PDT) Date: Sat, 27 May 2023 00:22:04 -0700 In-Reply-To: <20230527072210.2900565-1-irogers@google.com> Message-Id: <20230527072210.2900565-29-irogers@google.com> Mime-Version: 1.0 References: <20230527072210.2900565-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v5 28/34] perf pmus: Split pmus list into core and other 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-20230527_082400_148314_D518C639 X-CRM114-Status: GOOD ( 18.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Split the pmus list into core and other. This will later allow for the core and other pmus to be populated separately. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/perf/util/pmus.c | 52 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 58ff7937e9b7..4ef4fecd335f 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -12,13 +12,19 @@ #include "pmu.h" #include "print-events.h" -static LIST_HEAD(pmus); +static LIST_HEAD(core_pmus); +static LIST_HEAD(other_pmus); void perf_pmus__destroy(void) { struct perf_pmu *pmu, *tmp; - list_for_each_entry_safe(pmu, tmp, &pmus, list) { + list_for_each_entry_safe(pmu, tmp, &core_pmus, list) { + list_del(&pmu->list); + + perf_pmu__delete(pmu); + } + list_for_each_entry_safe(pmu, tmp, &other_pmus, list) { list_del(&pmu->list); perf_pmu__delete(pmu); @@ -29,7 +35,12 @@ static struct perf_pmu *pmu_find(const char *name) { struct perf_pmu *pmu; - list_for_each_entry(pmu, &pmus, list) { + list_for_each_entry(pmu, &core_pmus, list) { + if (!strcmp(pmu->name, name) || + (pmu->alias_name && !strcmp(pmu->alias_name, name))) + return pmu; + } + list_for_each_entry(pmu, &other_pmus, list) { if (!strcmp(pmu->name, name) || (pmu->alias_name && !strcmp(pmu->alias_name, name))) return pmu; @@ -53,7 +64,7 @@ struct perf_pmu *perf_pmus__find(const char *name) return pmu; dirfd = perf_pmu__event_source_devices_fd(); - pmu = perf_pmu__lookup(&pmus, dirfd, name); + pmu = perf_pmu__lookup(is_pmu_core(name) ? &core_pmus : &other_pmus, dirfd, name); close(dirfd); return pmu; @@ -72,7 +83,7 @@ static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name) if (pmu) return pmu; - return perf_pmu__lookup(&pmus, dirfd, name); + return perf_pmu__lookup(is_pmu_core(name) ? &core_pmus : &other_pmus, dirfd, name); } /* Add all pmus in sysfs to pmu list: */ @@ -93,7 +104,7 @@ static void pmu_read_sysfs(void) while ((dent = readdir(dir))) { if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) continue; - /* add to static LIST_HEAD(pmus): */ + /* add to static LIST_HEAD(core_pmus) or LIST_HEAD(other_pmus): */ perf_pmu__find2(fd, dent->d_name); } @@ -104,24 +115,37 @@ struct perf_pmu *perf_pmus__find_by_type(unsigned int type) { struct perf_pmu *pmu; - list_for_each_entry(pmu, &pmus, list) + list_for_each_entry(pmu, &core_pmus, list) { if (pmu->type == type) return pmu; - + } + list_for_each_entry(pmu, &other_pmus, list) { + if (pmu->type == type) + return pmu; + } return NULL; } +/* + * pmu iterator: If pmu is NULL, we start at the begin, otherwise return the + * next pmu. Returns NULL on end. + */ struct perf_pmu *perf_pmus__scan(struct perf_pmu *pmu) { - /* - * pmu iterator: If pmu is NULL, we start at the begin, - * otherwise return the next pmu. Returns NULL on end. - */ + bool use_core_pmus = !pmu || pmu->is_core; + if (!pmu) { pmu_read_sysfs(); - pmu = list_prepare_entry(pmu, &pmus, list); + pmu = list_prepare_entry(pmu, &core_pmus, list); + } + if (use_core_pmus) { + list_for_each_entry_continue(pmu, &core_pmus, list) + return pmu; + + pmu = NULL; + pmu = list_prepare_entry(pmu, &other_pmus, list); } - list_for_each_entry_continue(pmu, &pmus, list) + list_for_each_entry_continue(pmu, &other_pmus, list) return pmu; return NULL; } -- 2.41.0.rc0.172.g3f132b7071-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel