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 17ADEC7EE23 for ; Sun, 21 May 2023 20:07:38 +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:In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3WTVW8DRY9UBitlM0KYfP6FKKjLBmhIVH0PHqK8sqXM=; b=OyKbDCva5EF2Or 3ZhAkt2SeT9QzvGPZ45zwXJXhVwNs1fW2xb9Y3OduCpHwqVSGhVB49avwKztgbZNjwB0KYnlp73He p9ooDoT06fMR1sqpxM3rzeBfj/mq0UnZAOvMjrnv2VjceLVFVV46125Ay7KItKDhl9+Oj6zrzhcm7 KY7+pNu0PJUxApYWIhKZKKob8y+Rx5/Z73QrBwDwFlPTileBOvnGkxPql2doM8YbU/mPA2wbbJD6S klI13vnbOXxoTT2gPa84tSjxg0nxmPTWel+1+g2sme18MdZsYAXV3DRML+ovUCLJz3Iq0VdM5xxyZ 4Lr0DVhD9NICwoS1hkyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q0pKg-004ZXM-0P; Sun, 21 May 2023 20:07:10 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q0pKd-004ZVr-01 for linux-arm-kernel@lists.infradead.org; Sun, 21 May 2023 20:07:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684699627; x=1716235627; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=HwsbC2jKcQli9wh7b3iVXWoPZB7P/2qtGKKljalL3m8=; b=PGqfPefdhSAkXY3cwL/Ojyy+7dM4vNK7oGAWT+0ockZl6ePFIEb8JLI/ tthH4CZO+eePRi+ojOYDETUh0b+qGiiHuY4Ly5pRbnOHugzfyK/Oo4hLn mRgMOBfXmcA8EyMThYJwR1fpQsKbU4Y86V97E6ISNilIEA/mgLUuPloO7 tFTPt+AlDo/60LOo0cmFvuVjGRN/vCx0v+Zt7ry8UvsvXlRs94yiPS8J8 fioKzns+Mm4PzgF6SF70s6M2mJnuN00jYr5TmWOyZKd8DGQQY0ykcNOBP PNgDiIEwLf/rgwxiGd+y+2wyXGFQ5RNdd0hQYWOSxLtxCAafFin0DXw7P Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="439117230" X-IronPort-AV: E=Sophos;i="6.00,182,1681196400"; d="scan'208";a="439117230" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2023 13:03:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="949809290" X-IronPort-AV: E=Sophos;i="6.00,182,1681196400"; d="scan'208";a="949809290" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 21 May 2023 13:03:05 -0700 Received: from [10.212.161.251] (kliang2-mobl1.ccr.corp.intel.com [10.212.161.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 8572C580BA0; Sun, 21 May 2023 13:02:58 -0700 (PDT) Message-ID: Date: Sun, 21 May 2023 16:02:57 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v1 20/23] perf pmus: Split pmus list into core and uncore Content-Language: en-US To: Ian Rogers , 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 , Adrian Hunter , Kajol Jain , Jing Zhang , 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 References: <20230517145803.559429-1-irogers@google.com> <20230517145803.559429-21-irogers@google.com> From: "Liang, Kan" In-Reply-To: <20230517145803.559429-21-irogers@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230521_130707_102463_6C97E8AB X-CRM114-Status: GOOD ( 25.49 ) 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 On 2023-05-17 10:58 a.m., Ian Rogers wrote: > Split the pmus list into core and uncore. This will later allow for > the core and uncore pmus to be populated separately. I think the "uncore pmus" here means the other non-core PMUs, right? If so, I think the "uncore pmus" is misleading, since we have a dedicated uncore driver/PMU. Maybe we can use "other pmus" instead. Thanks, Kan > > Signed-off-by: Ian Rogers > --- > 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 2fb28e583366..dd029a810147 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(uncore_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, &uncore_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, &uncore_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 : &uncore_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 : &uncore_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(uncore_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, &uncore_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, &uncore_pmus, list); > } > - list_for_each_entry_continue(pmu, &pmus, list) > + list_for_each_entry_continue(pmu, &uncore_pmus, list) > return pmu; > return NULL; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel