From: Reinette Chatre <reinette.chatre@intel.com>
To: Babu Moger <babu.moger@amd.com>, <fenghua.yu@intel.com>,
<shuah@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<ilpo.jarvinen@linux.intel.com>,
<maciej.wieczor-retman@intel.com>, <peternewman@google.com>,
<eranian@google.com>
Subject: Re: [PATCH v3 2/4] selftests/resctrl: Pass sysfs controller name of the vendor
Date: Fri, 14 Jun 2024 11:38:18 -0700 [thread overview]
Message-ID: <fc551b62-6afa-40f8-b030-9e43253881db@intel.com> (raw)
In-Reply-To: <f45784f8882fa41d454ac3b35b203ee6d04ecc25.1717626661.git.babu.moger@amd.com>
Hi Babu,
Subject and changelog mentions how controller name is "passed" but the
patch does not seem to "pass" anything new.
On 6/5/24 3:45 PM, Babu Moger wrote:
> The test detects number of memory controllers by looking at the sysfs
> file system. Detect the vendor to pass the controller name appropriately.
> So, that rest of the code will be generic and can be used to support other
> vendors.
>
> Also change the search to look for the full string "uncore_imc_". Replace
> the sizeof with strlen.
>
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
> v3: Change the search string to "uncore_imc_".
>
> v2: No changes
> ---
> tools/testing/selftests/resctrl/resctrl_val.c | 22 ++++++++++++-------
> 1 file changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
> index 2d5e961b3a68..23c0e0a1d845 100644
> --- a/tools/testing/selftests/resctrl/resctrl_val.c
> +++ b/tools/testing/selftests/resctrl/resctrl_val.c
> @@ -10,7 +10,7 @@
> */
> #include "resctrl.h"
>
> -#define UNCORE_IMC "uncore_imc"
> +#define UNCORE_IMC "uncore_imc_"
> #define READ_FILE_NAME "events/cas_count_read"
> #define WRITE_FILE_NAME "events/cas_count_write"
> #define DYN_PMU_PATH "/sys/bus/event_source/devices"
> @@ -206,24 +206,30 @@ static int num_of_mem_controllers(void)
> char mc_dir[512], *temp;
> unsigned int count = 0;
> struct dirent *ep;
> - int ret;
> + char *sysfs_name;
> + int ret, vendor;
> DIR *dp;
>
> + vendor = get_vendor();
get_vendor() is already optimized to only need to do actual detection once.
I thus do not see a need for a local variable.
> + if (vendor == ARCH_INTEL) {
> + sysfs_name = UNCORE_IMC;
> + } else {
> + ksft_perror("Unsupported vendor!\n");
ksft_perror() also adds a "\n" so adding it here is not necessary. Also
please drop the exclamation.
> + return -1;
> + }
> +
> dp = opendir(DYN_PMU_PATH);
> if (dp) {
> while ((ep = readdir(dp))) {
> - temp = strstr(ep->d_name, UNCORE_IMC);
> + temp = strstr(ep->d_name, sysfs_name);
> if (!temp)
> continue;
>
> /*
> * imc counters are named as "uncore_imc_<n>", hence
> - * increment the pointer to point to <n>. Note that
> - * sizeof(UNCORE_IMC) would count for null character as
> - * well and hence the last underscore character in
> - * uncore_imc'_' need not be counted.
> + * increment the pointer to point to <n>.
> */
> - temp = temp + sizeof(UNCORE_IMC);
> + temp = temp + strlen(sysfs_name);
>
> /*
> * Some directories under "DYN_PMU_PATH" could have
Reinette
next prev parent reply other threads:[~2024-06-14 18:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 22:45 [PATCH v3 0/4] selftests/resctrl: Enable MBM and MBA tests on AMD Babu Moger
2024-06-05 22:45 ` [PATCH v3 1/4] selftests/resctrl: Rename variables and functions to generic names Babu Moger
2024-06-14 18:37 ` Reinette Chatre
2024-06-20 15:43 ` Moger, Babu
2024-06-05 22:45 ` [PATCH v3 2/4] selftests/resctrl: Pass sysfs controller name of the vendor Babu Moger
2024-06-14 18:38 ` Reinette Chatre [this message]
2024-06-20 16:02 ` Moger, Babu
2024-06-05 22:45 ` [PATCH v3 3/4] selftests/resctrl: Add support for MBM and MBA tests on AMD Babu Moger
2024-06-14 18:39 ` Reinette Chatre
2024-06-20 16:18 ` Moger, Babu
2024-06-05 22:45 ` [PATCH v3 4/4] selftests/resctrl: Enable MBA/MBA " Babu Moger
2024-06-14 18:39 ` Reinette Chatre
2024-06-20 19:11 ` Moger, Babu
2025-10-09 2:45 ` [PATCH v3 0/4] selftests/resctrl: Enable MBM and MBA " Shaopeng Tan (Fujitsu)
2025-10-10 15:38 ` Moger, Babu
2025-10-14 7:31 ` Shaopeng Tan (Fujitsu)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc551b62-6afa-40f8-b030-9e43253881db@intel.com \
--to=reinette.chatre@intel.com \
--cc=babu.moger@amd.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=peternewman@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox