From patchwork Mon May 20 12:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797934 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24EC755E6B; Mon, 20 May 2024 12:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208245; cv=none; b=k9MZAEQwKhwEziWMx5bwsuFGdIFEagZXIyZiqbKjwhekvNPChBI9LbR4zWfKF4eN9xrU6JcXJYjNjtPScMBWSKmkkPWSUZUK23EvRP3s82xsyFcIZI6ZY4fO6C3w9wnYGv1BzgX8rKWi7k9wxtFYw5JA04zOv0PKngu92eBVDWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208245; c=relaxed/simple; bh=wdgylQ0cZW/zhQH3/+NSWx0tyAmUR7W4z8W2bTRAPY8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=H6KDizB3JNqPba3KV18Uc+fSdWCAh7fMGBzmt5H2MEpQaAovNFljJBZNR1QtTRITpUnTQKmFKyNNt1wMtAL3wWVg4GrDHEwiu7vtlLU6RABjU3aW3gVkNw2yO8pZnD89wGffBy8ysJIXl66wi9HlcDk4AJq32Ii/GDe/4RqISvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Pn4TnwrM; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Pn4TnwrM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208244; x=1747744244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wdgylQ0cZW/zhQH3/+NSWx0tyAmUR7W4z8W2bTRAPY8=; b=Pn4TnwrMBqCX7COuYumWkW4xJPLCRxLnc0oUqy5+dj8IvmPXrIGp/mcv 8AqmzcSnHauH3dGv18UW94ZWp0FsPztM+Rwy0jqd9Uwy8GQEiZGhCrJ6F oxBu60PiMJS9OsxAEyZeT8OkOq83miPmyi8yrhUUX+U2Ihaj30nQbWZJP xSN2B2OUL2lxxLb/sVDwiYx9fBvlW8ITWo8dSW0UVwwf6khGu01tvJdZG Md/AZTP9yL46y5Hu14vnQCqw6RnAeV1i/3tDnR/sHa7AdOEIzf/QX1kIj FURBor+nu4esvnNQROmnglV2Erge6LFllU2HtaTr4QiRAHmwm6g3npCqe w==; X-CSE-ConnectionGUID: PxHWdLoBTWWVDzJLzt648A== X-CSE-MsgGUID: qHv0/9QtS0S8yTq1wGslYw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12444532" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12444532" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:30:44 -0700 X-CSE-ConnectionGUID: rdwgDbY0RnGxJr6wJ/C3Vg== X-CSE-MsgGUID: 9poR2QDFT8yyYFjohmG2Xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="37115264" Received: from unknown (HELO localhost) ([10.245.247.114]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:30:40 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 01/16] selftests/resctrl: Fix closing IMC fds on error and open-code R+W instead of loops Date: Mon, 20 May 2024 15:30:05 +0300 Message-Id: <20240520123020.18938-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The imc perf fd close() calls are missing from all error paths. In addition, get_mem_bw_imc() handles fds in a for loop but close() is based on two fixed indexes READ and WRITE. Open code inner for loops to READ+WRITE entries for clarity and add a function to close() IMC fds properly in all cases. Fixes: 7f4d257e3a2a ("selftests/resctrl: Add callback to start a benchmark") Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v4: - Merge with the fix close patch - Add loop to reset imc_counters_config fds to -1 to be able know which need closing - Introduce perf_close_imc_mem_bw() to close fds v3: - Rework entirely, use open coding instead of for loops for clarity --- tools/testing/selftests/resctrl/resctrl_val.c | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 445f306d4c2f..f55f5989de72 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -293,6 +293,18 @@ static int initialize_mem_bw_imc(void) return 0; } +static void perf_close_imc_mem_bw(void) +{ + int mc; + + for (mc = 0; mc < imcs; mc++) { + if (imc_counters_config[mc][READ].fd != -1) + close(imc_counters_config[mc][READ].fd); + if (imc_counters_config[mc][WRITE].fd != -1) + close(imc_counters_config[mc][WRITE].fd); + } +} + /* * get_mem_bw_imc: Memory band width as reported by iMC counters * @cpu_no: CPU number that the benchmark PID is binded to @@ -306,26 +318,33 @@ static int initialize_mem_bw_imc(void) static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) { float reads, writes, of_mul_read, of_mul_write; - int imc, j, ret; + int imc, ret; + + for (imc = 0; imc < imcs; imc++) { + imc_counters_config[imc][READ].fd = -1; + imc_counters_config[imc][WRITE].fd = -1; + } /* Start all iMC counters to log values (both read and write) */ reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; for (imc = 0; imc < imcs; imc++) { - for (j = 0; j < 2; j++) { - ret = open_perf_event(imc, cpu_no, j); - if (ret) - return -1; - } - for (j = 0; j < 2; j++) - membw_ioctl_perf_event_ioc_reset_enable(imc, j); + ret = open_perf_event(imc, cpu_no, READ); + if (ret) + goto close_fds; + ret = open_perf_event(imc, cpu_no, WRITE); + if (ret) + goto close_fds; + + membw_ioctl_perf_event_ioc_reset_enable(imc, READ); + membw_ioctl_perf_event_ioc_reset_enable(imc, WRITE); } sleep(1); /* Stop counters after a second to get results (both read and write) */ for (imc = 0; imc < imcs; imc++) { - for (j = 0; j < 2; j++) - membw_ioctl_perf_event_ioc_disable(imc, j); + membw_ioctl_perf_event_ioc_disable(imc, READ); + membw_ioctl_perf_event_ioc_disable(imc, WRITE); } /* @@ -341,15 +360,13 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) if (read(r->fd, &r->return_value, sizeof(struct membw_read_format)) == -1) { ksft_perror("Couldn't get read b/w through iMC"); - - return -1; + goto close_fds; } if (read(w->fd, &w->return_value, sizeof(struct membw_read_format)) == -1) { ksft_perror("Couldn't get write bw through iMC"); - - return -1; + goto close_fds; } __u64 r_time_enabled = r->return_value.time_enabled; @@ -369,10 +386,7 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) writes += w->return_value.value * of_mul_write * SCALE; } - for (imc = 0; imc < imcs; imc++) { - close(imc_counters_config[imc][READ].fd); - close(imc_counters_config[imc][WRITE].fd); - } + perf_close_imc_mem_bw(); if (strcmp(bw_report, "reads") == 0) { *bw_imc = reads; @@ -386,6 +400,10 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) *bw_imc = reads + writes; return 0; + +close_fds: + perf_close_imc_mem_bw(); + return -1; } void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id) From patchwork Mon May 20 12:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798573 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D39195466B; Mon, 20 May 2024 12:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208253; cv=none; b=DK09ysrYng/PoA/YdJwDwZoJoM8lPibKm5wGDnvqd//ylL7oGT9xYWpvINMyVL03Hhcq3n2E81dz+k8X8mqRAogUvz07JzV3NBCDa/+snx/BBNnZTC4MzLF2nRhJxc9RZNFFAVjK3LXBrWeoJUgk/i3g4JmDKvGRyOIf2fqAHW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208253; c=relaxed/simple; bh=//oQCpLHULNkZm6rA5fdSTosfvwJzsgXn+TlVyfaP5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=nKByPXxij5OwHfgGCE9/TnDlMMCIoDKG4J+h8F6ZoiXodKsUHRS4rgETlZ3bwJrmWIs/gB6w3ZfB2I7FzlciBsxoUR3n9PYbiWbCSfYyJr2N0HN4LiEQddzKSRybhNcn5hhyWqmkrnuRFrFIZOwOmMAzqMtmsiCUcKk3vuQmcPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HaWhIcIW; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HaWhIcIW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208252; x=1747744252; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=//oQCpLHULNkZm6rA5fdSTosfvwJzsgXn+TlVyfaP5k=; b=HaWhIcIWS7DXC3IeEmktjLXXNdHDjF+FoHlGQMmRnvrz8CWVBclwmJ/l Y0OdSxqyWVpFshqKSHnPCOYzWzG36ZuvqDyYuDihsr8EmdqdJN1HbvvB7 qw/5zbqIDT0adE+5LphQrRJ03Fww8BOKJuaj2LEe/tRLX9tiMVbKTtzSS GV4CE5zSfys+tF7Xzw77tX6bV0LWknIL74JsmxRGczD4xc966IfLkM/Xu sLJs1hp899fx4XXRAK9+IhcJrt4EBypO0CexHH8LXJdMubz+T6Qy+UF8/ 4v9O4llZ2g78iMT+QSeZBU2pgpaUtZDMFOr6gtfkFdnw1Gxi3PVaUu6Wb w==; X-CSE-ConnectionGUID: Bu3hDyLHQIukYGkj1MZZvg== X-CSE-MsgGUID: BnvVIgkPR3eoSaHW47ZNGg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180298" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180298" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:30:51 -0700 X-CSE-ConnectionGUID: 6DdbZsDVSRWRfNfT3N8znA== X-CSE-MsgGUID: M0M7ba0RRWG2d41uRnDkgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091030" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:30:48 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 02/16] selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only Date: Mon, 20 May 2024 15:30:06 +0300 Message-Id: <20240520123020.18938-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For MBM/MBA tests, measure_vals() calls get_mem_bw_imc() that performs the measurement over a duration of sleep(1) call. The memory bandwidth numbers from IMC are derived over this duration. The resctrl FS derived memory bandwidth, however, is calculated inside measure_vals() and only takes delta between the previous value and the current one which besides the actual test, also samples inter-test noise. Rework the logic in measure_vals() and get_mem_bw_imc() such that the resctrl FS memory bandwidth section covers much shorter duration closely matching that of the IMC perf counters to improve measurement accuracy. Open two the resctrl mem bw files twice to avoid opening after the test during measurement period (reading the same file twice returns the same value so two files are needed). Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v4: - Open resctrl mem bw file (twice) beforehand to avoid opening it during the test v3: - Don't drop Return: entry from perf_open_imc_mem_bw() func comment --- tools/testing/selftests/resctrl/resctrl_val.c | 119 +++++++++++++----- 1 file changed, 85 insertions(+), 34 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index f55f5989de72..bd5a1cbb8a21 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -306,18 +306,13 @@ static void perf_close_imc_mem_bw(void) } /* - * get_mem_bw_imc: Memory band width as reported by iMC counters - * @cpu_no: CPU number that the benchmark PID is binded to - * @bw_report: Bandwidth report type (reads, writes) - * - * Memory B/W utilized by a process on a socket can be calculated using - * iMC counters. Perf events are used to read these counters. + * perf_open_imc_mem_bw - Open perf fds for IMCs + * @cpu_no: CPU number that the benchmark PID is binded to * * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) +static int perf_open_imc_mem_bw(int cpu_no) { - float reads, writes, of_mul_read, of_mul_write; int imc, ret; for (imc = 0; imc < imcs; imc++) { @@ -325,8 +320,6 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) imc_counters_config[imc][WRITE].fd = -1; } - /* Start all iMC counters to log values (both read and write) */ - reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; for (imc = 0; imc < imcs; imc++) { ret = open_perf_event(imc, cpu_no, READ); if (ret) @@ -334,7 +327,26 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) ret = open_perf_event(imc, cpu_no, WRITE); if (ret) goto close_fds; + } + return 0; + +close_fds: + perf_close_imc_mem_bw(); + return -1; +} + +/* + * do_mem_bw_test - Perform memory bandwidth test + * + * Runs memory bandwidth test over one second period. Also, handles starting + * and stopping of the IMC perf counters around the test. + */ +static void do_imc_mem_bw_test(void) +{ + int imc; + + for (imc = 0; imc < imcs; imc++) { membw_ioctl_perf_event_ioc_reset_enable(imc, READ); membw_ioctl_perf_event_ioc_reset_enable(imc, WRITE); } @@ -346,6 +358,24 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) membw_ioctl_perf_event_ioc_disable(imc, READ); membw_ioctl_perf_event_ioc_disable(imc, WRITE); } +} + +/* + * get_mem_bw_imc - Memory band width as reported by iMC counters + * @bw_report: Bandwidth report type (reads, writes) + * + * Memory B/W utilized by a process on a socket can be calculated using + * iMC counters. Perf events are used to read these counters. + * + * Return: = 0 on success. < 0 on failure. + */ +static int get_mem_bw_imc(char *bw_report, float *bw_imc) +{ + float reads, writes, of_mul_read, of_mul_write; + int imc; + + /* Start all iMC counters to log values (both read and write) */ + reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; /* * Get results which are stored in struct type imc_counter_config @@ -462,24 +492,23 @@ static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, * 1. If con_mon grp is given, then read from it * 2. If con_mon grp is not given, then read from root con_mon grp */ -static int get_mem_bw_resctrl(unsigned long *mbm_total) +static FILE *open_mem_bw_resctrl(const char *mbm_bw_file) { FILE *fp; - fp = fopen(mbm_total_path, "r"); - if (!fp) { + fp = fopen(mbm_bw_file, "r"); + if (!fp) ksft_perror("Failed to open total bw file"); - return -1; - } + return fp; +} + +static int get_mem_bw_resctrl(FILE *fp, unsigned long *mbm_total) +{ if (fscanf(fp, "%lu", mbm_total) <= 0) { ksft_perror("Could not get mbm local bytes"); - fclose(fp); - return -1; } - fclose(fp); - return 0; } @@ -616,13 +645,22 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, } static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param, - unsigned long *bw_resc_start) + struct resctrl_val_param *param) { - unsigned long bw_resc, bw_resc_end; + unsigned long bw_resc, bw_resc_start, bw_resc_end; + FILE *mem_bw_fp, *mem_bw_fp2; float bw_imc; int ret; + mem_bw_fp = open_mem_bw_resctrl(mbm_total_path); + if (!mem_bw_fp) + return -1; + mem_bw_fp2 = open_mem_bw_resctrl(mbm_total_path); + if (!mem_bw_fp2) { + ret = -1; + goto close_fp; + } + /* * Measure memory bandwidth from resctrl and from * another source which is perf imc value or could @@ -630,22 +668,36 @@ static int measure_vals(const struct user_params *uparams, * Compare the two values to validate resctrl value. * It takes 1sec to measure the data. */ - ret = get_mem_bw_imc(uparams->cpu, param->bw_report, &bw_imc); + ret = perf_open_imc_mem_bw(uparams->cpu); if (ret < 0) - return ret; + goto close_fp2; - ret = get_mem_bw_resctrl(&bw_resc_end); + ret = get_mem_bw_resctrl(mem_bw_fp, &bw_resc_start); if (ret < 0) - return ret; + goto close_fp2; - bw_resc = (bw_resc_end - *bw_resc_start) / MB; - ret = print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); - if (ret) - return ret; + do_imc_mem_bw_test(); + + ret = get_mem_bw_resctrl(mem_bw_fp2, &bw_resc_end); + if (ret < 0) + goto close_fp2; + + ret = get_mem_bw_imc(param->bw_report, &bw_imc); + if (ret < 0) + goto close_fp2; - *bw_resc_start = bw_resc_end; + fclose(mem_bw_fp2); + fclose(mem_bw_fp); - return 0; + bw_resc = (bw_resc_end - bw_resc_start) / MB; + + return print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); + +close_fp2: + fclose(mem_bw_fp2); +close_fp: + fclose(mem_bw_fp); + return ret; } /* @@ -719,7 +771,6 @@ int resctrl_val(const struct resctrl_test *test, struct resctrl_val_param *param) { char *resctrl_val = param->resctrl_val; - unsigned long bw_resc_start = 0; struct sigaction sigact; int ret = 0, pipefd[2]; char pipe_message = 0; @@ -861,7 +912,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param, &bw_resc_start); + ret = measure_vals(uparams, param); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon May 20 12:30:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797933 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8369556440; Mon, 20 May 2024 12:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208261; cv=none; b=WDarpAMFoRYDJG1WYOWYTZNK4Z97tzk3JR4SnSmADyk5nTPf0EaB+hDRPCaEJpCgCrCwqFPOzvh+kSNgBeTG2hVMfyRPFtDBMzBtqgkgPGGmb1jO51uOb0Fh47xMIrTTf18cNLcTV9ODy7oTmNWg7ulrVyzd7eZWttn5Bk4QqpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208261; c=relaxed/simple; bh=qciJp89w73IYXrwUHbmWOg2Gey9XF1Mn/Uim9/b41Og=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=VUeTnGKjcy9h19gmr9folGHr5U5VKU+W5k72ebO8TVL+Jqb6SjJVM5F7g+V2HLVfM48zFWGA/XofqoOiMrWwPOROsuHR7zr70vayyjf5Ykm3ILD9YPbwLvTcXb4qoz39PRGbGwTmLLjWBK1s7knHtyAsmxF3CnpvCWOTCD2IJME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YP/J42fq; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YP/J42fq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208260; x=1747744260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qciJp89w73IYXrwUHbmWOg2Gey9XF1Mn/Uim9/b41Og=; b=YP/J42fqH5gVydWGjkc9agBnF0+n3OlTXsCIqYmylFKY4Rubx/BoNzKt B/Dk8KYA6197cL80BvM1AVPuLcFcZKrB0gKTMZKwDA2JzAciX6xfIHC66 i7OZP8APJlenQx8GIMume9YyFaoMwoLLFPdykib0aTFGSOTIQFbQu1xab Iuv5mXKX4WuxyDJvSZED9MFuy1apHZFGnCvYfDkS6rmvPchFU7XuhW/jn y092rQag+efYxa3/zkh5P0ldQ33l7fGUGvF4VfMWcML6vrGTpy7GvXtXj hTMwEF8B4Gq0AjEx+bS/aMisK3dqF4ZTwL4ZhIetvtClCNRj2MeNSQh0p A==; X-CSE-ConnectionGUID: 5sfbBTevRF6HNyL11oIG2Q== X-CSE-MsgGUID: pWY9/B8bR1qRa3YODbDBtQ== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180314" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180314" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:00 -0700 X-CSE-ConnectionGUID: WQDHJ4k+Rs6N/1R1Anz/NA== X-CSE-MsgGUID: A2Axa0apSSCuTMtQIjbAXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091062" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:30:57 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 03/16] selftests/resctrl: Make "bandwidth" consistent in comments & prints Date: Mon, 20 May 2024 15:30:07 +0300 Message-Id: <20240520123020.18938-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Resctrl selftests refer to "bandwidth" currently in two other forms in the code ("B/W" and "band width"). Use "bandwidth" consistently everywhere. While at it, fix also one "over flow" -> "overflow" on a line that is touched by the change. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v3: - New patch --- tools/testing/selftests/resctrl/resctrl_val.c | 14 +++++++------- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index bd5a1cbb8a21..126a9cad588b 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -361,11 +361,11 @@ static void do_imc_mem_bw_test(void) } /* - * get_mem_bw_imc - Memory band width as reported by iMC counters + * get_mem_bw_imc - Memory bandwidth as reported by iMC counters * @bw_report: Bandwidth report type (reads, writes) * - * Memory B/W utilized by a process on a socket can be calculated using - * iMC counters. Perf events are used to read these counters. + * Memory bandwidth utilized by a process on a socket can be calculated + * using iMC counters. Perf events are used to read these counters. * * Return: = 0 on success. < 0 on failure. */ @@ -379,7 +379,7 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) /* * Get results which are stored in struct type imc_counter_config - * Take over flow into consideration before calculating total b/w + * Take overflow into consideration before calculating total bandwidth. */ for (imc = 0; imc < imcs; imc++) { struct imc_counter_config *r = @@ -389,13 +389,13 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) if (read(r->fd, &r->return_value, sizeof(struct membw_read_format)) == -1) { - ksft_perror("Couldn't get read b/w through iMC"); + ksft_perror("Couldn't get read bandwidth through iMC"); goto close_fds; } if (read(w->fd, &w->return_value, sizeof(struct membw_read_format)) == -1) { - ksft_perror("Couldn't get write bw through iMC"); + ksft_perror("Couldn't get write bandwidth through iMC"); goto close_fds; } @@ -498,7 +498,7 @@ static FILE *open_mem_bw_resctrl(const char *mbm_bw_file) fp = fopen(mbm_bw_file, "r"); if (!fp) - ksft_perror("Failed to open total bw file"); + ksft_perror("Failed to open total memory bandwidth file"); return fp; } diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 1cade75176eb..9b86f826a40c 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -850,7 +850,7 @@ int validate_bw_report_request(char *bw_report) if (strcmp(bw_report, "total") == 0) return 0; - fprintf(stderr, "Requested iMC B/W report type unavailable\n"); + fprintf(stderr, "Requested iMC bandwidth report type unavailable\n"); return -1; } From patchwork Mon May 20 12:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798572 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B4FE56766; Mon, 20 May 2024 12:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208270; cv=none; b=udovgncUl5Jxj3J6OIBla0Iqinz+RQTv//Ocfv9ED6IlKpoNtDKH3dX9f6j/kE2xQ3TX6HDKH4OcpYuq37oP83BQgp3Grkc4luQVK9leYR3o1ahU6CmtPPErSoMKAgtkIJcC3HkKdx23dySXcPkMvGT+QPWxhre8NKRpms4N+gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208270; c=relaxed/simple; bh=IK/hJK9+J08W1MsxIwwJRZTw4zqFwkiytsnG2YPMKBw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=NPT6zOec4Pn9Wj5/9DG5qx/nW26IPM2qedeADUpc28moWRLcezNUy6eDLclknYZDXd42U4pmBXjmrByN8rQtJHR7/Dv5DASWASsgr9kv/wb/TT29aEhOhxFN1Fl98afF+UcfgQIyanEepx2TH2tzb/iSAkTK+xM0OpdKg9abT/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XmlMpimr; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XmlMpimr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208269; x=1747744269; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IK/hJK9+J08W1MsxIwwJRZTw4zqFwkiytsnG2YPMKBw=; b=XmlMpimrY32/0Q10z2G+E+7XkEjDLchqO2y6zzxKVWptQS+6UQVBYhZl WrZI+a7bF3GzeNYXWPZCUqzNjx4apqMIJ0jLozhR24d54jxAlybHsE5Wm Qe7qVjmSUISC+M8m6T0w1wQ2c0snU7VOjm5ues2fEKCkgFDHFs6NNlq6w 8Kig39kZrUV7r2+8CpdLqv/3/lj2QugaJLNXk08EtPtibern0dfL0H+yc irtgx4KL9xKYEZ/lnCTLiZhI8XqO2jknSqFLnv6nV9lsVHIB9dkm6yOYv ABShegtbNCBTaa8Zi8c5bb6OXd0+k01zpNHHH1P5Li6r37bLkxq8mul+2 Q==; X-CSE-ConnectionGUID: i7ddnMAvRpaHT6Y3jt88yA== X-CSE-MsgGUID: ApsuPWIRRuGarYQlwFtjxg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180336" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180336" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:08 -0700 X-CSE-ConnectionGUID: 33vUk75zRgSv9Xb8f1AUfg== X-CSE-MsgGUID: sTw8PonUQTOlY/r9VbJLMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091115" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:05 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 04/16] selftests/resctrl: Consolidate get_domain_id() into resctrl_val() Date: Mon, 20 May 2024 15:30:08 +0300 Message-Id: <20240520123020.18938-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl() that are called from resctrl_val() need to determine domain ID to construct resctrl fs related paths. Both functions do it by taking CPU ID which neither needs for any other purpose than determining the domain ID. Consolidate determining the domain ID into resctrl_val() and pass the domain ID instead of CPU ID to initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl(). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 126a9cad588b..6ea8fd2c65cc 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -456,19 +456,12 @@ void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id) * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @cpu_no: CPU number that the benchmark PID is binded to + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) */ static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, - int cpu_no, char *resctrl_val) + int domain_id, char *resctrl_val) { - int domain_id; - - if (get_domain_id("MB", cpu_no, &domain_id) < 0) { - ksft_print_msg("Could not get domain ID\n"); - return; - } - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) set_mbm_path(ctrlgrp, mongrp, domain_id); @@ -627,19 +620,12 @@ static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num) * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @cpu_no: CPU number that the benchmark PID is binded to + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) */ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, - int cpu_no, char *resctrl_val) + int domain_id, char *resctrl_val) { - int domain_id; - - if (get_domain_id("L3", cpu_no, &domain_id) < 0) { - ksft_print_msg("Could not get domain ID\n"); - return; - } - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) set_cmt_path(ctrlgrp, mongrp, domain_id); } @@ -775,10 +761,17 @@ int resctrl_val(const struct resctrl_test *test, int ret = 0, pipefd[2]; char pipe_message = 0; union sigval value; + int domain_id; if (strcmp(param->filename, "") == 0) sprintf(param->filename, "stdio"); + ret = get_domain_id(test->resource, uparams->cpu, &domain_id); + if (ret < 0) { + ksft_print_msg("Could not get domain ID\n"); + return ret; + } + if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { ret = validate_bw_report_request(param->bw_report); @@ -873,10 +866,10 @@ int resctrl_val(const struct resctrl_test *test, goto out; initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val); } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val); /* Parent waits for child to be ready. */ close(pipefd[1]); From patchwork Mon May 20 12:30:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797932 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8EB26A8AC; Mon, 20 May 2024 12:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208279; cv=none; b=jRPj6YFCUnEjDgD/LWNxz9eaxnhxeuGX6ZNkkMYEEFCgG6XXfSDGKtw0AkB7UhJrjEooasAulf/rLE8xYj0STFJgeoDKI+CZkHoTZJ/Cm1SgJktXrY+9ygsnk+aJiQs+MBrOgzenmghJHpQhOtNLuM35ITJ5NevmdWQgCg2YElk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208279; c=relaxed/simple; bh=OXLRHfwzhWhfF/o+k3sFxvU1ArXQmPhsk8nX+CqNWLg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=AHDiPLMcqCgD+W2xnN0DNsFWGUUU7e9ldOU4/ZtNjRlS/LgjPCBOfr9GU1T7OBlLNPh53tgeS1Zik58ocsArWgC8nMFN+O/JgL4hwJTsuHFePoaMS1osJzzEUgz7Mfq5XhtpgnCy2EI9XiLF+4ySSDvC9BfY3XM9yKxn9XmwI94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=S/q2OSFX; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="S/q2OSFX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208278; x=1747744278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OXLRHfwzhWhfF/o+k3sFxvU1ArXQmPhsk8nX+CqNWLg=; b=S/q2OSFXstuVD0qwM6X0Bkysj75wxm07HxIz3bywBmHnf2HDI5U5V+h2 e6wQWuq5ftSqyJtstq20SxWk4PKJ8XWhUdJGXR/npQU3qmclTz5K9dFZE PbEzS2aeFobr1maJ06Yu+RedKz4GKTbjrpBaeHYlkKUu8e6ppIAPvHglq mTpGpYtae3NH7tSzx7IgeSQ870vtHzveWNIwqWTVrqJT9Wlu2O+e1fHAC ToAGhwUPFLPI+kzT0qxMXbeGfng4yWHK9dwa0DLlQgTBWIclY2ZfP2MlE nOOQLMQ3KoKsEcd79lfHIWcOH8p1Ri86exh1DyIPK3Sr8zc4TTVSJIZpv g==; X-CSE-ConnectionGUID: A6hzIa+9Tte4w3SxhMie2w== X-CSE-MsgGUID: a5Z7Kz+6QhS7i/YTxAK2+w== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180358" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180358" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:17 -0700 X-CSE-ConnectionGUID: lIpSSv3RSiihX+465unR8A== X-CSE-MsgGUID: SiU3s4YXRKKwcZlDUzJZzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091197" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:14 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 05/16] selftests/resctrl: Use correct type for pids Date: Mon, 20 May 2024 15:30:09 +0300 Message-Id: <20240520123020.18938-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A few functions receive PIDs through int arguments. PIDs variables should be of type pid_t, not int. Convert pid arguments from int to pid_t. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 6 +++--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 1b339d6bbff1..9b74fce80037 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -101,7 +101,7 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy) * * Return: 0 on success, < 0 on error. */ -static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value) +static int print_results_cache(const char *filename, pid_t bm_pid, __u64 llc_value) { FILE *fp; @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value * Return: =0 on success. <0 on failure. */ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid) + const char *filename, pid_t bm_pid) { int ret; @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, * * Return: =0 on success. <0 on failure. */ -int measure_llc_resctrl(const char *filename, int bm_pid) +int measure_llc_resctrl(const char *filename, pid_t bm_pid) { unsigned long llc_occu_resc = 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 00d51fa7531c..e6f221236c79 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -174,8 +174,8 @@ void perf_event_initialize_read_format(struct perf_event_read *pe_read); int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no); int perf_event_reset_enable(int pe_fd); int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid); -int measure_llc_resctrl(const char *filename, int bm_pid); + const char *filename, pid_t bm_pid); +int measure_llc_resctrl(const char *filename, pid_t bm_pid); void show_cache_info(int no_of_bits, __u64 avg_llc_val, size_t cache_span, bool lines); /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 6ea8fd2c65cc..18bfdff78089 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -572,7 +572,7 @@ void signal_handler_unregister(void) * * Return: 0 on success, < 0 on error. */ -static int print_results_bw(char *filename, int bm_pid, float bw_imc, +static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, unsigned long bw_resc) { unsigned long diff = fabs(bw_imc - bw_resc); From patchwork Mon May 20 12:30:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798571 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 086A06CDC5; Mon, 20 May 2024 12:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208288; cv=none; b=GDsJOzReDlLdWz+tnCKCk8iwmsZdvAaCXRYuSb8Y2iuM/aRYs2Ap5oEuP//Q7ElPwfqtsrRbXxJljv+/hD0sb2qcT9+emC28mP3g+w9/d/QXqGZJkX2kO+608YW+B1pjijLZMZ8Oco+O9fCsqJy1TaJrXOIBJ9Yfvogb9wiBSYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208288; c=relaxed/simple; bh=K+i/q8levs1aLzjEe7nsPGEh1RHzB4gA9b8PvFdYk0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SBDHul17Ao9NYC0p/3l5rK+Fy1hwMfhpFO3amuPD0i/a0NwWUUnMt04Rs1sa/ZPjE4E1a+FjiWXS5zomz24nr8ZxPOLk999B2ImNY0H0OMakXf9IlIR+1IZv462vg0AlVsqkP//gJOgZuA7cye4fgXrg8vFHhxTVB5CqDR7OzUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OiIMo3j4; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OiIMo3j4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208287; x=1747744287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K+i/q8levs1aLzjEe7nsPGEh1RHzB4gA9b8PvFdYk0s=; b=OiIMo3j4k28xsswzqjT44M9Tc04IP+1+q4CiN1UyGceqE7+vuU4OwlYC 5QFp3apU9r4L+dtQwL4eQ5qpR4VTTRNLMNKD+2vLc2P6dUQ0A2LlZvntT o2cvjvG+hEcppfxCMaHjvpbMnCNo3HBdTCTvFMyxz71GZvm2DX8fGWfrV gx7xrm6VeL/xrhmUieHZ/I7AykGpcRXAS3yAvpfuRg4YDhmgV6UHra+GE GcDXTn4Eb/31zsk/q9FUNl+wRa/VjXo0NvbBNZCNNp8ecC7HOni4KF4qU GYB0wzRUD4TERL9yNE+MSQq/kmef2lEE3hOBeL2WlQ7aOFNPxj0v5GapI A==; X-CSE-ConnectionGUID: wSRoIUXuTbW/UhhnmXP1HA== X-CSE-MsgGUID: fVWtIUjTRxGiVrlUUj/BZQ== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180387" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180387" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:26 -0700 X-CSE-ConnectionGUID: ZD2gpGpaSPexQkA8/jRn3w== X-CSE-MsgGUID: ei8Lnr3dRXaMhEhAsya2vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="37474354" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:24 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 06/16] selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope Date: Mon, 20 May 2024 15:30:10 +0300 Message-Id: <20240520123020.18938-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'bm_pid' and 'ppid' are global variables. As they are used by different processes and in signal handler, they cannot be entirely converted into local variables. The scope of those variables can still be reduced into resctrl_val.c only. As PARENT_EXIT() macro is using 'ppid', make it a function in resctrl_val.c and pass ppid to it as an argument because it is easier to understand than using the global variable directly. Pass 'bm_pid' into measure_val() instead of relying on the global variable which helps to make the call signatures of measure_val() and measure_llc_resctrl() more similar to each other. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 9 -------- tools/testing/selftests/resctrl/resctrl_val.c | 23 ++++++++++++------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index e6f221236c79..e4b6dc672ecc 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -43,13 +43,6 @@ #define DEFAULT_SPAN (250 * MB) -#define PARENT_EXIT() \ - do { \ - kill(ppid, SIGKILL); \ - umount_resctrlfs(); \ - exit(EXIT_FAILURE); \ - } while (0) - /* * user_params: User supplied parameters * @cpu: CPU number to which the benchmark will be bound to @@ -127,8 +120,6 @@ struct perf_event_read { */ extern volatile int *value_sink; -extern pid_t bm_pid, ppid; - extern char llc_occup_path[1024]; int get_vendor(void); diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 18bfdff78089..198b5133432a 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -505,7 +505,7 @@ static int get_mem_bw_resctrl(FILE *fp, unsigned long *mbm_total) return 0; } -pid_t bm_pid, ppid; +static pid_t bm_pid, ppid; void ctrlc_handler(int signum, siginfo_t *info, void *ptr) { @@ -563,6 +563,13 @@ void signal_handler_unregister(void) } } +static void parent_exit(pid_t ppid) +{ + kill(ppid, SIGKILL); + umount_resctrlfs(); + exit(EXIT_FAILURE); +} + /* * print_results_bw: the memory bandwidth results are stored in a file * @filename: file that stores the results @@ -631,7 +638,7 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, } static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param) + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; FILE *mem_bw_fp, *mem_bw_fp2; @@ -710,7 +717,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) fp = freopen("/dev/null", "w", stdout); if (!fp) { ksft_perror("Unable to direct benchmark status to /dev/null"); - PARENT_EXIT(); + parent_exit(ppid); } if (strcmp(benchmark_cmd[0], "fill_buf") == 0) { @@ -724,7 +731,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) once = false; } else { ksft_print_msg("Invalid once parameter\n"); - PARENT_EXIT(); + parent_exit(ppid); } if (run_fill_buf(span, memflush, operation, once)) @@ -738,7 +745,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) fclose(stdout); ksft_print_msg("Unable to run specified benchmark\n"); - PARENT_EXIT(); + parent_exit(ppid); } /* @@ -817,7 +824,7 @@ int resctrl_val(const struct resctrl_test *test, /* Register for "SIGUSR1" signal from parent */ if (sigaction(SIGUSR1, &sigact, NULL)) { ksft_perror("Can't register child for signal"); - PARENT_EXIT(); + parent_exit(ppid); } /* Tell parent that child is ready */ @@ -835,7 +842,7 @@ int resctrl_val(const struct resctrl_test *test, sigsuspend(&sigact.sa_mask); ksft_perror("Child is done"); - PARENT_EXIT(); + parent_exit(ppid); } ksft_print_msg("Benchmark PID: %d\n", bm_pid); @@ -905,7 +912,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param); + ret = measure_vals(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon May 20 12:30:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797931 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D1A7535BF; Mon, 20 May 2024 12:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208297; cv=none; b=dXMBCB2M4r5fXCcKMJYo+kZXKnqcvVoKksgjuKzwiZSXqX8hUhgZxiMEncEDCP1LoCPvN+Bm7mmzxsuc1VytfLfdNqjePm61esKYmE4aAEFV1EqC2SJem4BDbJDzhuaSmvIib0xmgZyyIlcAoz20sKlB7n3ddxqcosLuaGnUYME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208297; c=relaxed/simple; bh=vD3mIPWehyTxwiEwSM2bRKm7uM+xdNcRV/4ZwMjS0X4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QN440DwImfUbRQj9cgqWnnzmYMi96kjUBpvqC1RzT9i/7pW68bneGu4npGcUbpmKKW/L/c0uR6DYljWpE6vD/O7XQ43ATfZWpyUU4xUrdOMFuL0ndP7G7daK8CcedS0ZV+8OBtSIfaoa7t0vLH00lrghWbcHYLLhayn+BM7fpd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=k/CYVbpt; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="k/CYVbpt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208296; x=1747744296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vD3mIPWehyTxwiEwSM2bRKm7uM+xdNcRV/4ZwMjS0X4=; b=k/CYVbptNyLFPWKxVJ5yeCRP7a9Xm8aNd21e+m+LEiUOJSF6lP9iUHY2 teJ1+ODuTQzEV7HRsLDk3acEFD1Kas6HA0HQ4L+TQdNO2RWV8KAcixei/ YDKv4RZcJKONyEnH09O3cSfZWxVDRGZHTtCoxYMXclNQ9CJ+xqcZvxsEF spVGQagDaxqKRMJj60owU+fkaRixJip1smlgeSamUDT5Nd66e6aaxewei GSn5BUz8pFXf75llyy3euKmEKzNpEO4zjRfx4RkrGFeJnsKThe9TpuV8N n0OOs+g6vtDx9+l1wBUsl9BCZYZq35CScB4R0iCESYRFJ1QGGAcDSarN2 A==; X-CSE-ConnectionGUID: G3rh8IPdSyKdBFERxNEeWQ== X-CSE-MsgGUID: FO0z4uVqRtiAkmmP9XAsJw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180401" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180401" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:36 -0700 X-CSE-ConnectionGUID: vqimptmwRyiz92b0+b+l3w== X-CSE-MsgGUID: jk1/L8YJSQKwxh+8A+mQGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="37474480" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:33 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 07/16] selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() & document Date: Mon, 20 May 2024 15:30:11 +0300 Message-Id: <20240520123020.18938-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 measure_val() is awfully generic name so rename it to measure_mem_bw() to describe better what it does and document the function parameters. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 198b5133432a..6c53eb9171ea 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -637,8 +637,14 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, set_cmt_path(ctrlgrp, mongrp, domain_id); } -static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) +/* + * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs + * @uparams: User supplied parameters + * @param: parameters passed to resctrl_val() + * @bm_pid: PID that runs the benchmark + */ +static int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; FILE *mem_bw_fp, *mem_bw_fp2; @@ -912,7 +918,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param, bm_pid); + ret = measure_mem_bw(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon May 20 12:30:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798570 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA0DE71B48; Mon, 20 May 2024 12:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208306; cv=none; b=FXfDsSmAvzrr5pcyEsT1OHn+TJufRBrWlWG4Ois/LbkVvQ41uSkjTFLmeJAOWQyG6IwNuyiaWdZDq0Xe04QJg/gLwphNS3P2H48h314inmjcip8idytl7BIhi7kC0XQ07DjOA0LsMN0Kz8wrgxkmTkL24b+dwXzk5/OZBtc8DHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208306; c=relaxed/simple; bh=k+xZPNvp8VJD3Y5WMA9eeWl+zPa7LoAlFBHiX0NOM3M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gZLHVQw8cv4C0jaL2MelQFSpByXetySdLyaHb1QJVL/kApnKpYWaXuqRvuGWWMq3DE/qlc5YfuDo2RbluF9EvMGixCGrHuNbc5ycltvsDE+DrQlOnL1QQBJ1NMruPTCXEw3+NZoODZnUam2tA2+Qi7ppq89Atjyz9uH+g5zQ4Xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=D4a6KXrh; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D4a6KXrh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208305; x=1747744305; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k+xZPNvp8VJD3Y5WMA9eeWl+zPa7LoAlFBHiX0NOM3M=; b=D4a6KXrhmn3DAEZaSW7nBQNmVaiHKb3djul4tlAVE62CIt3Kj+OXnq+6 Fd3+WdyIBlKan4p62IvvB2zf2VHVnDmsUtr1AaZ01DpJv/DL5GdqTcFMo k5NtaZIsP41vr6zVzoTr7SlpZhAMQrgojqTpaRCS3LVReaMoRXqYBw+np 1HIYSTbRW6Khys/1afIayFSgkLcWy608dsTZdAsBV8GVetE9vy8NTo3YJ oXJZ4UbF2YCB/hTsHVzWbs3E/DZGEtq0zwy39/vY9IH1V9F9IdlrPVCJT G2M7C8ZpqBUAZciB0SYyy3nOcrkqOWdYzLUKTehNyFrNu1Spa158HE1PW A==; X-CSE-ConnectionGUID: tt/pGeOoRzSW/qWLUM+cag== X-CSE-MsgGUID: JvPJ2Cl4SKGFIsHFiVTnCw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180435" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180435" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:44 -0700 X-CSE-ConnectionGUID: Skeem3bPS4iH8KcErhPASw== X-CSE-MsgGUID: okJHpcksSKeMEJR8jBgKLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="37474552" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:42 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 08/16] selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests Date: Mon, 20 May 2024 15:30:12 +0300 Message-Id: <20240520123020.18938-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 initialize_mem_bw_resctrl() and set_mbm_path() contain complicated set of conditions, each yielding different file to be opened to measure memory bandwidth through resctrl FS. In practice, only two of them are used. For MBA test, ctrlgrp is always provided, and for MBM test both ctrlgrp and mongrp are set. The file used differ between MBA/MBM test, however, MBM test unnecessarily create monitor group because resctrl FS already provides monitoring interface underneath any ctrlgrp too, which is what the MBA selftest uses. Consolidate memory bandwidth file used to the one used by the MBA selftest. Remove all unused branches opening other files to simplify the code. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v4: - Remove also MBM .mongrp setup v3: - New patch --- tools/testing/selftests/resctrl/mbm_test.c | 1 - tools/testing/selftests/resctrl/resctrl_val.c | 45 ++----------------- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 3059ccc51a5a..96d279b06377 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -115,7 +115,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param struct resctrl_val_param param = { .resctrl_val = MBM_STR, .ctrlgrp = "c1", - .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", .setup = mbm_setup diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 6c53eb9171ea..a3cf3c5ed17f 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -19,18 +19,10 @@ #define MAX_TOKENS 5 #define READ 0 #define WRITE 1 -#define CON_MON_MBM_LOCAL_BYTES_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" #define CON_MBM_LOCAL_BYTES_PATH \ "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define MON_MBM_LOCAL_BYTES_PATH \ - "%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" - -#define MBM_LOCAL_BYTES_PATH \ - "%s/mon_data/mon_L3_%02d/mbm_local_bytes" - #define CON_MON_LCC_OCCUP_PATH \ "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" @@ -436,43 +428,15 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) return -1; } -void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id) -{ - if (ctrlgrp && mongrp) - sprintf(mbm_total_path, CON_MON_MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, ctrlgrp, mongrp, domain_id); - else if (!ctrlgrp && mongrp) - sprintf(mbm_total_path, MON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - mongrp, domain_id); - else if (ctrlgrp && !mongrp) - sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - ctrlgrp, domain_id); - else if (!ctrlgrp && !mongrp) - sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - domain_id); -} - /* * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @mongrp: Name of the monitor group (mon grp) * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) */ -static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, - int domain_id, char *resctrl_val) +static void initialize_mem_bw_resctrl(const char *ctrlgrp, int domain_id) { - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) - set_mbm_path(ctrlgrp, mongrp, domain_id); - - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - if (ctrlgrp) - sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, ctrlgrp, domain_id); - else - sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, domain_id); - } + sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, + ctrlgrp, domain_id); } /* @@ -878,8 +842,7 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; - initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); + initialize_mem_bw_resctrl(param->ctrlgrp, domain_id); } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, domain_id, resctrl_val); From patchwork Mon May 20 12:30:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797930 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C414755E53; Mon, 20 May 2024 12:31:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208315; cv=none; b=Yk1b94K/z8AIJRtqY8KoJnUCSOdNwt3ag43FuPkdJpYaeMWm+qhit0YbDsZGW1l9LJ0VbbK6zTSdPjw68rGm9rvMcsTKFUkyYiOj8ESegynGuUnyEbiP3Yz+Zr1S85WiJSIf83+sqJsb1Avm4KBdvBBIGNPpAtxXVcqVGGmMAes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208315; c=relaxed/simple; bh=GA4pv39MR635BUgP8l+N/zN9DfloTiIsJX023Tz0sW0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=cXhTVPb1IL/tg24RQb/3vF6h566siAqxKbAEwMwdtrNEimduF1YOEXiBaizNkzxjAjqr1Hjcy9BgYQ0ziGyXd4dJtAXUM/8oWQY1x5qxOGGkBzEgkU6KwqNBPHv1ZpFaJ5/CdVLvNmcaeDpJA5riRaCdJpMOEXJ9QupUbOiNEUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=frfTSl87; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="frfTSl87" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208314; x=1747744314; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GA4pv39MR635BUgP8l+N/zN9DfloTiIsJX023Tz0sW0=; b=frfTSl87/SpkGfTu2Bkhlva1gFnMus7KQPhJFgZDc/maNOXSdXJ4Upwg jQk8S3nMq0GMYGKHTBThIbCJK/J6PZShzR95mxgB9i4dF9kKVPmlGDBpd fHEiMP7PiaeJoJQo0ktxrta36kgKLajBB/B1uELaXgsGHUGZQm+x1pIPs R6JyM1EYP41aZfoXuwSQyQdrWud0jlP8M/c20Q7/WUF1YALjmVf9qnRz2 Z8sJvGJAZa0erPNSWhq4uV+f5kApjX34Px2EakL8+/KN1S9DZsBu28uib UfO7+5PrhZrgKzfgpsmottyh0rNysJaZU8r1lDLMJzPsaYliCSxSinbeV Q==; X-CSE-ConnectionGUID: Iy0saNWjTj2xn3C1bnHHbA== X-CSE-MsgGUID: AFevvtBuT0ylKH/4UNK2hA== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180458" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180458" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:53 -0700 X-CSE-ConnectionGUID: iOOxxlL5ThCDI6lTEnBTWQ== X-CSE-MsgGUID: ceTDA6/NRmW1zT61V0jYTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="37474623" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:50 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 09/16] selftests/resctrl: Add ->measure() callback to resctrl_val_param Date: Mon, 20 May 2024 15:30:13 +0300 Message-Id: <20240520123020.18938-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The measurement done in resctrl_val() varies depending on test type. The decision for how to measure is decided based on the string compare to test name which is quite inflexible. Add ->measure() callback into the struct resctrl_val_param to allow each test to provide necessary code as a function which simplifies what resctrl_val() has to do. Signed-off-by: Ilpo Järvinen --- v2: - spaces -> tabs --- tools/testing/selftests/resctrl/cmt_test.c | 8 ++++++++ tools/testing/selftests/resctrl/mba_test.c | 9 ++++++++- tools/testing/selftests/resctrl/mbm_test.c | 9 ++++++++- tools/testing/selftests/resctrl/resctrl.h | 6 ++++++ tools/testing/selftests/resctrl/resctrl_val.c | 18 +++++------------- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index a44e6fcd37b7..d8521386cd18 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -29,6 +29,13 @@ static int cmt_setup(const struct resctrl_test *test, return 0; } +static int cmt_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + sleep(1); + return measure_llc_resctrl(param->filename, bm_pid); +} + static int show_results_info(unsigned long sum_llc_val, int no_of_bits, unsigned long cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, @@ -133,6 +140,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, .setup = cmt_setup, + .measure = cmt_measure, }; span = cache_portion_size(cache_total_size, param.mask, long_mask); diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 5d6af9e8afed..de6e29faf214 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -51,6 +51,12 @@ static int mba_setup(const struct resctrl_test *test, return 0; } +static int mba_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + return measure_mem_bw(uparams, param, bm_pid); +} + static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) { int allocation, runs; @@ -150,7 +156,8 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mba_setup + .setup = mba_setup, + .measure = mba_measure, }; int ret; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 96d279b06377..59e26adf60bb 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -105,6 +105,12 @@ static int mbm_setup(const struct resctrl_test *test, return ret; } +static int mbm_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + return measure_mem_bw(uparams, param, bm_pid); +} + static void mbm_test_cleanup(void) { remove(RESULT_FILE_NAME); @@ -117,7 +123,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mbm_setup + .setup = mbm_setup, + .measure = mbm_measure, }; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index e4b6dc672ecc..5dc3def70669 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -87,6 +87,7 @@ struct resctrl_test { * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) * @setup: Call back function to setup test environment + * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { char *resctrl_val; @@ -99,6 +100,9 @@ struct resctrl_val_param { int (*setup)(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *param); + int (*measure)(const struct user_params *uparams, + struct resctrl_val_param *param, + pid_t bm_pid); }; struct perf_event_read { @@ -145,6 +149,8 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush); void mem_flush(unsigned char *buf, size_t buf_size); void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); +int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index a3cf3c5ed17f..76ae89e1aea3 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -607,8 +607,8 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark */ -static int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) +int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; FILE *mem_bw_fp, *mem_bw_fp2; @@ -879,17 +879,9 @@ int resctrl_val(const struct resctrl_test *test, if (ret < 0) break; - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_mem_bw(uparams, param, bm_pid); - if (ret) - break; - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { - sleep(1); - ret = measure_llc_resctrl(param->filename, bm_pid); - if (ret) - break; - } + ret = param->measure(uparams, param, bm_pid); + if (ret) + break; } out: From patchwork Mon May 20 12:30:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798569 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E04B455E53; Mon, 20 May 2024 12:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208323; cv=none; b=FgBo6eGwf3B13HmQycL1yy9OrDh33hsKAGlHWV9PXIkNVl1x0qQDdjDjOqFUB3oHUw19x5h8VTGwwB+j7GFQMe7FYvsZAguhDzsFTEmN6TVoGI2+jvoox/E562lLiBHZb2maGNIj69THnh8gcaQw2SsjNNPEq5MXft7gY5gONMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208323; c=relaxed/simple; bh=rCPpUqAyrEHzYYx8VYaQs+iFJXyOl5ii6bNWL0XxLsA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JpHiYjpmPhJtvBzVqfTLFkJl65p2dVelPNg/dBKb+yX5TJOL/KkqQ4LknM/ZlKkeUteofmuvhf09PCCed2aECvBocRqHFyho6ODotCM62eIsLo9Z+uZnO94Q8UKoEjjqKwLMqREQRkgk+WLpR60NSHUXNuQiSrAgne9ovVPC+ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Rm9/KfeH; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Rm9/KfeH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208322; x=1747744322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rCPpUqAyrEHzYYx8VYaQs+iFJXyOl5ii6bNWL0XxLsA=; b=Rm9/KfeHUGUQrD0p3Nvdg+RuVT9wbOyG+GZfASndWMzGZgT+4k7/wBBP JkAhahd4Qg2U/iXzbFr4JuO9TIKXevr/RQEGraImn4kgmiMUBYRqzwqfg AORtUzrHI2jVXe9A7dQkogInuaHCkx2UE5n0BN8cTDQiF1etvcn12DzSl spZkjbvCMFvs8fnn0GybLEXjJxx7CGhqpzl4TT59QemGS8abpZ4o/ZpAu 1j5neSPblzVNKAtM0tGs01MK3H53rDeFqBmFUgdmkR1CsgGKl5Yj9GKA6 EQ79+YM6v7UhH7uuRGOMagIeyve+bRzMWK0nugbkF+h00ahpPTVLDHgAe A==; X-CSE-ConnectionGUID: NvOk3IBjTzuA/TAAxg7dwA== X-CSE-MsgGUID: +8V4yykwTKu/7DbMmBF2Kg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180495" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180495" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:01 -0700 X-CSE-ConnectionGUID: NIVeV3qBRw6BKoVyLjNXAw== X-CSE-MsgGUID: tK1FuRh5Se6R/wLekH51+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091219" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:31:58 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 10/16] selftests/resctrl: Add ->init() callback into resctrl_val_param Date: Mon, 20 May 2024 15:30:14 +0300 Message-Id: <20240520123020.18938-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct resctrl_val_param is there to customize behavior inside resctrl_val() which is currently not used to full extent and there are number of strcmp()s for test name in resctrl_val done by resctrl_val(). Create ->init() hook into the struct resctrl_val_param to cleanly do per test initialization. Remove also unused branches to setup paths and the related #defines for CMT test. Signed-off-by: Ilpo Järvinen --- v3: - Rename init functions to _init() - Removed tabs intermixed with code - Leave now common mbm bw filename setup into resctrl_val.c --- tools/testing/selftests/resctrl/cmt_test.c | 12 +++ tools/testing/selftests/resctrl/mba_test.c | 14 ++++ tools/testing/selftests/resctrl/mbm_test.c | 14 ++++ tools/testing/selftests/resctrl/resctrl.h | 8 +- tools/testing/selftests/resctrl/resctrl_val.c | 75 ++++--------------- 5 files changed, 60 insertions(+), 63 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index d8521386cd18..238f514ba7e6 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -16,6 +16,17 @@ #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 +#define CON_MON_LCC_OCCUP_PATH \ + "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" + +static int cmt_init(const struct resctrl_val_param *param, int domain_id) +{ + sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, + param->ctrlgrp, param->mongrp, domain_id); + + return 0; +} + static int cmt_setup(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *p) @@ -139,6 +150,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, + .init = cmt_init, .setup = cmt_setup, .measure = cmt_measure, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index de6e29faf214..0a95c42f1616 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -17,6 +17,19 @@ #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 +static int mba_init(const struct resctrl_val_param *param, int domain_id) +{ + int ret; + + ret = initialize_mem_bw_imc(); + if (ret) + return ret; + + initialize_mem_bw_resctrl(param, domain_id); + + return 0; +} + /* * Change schemata percentage from 100 to 10%. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -156,6 +169,7 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = mba_init, .setup = mba_setup, .measure = mba_measure, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 59e26adf60bb..00e60b01188a 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -86,6 +86,19 @@ static int check_results(size_t span) return ret; } +static int mbm_init(const struct resctrl_val_param *param, int domain_id) +{ + int ret; + + ret = initialize_mem_bw_imc(); + if (ret) + return ret; + + initialize_mem_bw_resctrl(param, domain_id); + + return 0; +} + static int mbm_setup(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *p) @@ -123,6 +136,7 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = mbm_init, .setup = mbm_setup, .measure = mbm_measure, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 5dc3def70669..d3fbb957309d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -86,7 +86,8 @@ struct resctrl_test { * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) - * @setup: Call back function to setup test environment + * @init: Callback function to initialize test environment + * @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { @@ -97,6 +98,8 @@ struct resctrl_val_param { char *bw_report; unsigned long mask; int num_of_runs; + int (*init)(const struct resctrl_val_param *param, + int domain_id); int (*setup)(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *param); @@ -149,8 +152,11 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush); void mem_flush(unsigned char *buf, size_t buf_size); void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); +int initialize_mem_bw_imc(void); int measure_mem_bw(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid); +void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, + int domain_id); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 76ae89e1aea3..23a82bd547a3 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -23,18 +23,6 @@ #define CON_MBM_LOCAL_BYTES_PATH \ "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define CON_MON_LCC_OCCUP_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define CON_LCC_OCCUP_PATH \ - "%s/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define MON_LCC_OCCUP_PATH \ - "%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define LCC_OCCUP_PATH \ - "%s/mon_data/mon_L3_%02d/llc_occupancy" - struct membw_read_format { __u64 value; /* The value of the event */ __u64 time_enabled; /* if PERF_FORMAT_TOTAL_TIME_ENABLED */ @@ -268,7 +256,7 @@ static int num_of_imcs(void) return count; } -static int initialize_mem_bw_imc(void) +int initialize_mem_bw_imc(void) { int imc, j; @@ -430,24 +418,18 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) /* * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) + * @param: parameters passed to resctrl_val() + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) */ -static void initialize_mem_bw_resctrl(const char *ctrlgrp, int domain_id) +void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, + int domain_id) { sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - ctrlgrp, domain_id); + param->ctrlgrp, domain_id); } /* - * Get MBM Local bytes as reported by resctrl FS - * For MBM, - * 1. If con_mon grp and mon grp are given, then read from con_mon grp's mon grp - * 2. If only con_mon grp is given, then read from con_mon grp - * 3. If both are not given, then read from root con_mon grp - * For MBA, - * 1. If con_mon grp is given, then read from it - * 2. If con_mon grp is not given, then read from root con_mon grp + * Open file to read MBM local bytes from resctrl FS */ static FILE *open_mem_bw_resctrl(const char *mbm_bw_file) { @@ -460,6 +442,9 @@ static FILE *open_mem_bw_resctrl(const char *mbm_bw_file) return fp; } +/* + * Get MBM Local bytes as reported by resctrl FS + */ static int get_mem_bw_resctrl(FILE *fp, unsigned long *mbm_total) { if (fscanf(fp, "%lu", mbm_total) <= 0) { @@ -572,35 +557,6 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, return 0; } -static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num) -{ - if (strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, mongrp, sock_num); - else if (!strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, MON_LCC_OCCUP_PATH, RESCTRL_PATH, - mongrp, sock_num); - else if (strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, CON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, sock_num); - else if (!strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, LCC_OCCUP_PATH, RESCTRL_PATH, sock_num); -} - -/* - * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @mongrp: Name of the monitor group (mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) - * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) - */ -static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, - int domain_id, char *resctrl_val) -{ - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - set_cmt_path(ctrlgrp, mongrp, domain_id); -} - /* * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs * @uparams: User supplied parameters @@ -836,16 +792,11 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = initialize_mem_bw_imc(); + if (param->init) { + ret = param->init(param, domain_id); if (ret) goto out; - - initialize_mem_bw_resctrl(param->ctrlgrp, domain_id); - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); + } /* Parent waits for child to be ready. */ close(pipefd[1]); From patchwork Mon May 20 12:30:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797929 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04AA6BB44; Mon, 20 May 2024 12:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208332; cv=none; b=NVzU1kGyO9+reYgGqajno6v6hqLKbTgLUhmYO0A1E9arm8lXcNMhYmo4DT1kvfjNmlYb3hmi6SLiyBFNbcEsocH3VgbUb7LfA60oymDKQXU/h1e+l179JsjR+GpGfwq+zyMSs+pBqRduUdLyTkTiEnxwUJ8pjnvVxILlZilXCIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208332; c=relaxed/simple; bh=aZZyt4NFPtXxU+nIadLJ1WaUrIuPpQqgZN/i+LIpzgE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=WLyzBcE8gr5WLvHQBCRr20sdZQPCsoJ4Jc5IG5Q2FdYE8VV3dHaxjh7vaJV40CJlSSojVDdEwhM7/Vjn6ve1QyhXLy+7g+1IA0eLVmdjADxTk/vKr1lDMSoUXA7xzQa+2WWS+MUSnT+LN8RKU067baTck3Ffqtpf3T4uzR8/DWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aWlD6hBP; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aWlD6hBP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208330; x=1747744330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aZZyt4NFPtXxU+nIadLJ1WaUrIuPpQqgZN/i+LIpzgE=; b=aWlD6hBPPi7nwUElHhDGSNa7ekiJD5VErA5o5i7NNjMGPb6NVk3DNQIX biT6UPkSDcU2nz59YYt11NNpbiLIqc0L+gkhIrB/Sj6CMkQPn/Z997h4v dOBEfd7XO0C1YHxLNrSAte29FDYCUYFmcIw5Y+kOk3rdMcjXjUyiR8Ytj +v7cc4scojAXFNnmGb46K6SuGGeU5ysjFZnLJxZ/M3i1GbSh6k4J4+XUz //y5RVF9StgA0Fq5WwbmWWdED/4kwjR9ih6Y6PtjCufy1/WGsdUZIMtd8 tEa8aEuKJAjsRyAHC4x7hO1aP1whUnvZlGKNrMBfOg6p0mPPCY2UnXioT A==; X-CSE-ConnectionGUID: Ni+CSCaEQLG2u+QRylmXaw== X-CSE-MsgGUID: 7a0dq5lOTee1+Fs55jDhlw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180530" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180530" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:10 -0700 X-CSE-ConnectionGUID: QlAKOWKRTuuUws68pREO7Q== X-CSE-MsgGUID: CI9jpiZxR5yRNSVrmLGb+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091231" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:07 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 11/16] selftests/resctrl: Simplify bandwidth report type handling Date: Mon, 20 May 2024 15:30:15 +0300 Message-Id: <20240520123020.18938-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 bw_report is only needed for selecting the correct value from the values IMC measured. It is a member in the resctrl_val_param struct and is always set to "reads". The value is then checked in resctrl_val() using validate_bw_report_request() that besides validating the input, assumes it can mutate the string which is questionable programming practice. Simplify handling bw_report: - Convert validate_bw_report_request() into get_bw_report_type() that inputs and returns const char *. Use NULL to indicate error. - Validate the report types inside measure_mem_bw(), not in resctrl_val(). - As resctrl_val() no longer needs bw_report for anything, it can just be passed to measure_mem_bw() by the ->measure() hooks. Signed-off-by: Ilpo Järvinen --- v2: - Rebased on top of next to resolve conflict in resctrl.h --- tools/testing/selftests/resctrl/mba_test.c | 3 +-- tools/testing/selftests/resctrl/mbm_test.c | 3 +-- tools/testing/selftests/resctrl/resctrl.h | 7 +++---- tools/testing/selftests/resctrl/resctrl_val.c | 19 +++++++++---------- tools/testing/selftests/resctrl/resctrlfs.c | 13 ++++++------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 0a95c42f1616..9c9a4f22e529 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -67,7 +67,7 @@ static int mba_setup(const struct resctrl_test *test, static int mba_measure(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid) { - return measure_mem_bw(uparams, param, bm_pid); + return measure_mem_bw(uparams, param, bm_pid, "reads"); } static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) @@ -168,7 +168,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mba_init, .setup = mba_setup, .measure = mba_measure, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 00e60b01188a..27b936fe60bc 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -121,7 +121,7 @@ static int mbm_setup(const struct resctrl_test *test, static int mbm_measure(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid) { - return measure_mem_bw(uparams, param, bm_pid); + return measure_mem_bw(uparams, param, bm_pid, "reads"); } static void mbm_test_cleanup(void) @@ -135,7 +135,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .resctrl_val = MBM_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mbm_init, .setup = mbm_setup, .measure = mbm_measure, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index d3fbb957309d..4446a0e493ef 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -85,7 +85,6 @@ struct resctrl_test { * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written - * @bw_report: Bandwidth report type (reads vs writes) * @init: Callback function to initialize test environment * @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test) @@ -95,7 +94,6 @@ struct resctrl_val_param { char ctrlgrp[64]; char mongrp[64]; char filename[64]; - char *bw_report; unsigned long mask; int num_of_runs; int (*init)(const struct resctrl_val_param *param, @@ -135,7 +133,7 @@ int filter_dmesg(void); int get_domain_id(const char *resource, int cpu_no, int *domain_id); int mount_resctrlfs(void); int umount_resctrlfs(void); -int validate_bw_report_request(char *bw_report); +const char *get_bw_report_type(const char *bw_report); bool resctrl_resource_exists(const char *resource); bool resctrl_mon_feature_exists(const char *resource, const char *feature); bool resource_info_file_exists(const char *resource, const char *file); @@ -154,7 +152,8 @@ void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); int initialize_mem_bw_imc(void); int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid); + struct resctrl_val_param *param, pid_t bm_pid, + const char *bw_report); void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, int domain_id); int resctrl_val(const struct resctrl_test *test, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 23a82bd547a3..b2b944a70fb9 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -349,7 +349,7 @@ static void do_imc_mem_bw_test(void) * * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc(char *bw_report, float *bw_imc) +static int get_mem_bw_imc(const char *bw_report, float *bw_imc) { float reads, writes, of_mul_read, of_mul_write; int imc; @@ -562,15 +562,21 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, * @uparams: User supplied parameters * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark + * @bw_report: Bandwidth report type (reads, writes) */ int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) + struct resctrl_val_param *param, pid_t bm_pid, + const char *bw_report) { unsigned long bw_resc, bw_resc_start, bw_resc_end; FILE *mem_bw_fp, *mem_bw_fp2; float bw_imc; int ret; + bw_report = get_bw_report_type(bw_report); + if (!bw_report) + return -1; + mem_bw_fp = open_mem_bw_resctrl(mbm_total_path); if (!mem_bw_fp) return -1; @@ -601,7 +607,7 @@ int measure_mem_bw(const struct user_params *uparams, if (ret < 0) goto close_fp2; - ret = get_mem_bw_imc(param->bw_report, &bw_imc); + ret = get_mem_bw_imc(bw_report, &bw_imc); if (ret < 0) goto close_fp2; @@ -705,13 +711,6 @@ int resctrl_val(const struct resctrl_test *test, return ret; } - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || - !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - ret = validate_bw_report_request(param->bw_report); - if (ret) - return ret; - } - /* * If benchmark wasn't successfully started by child, then child should * kill parent, so save parent's pid diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 9b86f826a40c..aac382eaa032 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -837,22 +837,21 @@ int filter_dmesg(void) return 0; } -int validate_bw_report_request(char *bw_report) +const char *get_bw_report_type(const char *bw_report) { if (strcmp(bw_report, "reads") == 0) - return 0; + return bw_report; if (strcmp(bw_report, "writes") == 0) - return 0; + return bw_report; if (strcmp(bw_report, "nt-writes") == 0) { - strcpy(bw_report, "writes"); - return 0; + return "writes"; } if (strcmp(bw_report, "total") == 0) - return 0; + return bw_report; fprintf(stderr, "Requested iMC bandwidth report type unavailable\n"); - return -1; + return NULL; } int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, From patchwork Mon May 20 12:30:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798568 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 706A56BB5B; Mon, 20 May 2024 12:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208340; cv=none; b=ZQZWgNctAnRE4LfY6wlmGa/Z85wyzuujs/7lXNnxtWn34Go+PGn5+gimh7acjB9WRhibxhnRygxPV+BAR8w18GOsPljAFfNttgyF/3rbZQSjWWJIHoHSgFcZzdtvQBV7yTPwizdYuX1y8BAGuX6wTyr9h8Cj+NrfrUllQe/DRg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208340; c=relaxed/simple; bh=530we9tbb1br2D5djQ/lnp1n4VHVKq4UhHt+32wQESQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=mHNNHpryzB70DPnUZ06IDOnT0idUKQf9DH6+IUsD538Hz9He8Vhxd/APid+orcB4mF15LA5JliXSnaqp4jPAhU4+2d2x2bfjbTk8ii84GjqirSpDlw0SXaGclrr10Ng6uHxRFj8PB20xuHLbB2i5cyoeNWJp//OkElFl/2g7b30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ug1phEon; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ug1phEon" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208339; x=1747744339; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=530we9tbb1br2D5djQ/lnp1n4VHVKq4UhHt+32wQESQ=; b=Ug1phEonWEYPXkGzRxjEYLnSG35Rn9dgI3zOMJ9tqwqd1QeaO/Jyc/pb dP89rSeZ+bpO39JG6Y9I4UoTqbfuNSvF6R2bzfdzwSRjnAzs9mma6S+q3 ghscS/41LmgZNmuhat9rJqlTgqoca/NklbJBnrcCPoNdz21oDSjd4JG1E aZwyBEcBySALoQ8XQSfDh4uMeIGnK/n0bC1PxpsRJPbOo2ggol9fk3fb+ pIsOiLDp0FmLZaBvyorbFsvY1PDtCrBdtD+FiuyyL0o8tmRelu2cLCfkQ uMxHjA1PUxh/Y36ohzTNBnfTHv68P6cD8UX2Bbgb3RgK6UAnse6vSoxxf A==; X-CSE-ConnectionGUID: 5pqFe0JDTTKHbbhKZsyXFw== X-CSE-MsgGUID: dN6iL4uMS6CIVDfWIvk4Fw== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180544" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180544" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:19 -0700 X-CSE-ConnectionGUID: HONmiqAjShaqzJMUIBk8eQ== X-CSE-MsgGUID: DWdxaSGLSxKapeDDse7UiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091261" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:16 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 12/16] selftests/resctrl: Make some strings passed to resctrlfs functions const Date: Mon, 20 May 2024 15:30:16 +0300 Message-Id: <20240520123020.18938-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Control group, monitor group and resctrl_val are not mutated and should not be mutated within resctrlfs.c functions. Mark this by using const char * for the arguments. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 7 ++++--- tools/testing/selftests/resctrl/resctrlfs.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4446a0e493ef..5967389038d4 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -141,9 +141,10 @@ bool test_resource_feature_check(const struct resctrl_test *test); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity); -int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource); -int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, - char *resctrl_val); +int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, + const char *resource); +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, + const char *mongrp, const char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); unsigned char *alloc_buffer(size_t buf_size, int memflush); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index aac382eaa032..a0e84157eb63 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -534,8 +534,8 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, - char *resctrl_val) +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, + const char *mongrp, const char *resctrl_val) { char controlgroup[128], monitorgroup[512], monitorgroup_p[256]; char tasks[1024]; @@ -593,7 +593,8 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, * * Return: 0 on success, < 0 on error. */ -int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource) +int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, + const char *resource) { char controlgroup[1024], reason[128], schema[1024] = {}; int domain_id, fd, schema_len, ret = 0; From patchwork Mon May 20 12:30:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797928 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 148C359147; Mon, 20 May 2024 12:32:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208349; cv=none; b=OkZMHRvZGGqxQHJLFYd1ThpOpqqQzklvSes3RnXPa+F0la5oDoQKRUkwLCU2+HAW6GU5nxiKfqpTyUFJmvXi4WYuUV2KWRORD5mj2I8vVgW3KUL9k4ZFQP2aalolcTmbDswb5MOaX7iMNwZjSu3qRrjnaHwuV9/Tukot04VG+r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208349; c=relaxed/simple; bh=zcaBoK/ACFrIjjdFXj8eyQESy8iAslUg8GB4EQy4ers=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LCZv/LYsiP7MmyJ8kK+QnP4g/h035WLhRrIy48wv2JVdhLmiwGLJzzHe4O7KguZmPUySgf8phruIi68x6axy3iDLIJhOd7cL+hVUH7DganEmLtsNyso0O948+2fcDgp0VaKKvMlpiwMb9XLvhV/ZLthu3dise9za6qz0wOEZ9H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=I1ZPR5KU; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="I1ZPR5KU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208348; x=1747744348; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zcaBoK/ACFrIjjdFXj8eyQESy8iAslUg8GB4EQy4ers=; b=I1ZPR5KUO96o2odX7FAmXeg8BeC7mwXs9fNC+VebRDJaytbRUr+HM0rD VjyuOwFjFhourm2yXqJg19Tz2ilAqmJWlILsN5sx+4335rcRfUS0C4e3G qNM2UJG9gTy7U0ER+JqmRTV+lAV6IOuyIzHvIUSQOG8AatKOkGzsE0a3L pnoeMbwzxHGiw2GExdn8909Lvfhgg4ahJD9gvxU/hIwlLY3H3oSqRnJYH 8dKhmZGwxvXaSkFPWQ5FGmkrm7d+I/NOEQSky0+uycCL9UAtc9SoSI4fI /OimQ7/S7ikRaYffH0kx3knCaZzi0nWLBo03kdOmQkKQtrUOL6aywXRYJ Q==; X-CSE-ConnectionGUID: NIR5mArpQ0qcSV55N5UsXA== X-CSE-MsgGUID: 6h1h4VlXTb22H+8dIAlyRg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12180558" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="12180558" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:28 -0700 X-CSE-ConnectionGUID: sz8r3dBKS0iodzgPVEo8qQ== X-CSE-MsgGUID: LN7xEZuhRSq2z5LHB1gVHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="33091294" Received: from unknown (HELO localhost) ([10.245.247.114]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:24 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 13/16] selftests/resctrl: Convert ctrlgrp & mongrp to pointers Date: Mon, 20 May 2024 15:30:17 +0300 Message-Id: <20240520123020.18938-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct resctrl_val_param has control and monitor groups as char arrays but they are not supposed to be mutated within resctrl_val(). Convert the ctrlgrp and mongrp char array within resctrl_val_param to plain const char pointers and adjust the strlen() based checks to check NULL instead. Convert !grp_name check in create_grp() into internal sanity check by returning error if the caller asked to create a group but doesn't provide a name for the group. The existing code already abides this by only calling create_grp() if mongrp is non-NULL so the error should never be returned with the current selftests (ctrlgrp is never NULL). Signed-off-by: Ilpo Järvinen --- v3: - Removed wrong comment - Changed grp_name check to return -1 on fail (internal sanity check) --- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrlfs.c | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 5967389038d4..a999fbc13fd3 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -91,8 +91,8 @@ struct resctrl_test { */ struct resctrl_val_param { char *resctrl_val; - char ctrlgrp[64]; - char mongrp[64]; + const char *ctrlgrp; + const char *mongrp; char filename[64]; unsigned long mask; int num_of_runs; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index a0e84157eb63..6b4448588666 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -464,13 +464,8 @@ static int create_grp(const char *grp_name, char *grp, const char *parent_grp) struct dirent *ep; DIR *dp; - /* - * At this point, we are guaranteed to have resctrl FS mounted and if - * length of grp_name == 0, it means, user wants to use root con_mon - * grp, so do nothing - */ - if (strlen(grp_name) == 0) - return 0; + if (!grp_name) + return -1; /* Check if requested grp exists or not */ dp = opendir(parent_grp); @@ -541,7 +536,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, char tasks[1024]; int ret = 0; - if (strlen(ctrlgrp)) + if (ctrlgrp) sprintf(controlgroup, "%s/%s", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s", RESCTRL_PATH); @@ -558,7 +553,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, /* Create mon grp and write pid into it for "mbm" and "cmt" test */ if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) || !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - if (strlen(mongrp)) { + if (mongrp) { sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); ret = create_grp(mongrp, monitorgroup, monitorgroup_p); @@ -612,7 +607,7 @@ int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, goto out; } - if (strlen(ctrlgrp) != 0) + if (ctrlgrp) sprintf(controlgroup, "%s/%s/schemata", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s/schemata", RESCTRL_PATH); From patchwork Mon May 20 12:30:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798567 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E2595674A; Mon, 20 May 2024 12:32:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208358; cv=none; b=Hi+K1hICKNWorDLDuaBSNhlBPqhRrChblGMSD7kqNCBzfsWkIoHwP3z7rQlgkxm55UWD2ZCj7UAHj7hpspDr4cx8vkAw5SEG6BPJJr/GL3Q2pfYf/u+rQHaO2gYxtKaabRYRcu80waDSQ7vj+3Q/ScseHtirSgyJ4TLiSoVLghU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208358; c=relaxed/simple; bh=Iy0JjcLUSebL6oRihQ/kvCDMmxysZknFiWvlqSKnjQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZtgI4N0Bvp+epgeChFN5P6R+aB7luq85gmXNrN3gCd4vRJRTYedZThn5urmf0J8UCw0dWHhhb5e1pehPzViNT+UN3mP3OCxMe91BQcGIbGf4RBlVwn+H5+TRUJMUoEHKOEXZEVb8tNCAWfhY7t3Ui4ie4jQfhRuLsQwfWidZFFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fMhHm0mu; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fMhHm0mu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208357; x=1747744357; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iy0JjcLUSebL6oRihQ/kvCDMmxysZknFiWvlqSKnjQo=; b=fMhHm0mui5i0QVv2wH2bBO1Z6bIVXpHLzzDv/8+P5ZxLalUgRiGcuCb8 3zf4lEco9ok5Iw+FwzXvaiCCFJ/No0yEhFpK3B5NNRlUn0BayztLXPWt5 NCFP29MvY2A/a8Nu8TK3lHM6DAcTPDoGzoZrAoXIE8knhP7AoaV7h4qBG FGgICKcl/JEclF8SVbUjG/68s4a1VxPgK2COpq4aCLgt0vDp5ddIwSsKz Sp4HYr1JK32r6qEG769/EaM55glaSi9CeAjWoHU8KVEGKyqKSxQFhPMUI gMgZ9MV0LG7pVWKAtBurJcFocDkK7sOzd5DhJwepZaaRJs1dsKXEEmSoU Q==; X-CSE-ConnectionGUID: Bl0zeG1xTVOnx2COdL2oOA== X-CSE-MsgGUID: glKVYXP5QG6Q3jRQ8au0MQ== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="23475470" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="23475470" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:37 -0700 X-CSE-ConnectionGUID: H7OGw2arSrG0XJUYeXXLOg== X-CSE-MsgGUID: 03vx+tvXS+eYCiFm5yQAOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="63747804" Received: from unknown (HELO localhost) ([10.245.247.114]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:33 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 14/16] selftests/resctrl: Remove mongrp from MBA test Date: Mon, 20 May 2024 15:30:18 +0300 Message-Id: <20240520123020.18938-15-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Nothing during MBA test uses mongrp even if it has been defined ever since the introduction of the MBA test in the commit 01fee6b4d1f9 ("selftests/resctrl: Add MBA test"). Remove the mongrp from MBA test. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mba_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 9c9a4f22e529..5e0b1e794295 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -166,7 +166,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param struct resctrl_val_param param = { .resctrl_val = MBA_STR, .ctrlgrp = "c1", - .mongrp = "m1", .filename = RESULT_FILE_NAME, .init = mba_init, .setup = mba_setup, From patchwork Mon May 20 12:30:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 797927 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF7B356754; Mon, 20 May 2024 12:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208365; cv=none; b=mUGbuDr4oDp0r2dIDX9706INksrMBHEC5aO4K5BeAXdOgy5iKCtkxpXU0WLcHSvWfjAeW4Qcl1Dfx8dr982lBzlix/+ukGUdSH76R17nEz0lGcyO7p52B7zRl6Iq8M4OdeZ/bdNwK1ePYu4Cgc4AwCF1OejR0+Z9NTdCFwb/Bcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208365; c=relaxed/simple; bh=DeuVhYVGlbeHQx+ZSQaZAGwOZQyUcwm1aYbJ2e5hPsk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=u6rTVmmRAaNNSPyl0Brn0XWESp7nVg4ra36o6TRrffZk++ZY0BaG/KP5NBA5Q1scc274j2lOdIuk/XBlZlMP1ZnDflOtpFdJcEVxXRHxc4Q6deHav0+pAX1c+Ttre/Xu5UIBo9+FxI/XeKHQu8gwcxWirgHSQYzYXEJI/kpgwJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ScbJn3A/; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ScbJn3A/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208364; x=1747744364; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DeuVhYVGlbeHQx+ZSQaZAGwOZQyUcwm1aYbJ2e5hPsk=; b=ScbJn3A/LmK5iiMjav8q69/IuyETsXQrO0gHOVCnZcnJe+2/c6tBgjjh 62fTBfVSvlgON3+2XKIGk+CBfs1n+ZyIdieerd+bSSJ5FiD9FbgtEcWqF dklzpGfWJBVnMZtqr1PxeDQViVoTkt526R7cEbbxnXgBOtIU9ly8AJEJE 3mauIZDP4xvGJeKx/7qtb58oDwDNwYg0SmVQNSXoQ5NmUg8Ny7vkH27YL R1gVHEzKwNOSMglohTFmuiOtAJWP+Mna8eXc5NIYit5Oufkmz4WWS6FhF W9jKNbtn1zIEXw+ku3LmgCWyM9yrg7dgsYoRCLyau4RKflbyeCA5KGbCT A==; X-CSE-ConnectionGUID: lrfcJXKNQ92JefuX3F7d5Q== X-CSE-MsgGUID: 8n7hoCUoRYWXCYziCNyXZA== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="23475491" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="23475491" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:44 -0700 X-CSE-ConnectionGUID: GQtPIMLERHS3/rjb18IPlg== X-CSE-MsgGUID: jDAXmw/YSEST+IftWVvl3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="63747811" Received: from unknown (HELO localhost) ([10.245.247.114]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:41 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 15/16] selftests/resctrl: Remove mongrp from CMT test Date: Mon, 20 May 2024 15:30:19 +0300 Message-Id: <20240520123020.18938-16-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The CMT selftest instanciates a monitor group to read LLC occupancy. Since the test also creates a control group, it is unnecessary to create another one for monitoring because control groups already provide monitoring too. Remove the unnecessary monitor group from the CMT selftest. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v4: - New patch --- tools/testing/selftests/resctrl/cmt_test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 238f514ba7e6..b63fa1e93307 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -17,12 +17,12 @@ #define MAX_DIFF_PERCENT 15 #define CON_MON_LCC_OCCUP_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" + "%s/%s/mon_data/mon_L3_%02d/llc_occupancy" static int cmt_init(const struct resctrl_val_param *param, int domain_id) { sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, - param->ctrlgrp, param->mongrp, domain_id); + param->ctrlgrp, domain_id); return 0; } @@ -146,7 +146,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param struct resctrl_val_param param = { .resctrl_val = CMT_STR, .ctrlgrp = "c1", - .mongrp = "m1", .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, From patchwork Mon May 20 12:30:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 798566 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A7415674E; Mon, 20 May 2024 12:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208374; cv=none; b=fuvHzFZuJk42h+hgYo10l+Iyht1GsZV7aqfdmCn1nu6HWIfmSbEAWqFJMakqOyBfpd7m+yWPcoFam9J9/nGEwbAPjy8sEKg9U5XKQS/LDKRvHW5dt0CswdiK1VGvVzyLwTCjd3POwbDTiJ8Arh/rQ3uvIViAP8n8CMFj0A5iTKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716208374; c=relaxed/simple; bh=m8Ay8MkqRIOBzYe6MzQZIISyQvOfsbMcEQaEQT9xQ6Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JVVP/6bqMbJnpSVS7BK+GBL8MYG0oqJSh+lI7Qq55QWqR+ZT3M6u/p+jCswY3xNbiZUXnOyLV3PQhXTEhQRfDOBDbHVlbf7WzPhkPLeJqJOR4P15qVVXVI4Y6zwODwhZZMVTpDH/4vAq5LkxyrcAUdX+22bT6JUwyvMe/+fgpAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cisR0SiT; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cisR0SiT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716208373; x=1747744373; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m8Ay8MkqRIOBzYe6MzQZIISyQvOfsbMcEQaEQT9xQ6Q=; b=cisR0SiTIAtBZWuByJsZcbTQrtEPYnG86j7oNz+d5fce4oV4KFl3fEVd +9q+EgoXoWty+RwQVPvcWlIEb23fsNMJQsnqy5Lcri9bTOzga1eJqUM6L BLI6H1PKCCavXxrMJyj8trJF44KinRJ2xoSVqX1VjGg7kjxtFXgTU43U9 vgxQvlLzlGRSrw9yqiezH4wESA6vGE3kYC0WwLDK7WadpfTRN5AmyC5y0 A5JLrZfgDC+ovH6lt81KNYLFxcCvOzSYLu33lPSPZbdpd7r8IjwAUjuDr y5H+Zajx033GmwUHxQF7hdgM12ObP+9JUXi6ExoflgfGh2KFv5MjkWQ49 A==; X-CSE-ConnectionGUID: +QPScvsGTDOZOApOLHLnUw== X-CSE-MsgGUID: TKeLot8ETLOfLH8fo1/9mg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="23475528" X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="23475528" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:53 -0700 X-CSE-ConnectionGUID: BNKLkKUrSkqJ7FtAUVMe7A== X-CSE-MsgGUID: kBxmBYOxT8SvJpnXXwqNzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,175,1712646000"; d="scan'208";a="63747818" Received: from unknown (HELO localhost) ([10.245.247.114]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 05:32:49 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: linux-kernel@vger.kernel.org, Fenghua Yu , Shuah Khan , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 16/16] selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl() Date: Mon, 20 May 2024 15:30:20 +0300 Message-Id: <20240520123020.18938-17-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> References: <20240520123020.18938-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 write_bm_pid_to_resctrl() uses resctrl_val to check test name which is not a good interface generic resctrl FS functions should provide. Only MBM and CMT tests define mongrp so the test name check in write_bm_pid_to_resctrl() can be changed to depend simply on mongrp being non-NULL. With last user of resctrl_val gone, the parameter and member from the struct resctrl_val_param can removed. Test name constants can also be removed because they are not used anymore. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 5 +-- tools/testing/selftests/resctrl/cmt_test.c | 1 - tools/testing/selftests/resctrl/mba_test.c | 1 - tools/testing/selftests/resctrl/mbm_test.c | 1 - tools/testing/selftests/resctrl/resctrl.h | 10 +----- tools/testing/selftests/resctrl/resctrl_val.c | 4 +-- tools/testing/selftests/resctrl/resctrlfs.c | 33 ++++++++----------- 7 files changed, 17 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index c7686fb6641a..d4dffc934bc3 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -158,7 +158,6 @@ static int cat_test(const struct resctrl_test *test, struct resctrl_val_param *param, size_t span, unsigned long current_mask) { - char *resctrl_val = param->resctrl_val; struct perf_event_read pe_read; struct perf_event_attr pea; cpu_set_t old_affinity; @@ -178,8 +177,7 @@ static int cat_test(const struct resctrl_test *test, return ret; /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/ - ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto reset_affinity; @@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param start_mask = create_bit_mask(start, n); struct resctrl_val_param param = { - .resctrl_val = CAT_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .num_of_runs = 0, diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index b63fa1e93307..d1c272743eb2 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -144,7 +144,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param } struct resctrl_val_param param = { - .resctrl_val = CMT_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 5e0b1e794295..1f2a7dc73b62 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -164,7 +164,6 @@ static void mba_test_cleanup(void) static int mba_run_test(const struct resctrl_test *test, const struct user_params *uparams) { struct resctrl_val_param param = { - .resctrl_val = MBA_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .init = mba_init, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 27b936fe60bc..39aa70374154 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -132,7 +132,6 @@ static void mbm_test_cleanup(void) static int mbm_run_test(const struct resctrl_test *test, const struct user_params *uparams) { struct resctrl_val_param param = { - .resctrl_val = MBM_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .init = mbm_init, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index a999fbc13fd3..2dda56084588 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -81,7 +81,6 @@ struct resctrl_test { /* * resctrl_val_param: resctrl test parameters - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written @@ -90,7 +89,6 @@ struct resctrl_test { * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { - char *resctrl_val; const char *ctrlgrp; const char *mongrp; char filename[64]; @@ -113,11 +111,6 @@ struct perf_event_read { } values[2]; }; -#define MBM_STR "mbm" -#define MBA_STR "mba" -#define CMT_STR "cmt" -#define CAT_STR "cat" - /* * Memory location that consumes values compiler must not optimize away. * Volatile ensures writes to this location cannot be optimized away by @@ -143,8 +136,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity); int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, const char *resource); -int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, - const char *mongrp, const char *resctrl_val); +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); unsigned char *alloc_buffer(size_t buf_size, int memflush); diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index b2b944a70fb9..719a08ece9d3 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -695,7 +695,6 @@ int resctrl_val(const struct resctrl_test *test, const char * const *benchmark_cmd, struct resctrl_val_param *param) { - char *resctrl_val = param->resctrl_val; struct sigaction sigact; int ret = 0, pipefd[2]; char pipe_message = 0; @@ -786,8 +785,7 @@ int resctrl_val(const struct resctrl_test *test, goto out; /* Write benchmark to specified control&monitoring grp in resctrl FS */ - ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto out; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 6b4448588666..4bf1fe6dc308 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -519,7 +519,6 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * @bm_pid: PID that should be written * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * * If a con_mon grp is requested, create it and write pid to it, otherwise * write pid to root con_mon grp. @@ -529,8 +528,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, - const char *mongrp, const char *resctrl_val) +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp) { char controlgroup[128], monitorgroup[512], monitorgroup_p[256]; char tasks[1024]; @@ -550,22 +548,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, if (ret) goto out; - /* Create mon grp and write pid into it for "mbm" and "cmt" test */ - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) || - !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - if (mongrp) { - sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); - sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); - ret = create_grp(mongrp, monitorgroup, monitorgroup_p); - if (ret) - goto out; - - sprintf(tasks, "%s/mon_groups/%s/tasks", - controlgroup, mongrp); - ret = write_pid_to_tasks(tasks, bm_pid); - if (ret) - goto out; - } + /* Create monitor group and write pid into if it is used */ + if (mongrp) { + sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); + sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); + ret = create_grp(mongrp, monitorgroup, monitorgroup_p); + if (ret) + goto out; + + sprintf(tasks, "%s/mon_groups/%s/tasks", + controlgroup, mongrp); + ret = write_pid_to_tasks(tasks, bm_pid); + if (ret) + goto out; } out: