From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 252ED3FB3B; Mon, 11 Mar 2024 13:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165184; cv=none; b=fiuWNDJFiOCR0XITWYV1/yIYWADM04jPCvw0KQgxtoW8QLU9BD/1p6lgcT/7zbn8LxWJ8e76FiRSxKiXHPHIpJew34de2RxWaiApt0owxWo7E+P2zz/jcmyRMM5a2106gkvD3GMDcns2g/W7KjuTj+dVNRO9yA5tNFzsvjRB/Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165184; c=relaxed/simple; bh=bHwKVL1u0+Vdw8KGQFEU4SKrjknuufMsPWFSJoS9tHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=a7RTux3YyzLKWl3D6TjaDc1n2apFP4YecbhtXel77rkW4RpQPOQcTZ2EzKDnEEpPsNO/YMR7KzM3A/ooUYpTaSafl7zG1qV8v2+ZukBLhZQ1NwpKSV8K2/KGIYn2KEzl+xGF0XmSKysQtbTSetoxtJ7XKxXdYvA2/uxsKV/9cy0= 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=U1lCp4+z; arc=none smtp.client-ip=198.175.65.11 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="U1lCp4+z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165183; x=1741701183; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bHwKVL1u0+Vdw8KGQFEU4SKrjknuufMsPWFSJoS9tHg=; b=U1lCp4+zeOL6rDQ9jDoTpBLVpT0+zcYbpJc1rOBt54+1FDq/EForBGxw YDbBieWplf0ye3j7KAjWXKqx341g2J+xLum3QQYiuz6iCj/HMTe/qDewW smiEhTotz7UspwZn2s9L+Q9C+6HnP7SbCzKlGBInYYszYrYn1Ll6j7tL+ lE+M3+iab7v9x2ykuleTaV/S2uVHJmhZdj99EnYH4Tb6nZkj50cIm/o8g ZbtK5QvDUTvew2GbsYHcm40ZSWsuLbm5WzuA2nVgMj84u+93VaIS+rwdK CJQQ2FlmOiCiO/SJeKFCj0LiaMdfoW5K6XahHySLlG90NjF3uoviGAkmv A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15388715" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15388715" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11166645" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:00 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 01/13] selftests/resctrl: Convert get_mem_bw_imc() fd close to for loop Date: Mon, 11 Mar 2024 15:52:18 +0200 Message-Id: <20240311135230.7007-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The open() side handles fds in a for loop but close() is based on two fixed indexes READ and WRITE. Match the close() side with the open() side by using for loop for consistency. Signed-off-by: Ilpo J=C3=A4rvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 5a49f07a6c85..36139cba7be8 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -368,10 +368,9 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report,= float *bw_imc) writes +=3D w->return_value.value * of_mul_write * SCALE; } =20 - for (imc =3D 0; imc < imcs; imc++) { - close(imc_counters_config[imc][READ].fd); - close(imc_counters_config[imc][WRITE].fd); - } + for (imc =3D 0; imc < imcs; imc++) + for (j =3D 0; j < 2; j++) + close(imc_counters_config[imc][j].fd); =20 if (strcmp(bw_report, "reads") =3D=3D 0) { *bw_imc =3D reads; --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 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 B4DE43EA62; Mon, 11 Mar 2024 13:53:17 +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=1710165199; cv=none; b=kwvqyepaLYtN6+riPHayxM6lolTkT4TQhR0oaySBm7jA3MOKD5XQk5DKUB/j5vXqA0NmtKbgLDKKOlu/A/tzk+fhoozGB3WAWQQbqdHyuYAC5Ft9mVQOdBC84EXtRYoJGhBMQuQTADJur4cYa0B4hxYhV7yKzyyhHl6KN5bwajU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165199; c=relaxed/simple; bh=sEYLNbkyuSH14euw2egzBjKSQE2lGokAtrCPLRS27NE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qCnGS4HcIboO51xC75TEbpIFn1nlBXN2E76EY2aEcd53r73QMVab95cQHkH0FRi0p5Y92Db4KiNk7BSOBNr4RGfZ/DfyV4TnK/VP3jzSRosG5fWGmW5CgsXpIOK7GwBInfep6+Rv9jzC1SBT0s6E8CvI0IrmNiKT1HQq0bQM5FI= 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=QwrkinLT; 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="QwrkinLT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165198; x=1741701198; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sEYLNbkyuSH14euw2egzBjKSQE2lGokAtrCPLRS27NE=; b=QwrkinLTqfaBXsTVSFuwoCdakv0qqwadm9gmwSHZqcv4bP0lr3lxLABx 5ogzVgB2TiW/7mm5D+dziMZs1wjFGRrgUWXSBaPCoHsYUb5uM5Dslt9N3 jVD4OlucBlDj3pY+4tzjUQfQgy3Ph1q4JfzGae8WP5+GjL53/o4Dwn6Tx k6jCgJp+lfcWddxlRv+LgTxJV3HZLO4xT2ZprYxy6OYsanTKbGxpDfvBx lW214aMkJPTpX3C8WtAGeVygTPIP+HX7l53lrFSgxGBIcSwUGxDgmhY/6 a+rhgvL0fStMdhyqOiNKq/8nSH10u3hVOWpOBLIefR3UCKz1AHnN9Jz5n Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15966201" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15966201" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11614484" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:08 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 02/13] selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only Date: Mon, 11 Mar 2024 15:52:19 +0200 Message-Id: <20240311135230.7007-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Suggested-by: Reinette Chatre Signed-off-by: Ilpo J=C3=A4rvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 72 +++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 36139cba7be8..4df2cd738f88 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -293,28 +293,35 @@ static int initialize_mem_bw_imc(void) } =20 /* - * get_mem_bw_imc: Memory band width as reported by iMC counters + * perf_open_imc_mem_bw - Open perf fds for IMCs * @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. - * - * Return: =3D 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, j, ret; =20 - /* Start all iMC counters to log values (both read and write) */ - reads =3D 0, writes =3D 0, of_mul_read =3D 1, of_mul_write =3D 1; for (imc =3D 0; imc < imcs; imc++) { for (j =3D 0; j < 2; j++) { ret =3D open_perf_event(imc, cpu_no, j); if (ret) return -1; } + } + + return 0; +} + +/* + * do_mem_bw_test - Perform memory bandwidth test + * + * Runs memory bandwidth test over one second period. Also, handles starti= ng + * and stopping of the IMC perf counters around the test. + */ +static void do_imc_mem_bw_test(void) +{ + int imc, j; + + for (imc =3D 0; imc < imcs; imc++) { for (j =3D 0; j < 2; j++) membw_ioctl_perf_event_ioc_reset_enable(imc, j); } @@ -326,6 +333,24 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report,= float *bw_imc) for (j =3D 0; j < 2; j++) membw_ioctl_perf_event_ioc_disable(imc, j); } +} + +/* + * 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: =3D 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, j; + + /* Start all iMC counters to log values (both read and write) */ + reads =3D 0, writes =3D 0, of_mul_read =3D 1, of_mul_write =3D 1; =20 /* * Get results which are stored in struct type imc_counter_config @@ -593,10 +618,9 @@ static void initialize_llc_occu_resctrl(const char *ct= rlgrp, const char *mongrp, } =20 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; float bw_imc; int ret; =20 @@ -607,22 +631,27 @@ static int measure_vals(const struct user_params *upa= rams, * Compare the two values to validate resctrl value. * It takes 1sec to measure the data. */ - ret =3D get_mem_bw_imc(uparams->cpu, param->bw_report, &bw_imc); + ret =3D perf_open_imc_mem_bw(uparams->cpu); if (ret < 0) return ret; =20 + ret =3D get_mem_bw_resctrl(&bw_resc_start); + if (ret < 0) + return ret; + + do_imc_mem_bw_test(); + ret =3D get_mem_bw_resctrl(&bw_resc_end); if (ret < 0) return ret; =20 - bw_resc =3D (bw_resc_end - *bw_resc_start) / MB; - ret =3D print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); - if (ret) + ret =3D get_mem_bw_imc(param->bw_report, &bw_imc); + if (ret < 0) return ret; =20 - *bw_resc_start =3D bw_resc_end; + bw_resc =3D (bw_resc_end - bw_resc_start) / MB; =20 - return 0; + return print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); } =20 /* @@ -696,7 +725,6 @@ int resctrl_val(const struct resctrl_test *test, struct resctrl_val_param *param) { char *resctrl_val =3D param->resctrl_val; - unsigned long bw_resc_start =3D 0; struct sigaction sigact; int ret =3D 0, pipefd[2]; char pipe_message =3D 0; @@ -838,7 +866,7 @@ int resctrl_val(const struct resctrl_test *test, =20 if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret =3D measure_vals(uparams, param, &bw_resc_start); + ret =3D measure_vals(uparams, param); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 142033FB94; Mon, 11 Mar 2024 13:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165202; cv=none; b=N3ULhX51EyWORImNAWTIzSZu/yYGp1osXkYVpEtEN98qFUfshKZSH7y+e4Ic+bDh9lrDzaC9e72o2UiudIonJTBtBIb3jJt3W8tRn1ZC90dVpCah2OcmJY9r9KR/R1umrLGlyTewlzIUaN3XRCl4BQpoNBmr4Oad5XCJo9rq/Rs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165202; c=relaxed/simple; bh=rwUGKWtRQHCPDzae5+w4LWpcgWjkphzsu2B1RTrQA40=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=N2tFd7/LqVFjXfipHNjksTFzac5ag4EcUqMQHigkf8+HjJPI2Kty/y74YiTbqDlLYUlbRqwGwdYgVcrYsNXE6oZ11FuwJmdZ6dw3rlBdUjhCvDMuCpEOGKXtyBgsQ+iTN3C/0esnGR8xm9UGOMuxZoDvI2yyBpMgCXCvLb0fWgo= 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=fjNHPlqv; arc=none smtp.client-ip=198.175.65.20 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="fjNHPlqv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165199; x=1741701199; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rwUGKWtRQHCPDzae5+w4LWpcgWjkphzsu2B1RTrQA40=; b=fjNHPlqvsQfE9LM5OYpjuCxhARAcRDZNO0SmOXpe3mOZdgMxSyRlAayv NXvqbf4ACt98YPky8XrFYN82xhztQiDAPKjkkkZUKmUk50zS9m1B/96+f jI82TMK37yqY/BD7hna7M0N5DFmnAOY7CCOuD1QFuOFbztI7u3n1+JuD1 aDxfdRNwlQ7l2UTbqgMZ7Y8GYgJWcxrl9/SEQTZXQXQ1bvfPav9xZ/WGr C2vtSJBwpukRqoAek4SA5f4B+1P/VT8HQlCErtA08QnSGzdTq90anQOQg jiGao8UPE4HnhZfDREaYGUENRrS6L2FbcaurKDGmLpaSYqWQoCzSXizsn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4705179" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4705179" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11247445" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:15 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 03/13] selftests/resctrl: Consolidate get_domain_id() into resctrl_val() Date: Mon, 11 Mar 2024 15:52:20 +0200 Message-Id: <20240311135230.7007-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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 4df2cd738f88..7981589f4db0 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -431,19 +431,12 @@ void set_mbm_path(const char *ctrlgrp, const char *mo= ngrp, 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 *mon= grp, - 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); =20 @@ -600,19 +593,12 @@ static void set_cmt_path(const char *ctrlgrp, const c= har *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 *m= ongrp, - 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); } @@ -729,10 +715,17 @@ int resctrl_val(const struct resctrl_test *test, int ret =3D 0, pipefd[2]; char pipe_message =3D 0; union sigval value; + int domain_id; =20 if (strcmp(param->filename, "") =3D=3D 0) sprintf(param->filename, "stdio"); =20 + ret =3D 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 =3D validate_bw_report_request(param->bw_report); @@ -827,10 +820,10 @@ int resctrl_val(const struct resctrl_test *test, goto out; =20 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); =20 /* Parent waits for child to be ready. */ close(pipefd[1]); --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 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 4636A4084D; Mon, 11 Mar 2024 13:53:29 +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=1710165210; cv=none; b=bKHE/TKuT20Pi3MQ6il1bUkNrHSGipxnM/XGjqLeu9kC//js+Hjx6WW7pzsYlwFBgFVSqj2l8LdvtaLFZhu8KKx91lU8AD0VIREz1swMdav/SDLSRcYPOA8J3/hmPpr13OaMhcK40MNBfIFHKSFkUval91mVZy+523t64PE/Oyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165210; c=relaxed/simple; bh=uA6OYVRIYufgbW7yxIhXblxuUV5qb8YfEqmODgCiBqE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=CL4waLuFPt4tKl/kO7TL+3TOr5wnyIFBrrAX7ksWypRkMdSR6/PwdaLruoiFVH9W8TNM1tUFvLgqqfDdv8n3KEuHf6G2uIlhvv84YwZdtgcKVkTH7b1KHSHWXGRKl2LQ3AdpwTatCJLuGyHff1xggn+joNedBzjd00TGHF0zpkc= 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=jv+MFvOT; 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="jv+MFvOT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165209; x=1741701209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uA6OYVRIYufgbW7yxIhXblxuUV5qb8YfEqmODgCiBqE=; b=jv+MFvOT0UCw6cbSYUvksAL5PeDQ6d9On/kHGFzycCpUbje2RoQ5XqlR 53iwBD5kgppDy5HCjXRnH+/uuXu0N8dKOzPpzOccAM1fiuxDzMaslnHwC OLDMuxQAMKURCakZIjSOn0l0zDBa+uQA+SsFKIxuDyrhix9ctUPZRrJbF 2mCbO3Mhv4htEvCv9g5FTxxCpFSFz7WBjGCFHRaV2Vp/qT0Ni3k2aXXH5 pMMkQ/elYoAJ8uG8Z5LHlE6Uz++ZwQpCGzzAJQiEYaJHsSE7bNdAJBePW OJ+SsWZ8Sx6EZYrr7OGFZnf4nL6YaOSEHFAT0FCtqheuRk1X99x9oszc8 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15966242" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15966242" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11614597" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:26 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 04/13] selftests/resctrl: Use correct type for pids Date: Mon, 11 Mar 2024 15:52:21 +0200 Message-Id: <20240311135230.7007-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/selfte= sts/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_occu= pancy) * * 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 l= lc_value) { FILE *fp; =20 @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, in= t bm_pid, __u64 llc_value * Return: =3D0 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; =20 @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_rea= d *pe_read, * * Return: =3D0 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 =3D 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 2051bd135e0d..f810a3c5692c 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -177,8 +177,8 @@ void perf_event_initialize_read_format(struct perf_even= t_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); =20 /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 7981589f4db0..07fd57d8d125 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -545,7 +545,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 =3D fabs(bw_imc - bw_resc); --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 A76F43FE20; Mon, 11 Mar 2024 13:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165220; cv=none; b=l832mPrVtubJHHdj2Ii3X799JaEisfj6z6HwaFt0/HCoMA9X8iVla9aUIZXb4657FMpHWwViJpxXA76xHbvJ6WfBPIZ3YWZyczUUhDU5kG6wUm/X0CGwqJQI39WFATCIIFocdF757Q5UwA/dXIFMaGC7QMi+xR1M7tpkjZjc/QY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165220; c=relaxed/simple; bh=GDC8Tjn6yltKW0gL0SkQ6vqVXaf83nlicg0ZTvVVWG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=uzwef1S9yPgncuGmMQvUm695OpxIxutTT/kgRHRDVAtx1KeytGCvPLa9VCBfdT9OuGD03WXAVbJDn8s5gypcbnXX04a8Mo9/AE1ikrB3+ikFPNNyy4aYnZpAl3Q21XowX6lrW0vvjWLQCF0KWH9zbT1rlFlsKiVnx/mkjoYNb9g= 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=bqJ6IbQA; arc=none smtp.client-ip=198.175.65.20 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="bqJ6IbQA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165217; x=1741701217; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GDC8Tjn6yltKW0gL0SkQ6vqVXaf83nlicg0ZTvVVWG4=; b=bqJ6IbQAgYUnbCvjLkMd58MPp6Vk29Sfa8mWLVjlP0lAemCyNa1vSdb/ 4Eh/ERWvNsdOeVnYVG67x5yxGrjr3HkwXRpo9JCXpGilv5PCvQlCszZEd vyZtNpEm3ojGouI5l/C/WTPD++38RzVK6nfZvy1RQvMN5db1Mpm3XT5Hn N3x99K3GdbPzmvDDh6d5dklDcSfL2VyJlMn6/ZBz+ijaC/nWQXNKXEcd7 +i3uBuzicngJsHxYW15xS64FVAYpJtR3Q5d339wzjR3MdIq9zw5qCbf8K J6pbSj4563covU0EbRMG3hN2CN3r+x2IQwIcwcI4DYvSssep3x4SVup7f g==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4705211" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4705211" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11247730" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:33 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 05/13] selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope Date: Mon, 11 Mar 2024 15:52:22 +0200 Message-Id: <20240311135230.7007-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable '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=C3=A4rvinen --- 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/self= tests/resctrl/resctrl.h index f810a3c5692c..90fc00a61d72 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -43,13 +43,6 @@ =20 #define DEFAULT_SPAN (250 * MB) =20 -#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 @@ -125,8 +118,6 @@ struct perf_event_read { */ extern volatile int *value_sink; =20 -extern pid_t bm_pid, ppid; - extern char llc_occup_path[1024]; =20 int get_vendor(void); diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index 07fd57d8d125..04a8577b5e0a 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -481,7 +481,7 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total) return 0; } =20 -pid_t bm_pid, ppid; +static pid_t bm_pid, ppid; =20 void ctrlc_handler(int signum, siginfo_t *info, void *ptr) { @@ -536,6 +536,13 @@ void signal_handler_unregister(void) } } =20 +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 @@ -604,7 +611,7 @@ static void initialize_llc_occu_resctrl(const char *ctr= lgrp, const char *mongrp, } =20 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; float bw_imc; @@ -664,7 +671,7 @@ static void run_benchmark(int signum, siginfo_t *info, = void *ucontext) fp =3D freopen("/dev/null", "w", stdout); if (!fp) { ksft_perror("Unable to direct benchmark status to /dev/null"); - PARENT_EXIT(); + parent_exit(ppid); } =20 if (strcmp(benchmark_cmd[0], "fill_buf") =3D=3D 0) { @@ -678,7 +685,7 @@ static void run_benchmark(int signum, siginfo_t *info, = void *ucontext) once =3D false; } else { ksft_print_msg("Invalid once parameter\n"); - PARENT_EXIT(); + parent_exit(ppid); } =20 if (run_fill_buf(span, memflush, operation, once)) @@ -692,7 +699,7 @@ static void run_benchmark(int signum, siginfo_t *info, = void *ucontext) =20 fclose(stdout); ksft_print_msg("Unable to run specified benchmark\n"); - PARENT_EXIT(); + parent_exit(ppid); } =20 /* @@ -771,7 +778,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); } =20 /* Tell parent that child is ready */ @@ -789,7 +796,7 @@ int resctrl_val(const struct resctrl_test *test, sigsuspend(&sigact.sa_mask); =20 ksft_perror("Child is done"); - PARENT_EXIT(); + parent_exit(ppid); } =20 ksft_print_msg("Benchmark PID: %d\n", bm_pid); @@ -859,7 +866,7 @@ int resctrl_val(const struct resctrl_test *test, =20 if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret =3D measure_vals(uparams, param); + ret =3D measure_vals(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 D2BE240BEF; Mon, 11 Mar 2024 13:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165228; cv=none; b=p9H4LUickU2DeMF8lTIBMmZ9nILdjsxqnBCOUurH2fKFuRw0swiuhWjYW0tEEZTGHfSJ/+d6YCDpeovwYr5+4DGAkxBKkUBLWz8yqjsdcwnziWzVmxa5o4nUhn+77LKiXTTee7172jzreRz+0lrDvtF8wyx+wAZhSyJin49eUh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165228; c=relaxed/simple; bh=JPtSfp+JQQ0trLAFpVwdU+Ykb3MHg/csFrk4EECZeQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=CAe3eyPZ26RYsXC+uZ5hvSz+ZlGTdGg+LviYiaGa+gTrMtfBxiXsHSS06Unn81UbhUDCsEZeVKiz5mTzg6JUt1QEDDnOKUzs5iws3zWnXWciRUedyIoqglwIdFR8lJHV257stDGf5uT25A/S3ls1nstTPSZnBZY8zzx6ZQaMMvw= 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=SQIGstie; arc=none smtp.client-ip=198.175.65.20 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="SQIGstie" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165225; x=1741701225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JPtSfp+JQQ0trLAFpVwdU+Ykb3MHg/csFrk4EECZeQo=; b=SQIGstieQPN2OWU5OirruCBIwSEw92GSgAc2sMZg8vVyMaJ3VtFWwZmn YMbnyEli8md0oexLCgA3He84gnNpBDRzjEfBj14y+1cFUTie0Mv21bbaI utNDNt6RF45LeOqmZgeYW4baTa1/f7SKrLa+b++QI8KqKUapdNj+hplCz 4dTaEgMa5pgNORXE+oQbOoRvcRhnc0dHrZtl6RuRSR7qqbSlPS57E5byD YjI60V8c9VlBRA3WQpQHfaJWM6e56BBGj27bF3JUDk2i6y4X9NMVkWLZI EQaMGhacIYKuadrBKN2Vrw93juKigDv5DW9fit+/v6eW2/FnV77x7aTap A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4705224" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4705224" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11247819" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:42 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 06/13] selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() & document Date: Mon, 11 Mar 2024 15:52:23 +0200 Message-Id: <20240311135230.7007-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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 04a8577b5e0a..80e5174df828 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -610,8 +610,14 @@ static void initialize_llc_occu_resctrl(const char *ct= rlgrp, const char *mongrp, set_cmt_path(ctrlgrp, mongrp, domain_id); } =20 -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; float bw_imc; @@ -866,7 +872,7 @@ int resctrl_val(const struct resctrl_test *test, =20 if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret =3D measure_vals(uparams, param, bm_pid); + ret =3D measure_mem_bw(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 ECB664174A; Mon, 11 Mar 2024 13:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165236; cv=none; b=KKsQWQG1ssWyK9C8rC1m4aNgHpobXsQPdjHSWFVCxJaJrkbuBXxodhDjxwB0KbrlGvnEmGDOPQ5IhiIVF8fBLes5jyhWdxJ/gkfQP6swYjQ55TeBXrclfjP/ssZLvB5nyipcxAX+aP2BXjPt7+EKiIAaKhQIG/oVdtsF20pNV6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165236; c=relaxed/simple; bh=6hINeLfkgFWE94mLII8XIbT1s+jkdRdKz9vHyDRpLCM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=fUrGR68nFGALEf43XUv7py7FMchjJK0UejyHhXV7X5TLXB/2C4Tsx+cPOYez/LPwt+FLrPoDJzSxRPFsKYmSfD584ubiq80VVL/GDBnOVzr3RNNFXllbgKi1FHZmgMW0tO1u9+2uKv2qfxcxNniSbEl2PJ7TogC2zSBcUUdrZcY= 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=VEpQ0zy6; arc=none smtp.client-ip=198.175.65.11 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="VEpQ0zy6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165235; x=1741701235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6hINeLfkgFWE94mLII8XIbT1s+jkdRdKz9vHyDRpLCM=; b=VEpQ0zy6MCYc5bJ/gvY9+Juwg7ecqgRQyaaEpc+l+DTIkM0YFjDge17A iRteWicm4vOrEl3Zq7kf/APVdY6eSZQ2KvOZUpQTHyBYjG/JeoefCmRFz +pvI99ljFOqHZ5HYQx1/NlWIuSDtJzY9pBuUOoU/dfn/LqB/jhz0eZr5Y 9m8AUy/74UBj4fCAHjx6Tzft0KNid0Ofnj6DmmqsSu44fapMKe1xFEmNl ovNxuXXOtjKsPHLKIUAVNH+QbPmDwkAy7WWHrfmCX4MbUCSo7mW7KSBJj emO/BhWqgebm79p7RABO7Kkeb5khG15WfI5Idol8a1NXQHAa760Syiewt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15388847" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15388847" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15814495" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:52 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 07/13] selftests/resctrl: Add ->measure() callback to resctrl_val_param Date: Mon, 11 Mar 2024 15:52:24 +0200 Message-Id: <20240311135230.7007-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/sel= ftests/resctrl/cmt_test.c index a81f91222a89..241c0b129b58 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; } =20 +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 =3D ~(long_mask << n) & long_mask, .num_of_runs =3D 0, .setup =3D cmt_setup, + .measure =3D cmt_measure, }; =20 span =3D cache_portion_size(cache_total_size, param.mask, long_mask); diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index 7946e32e85c8..0939f86514f7 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; } =20 +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 =3D "m1", .filename =3D RESULT_FILE_NAME, .bw_report =3D "reads", - .setup =3D mba_setup + .setup =3D mba_setup, + .measure =3D mba_measure, }; int ret; =20 diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index d67ffa3ec63a..17398cd3aace 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; } =20 +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); +} + void mbm_test_cleanup(void) { remove(RESULT_FILE_NAME); @@ -118,7 +124,8 @@ static int mbm_run_test(const struct resctrl_test *test= , const struct user_param .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, .bw_report =3D "reads", - .setup =3D mbm_setup + .setup =3D mbm_setup, + .measure =3D mbm_measure, }; int ret; =20 diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 90fc00a61d72..2da642e11b61 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -85,6 +85,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; @@ -97,6 +98,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); }; =20 struct perf_event_read { @@ -143,6 +147,8 @@ unsigned char *alloc_buffer(size_t buf_size, int memflu= sh); 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 80e5174df828..13d89d24474e 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -616,8 +616,8 @@ static void initialize_llc_occu_resctrl(const char *ctr= lgrp, 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; float bw_imc; @@ -870,17 +870,9 @@ int resctrl_val(const struct resctrl_test *test, if (ret < 0) break; =20 - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret =3D measure_mem_bw(uparams, param, bm_pid); - if (ret) - break; - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { - sleep(1); - ret =3D measure_llc_resctrl(param->filename, bm_pid); - if (ret) - break; - } + ret =3D param->measure(uparams, param, bm_pid); + if (ret) + break; } =20 out: --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 ABC6D41C7A; Mon, 11 Mar 2024 13:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165244; cv=none; b=PrMoCQwN0jqsCmZpfPgeEHx+JtFJZYcUUXjSIDS5kflymyep2FNQGfCO/nQvw9HrDxHZzK3P+2s6WQH8ECrt6uODsbnZ+L+UHx9MhgGOA8gq/qbuS7McDHJ7JRSLPz9XO3XLVzaVQaMem11B2keYoduHYQYjaKEdLhXE7kef5rU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165244; c=relaxed/simple; bh=nrg3pCi22NX1fMATMvIFbWDFyL8xEeuOhcUfrUuu900=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gba+kOU5n5y/JADjGeyUL4OlmRjF4AH9e1pSZC94PvSj+fCwAwn7qkpbpzcsOvZNp6MHJWZwzIFtE69pybB9Oy83PK0PkpVQZgScdxNFckbsx3np4PBDoqM1rPqZqs7ixMHbqm4KNEqleWlAazkT5h0dWiCo4sviDDBeNLlJmbE= 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=GXloENAi; arc=none smtp.client-ip=198.175.65.11 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="GXloENAi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165243; x=1741701243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nrg3pCi22NX1fMATMvIFbWDFyL8xEeuOhcUfrUuu900=; b=GXloENAiSqHxEwed0MVKCFyd0fp9GMq+R+LEoPfnKvpbGf0zgOl0MPUT MD4s5IfBz0bzTi/uEC3WO1Va/gdc5ci7eAtUNIZEAb5jJx/o7CAmuaN9K LinfpFE2Vu2i9xDXTubtqBzWt8xKV5yVZnu1pxjVQksVAmaq+pXLjKrHv qTqlYY4rLP04OY6wDJD0Xv6XA5s0B8ULB3gpjADcMUlyMzRZZ3rCsDOxK AhFCfCojOtHU3AqFU/3+yuQahv57EnW0CydBjZq0lzcJks5mAnYqKKtEX 3AJZ13sgRgW5VQEaZ2Awi1FE+vMSz1ENrkpJ1Loe/b5g40qHm8Dc8z/Dt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15388863" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15388863" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11166897" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:53:59 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 08/13] selftests/resctrl: Add ->init() callback into resctrl_val_param Date: Mon, 11 Mar 2024 15:52:25 +0200 Message-Id: <20240311135230.7007-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Ilpo J=C3=A4rvinen --- tools/testing/selftests/resctrl/cmt_test.c | 12 ++ tools/testing/selftests/resctrl/mba_test.c | 24 +++- tools/testing/selftests/resctrl/mbm_test.c | 24 +++- tools/testing/selftests/resctrl/resctrl.h | 9 +- tools/testing/selftests/resctrl/resctrl_val.c | 123 ++---------------- 5 files changed, 75 insertions(+), 117 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/sel= ftests/resctrl/cmt_test.c index 241c0b129b58..e79eca9346f3 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 =20 +#define CON_MON_LCC_OCCUP_PATH \ + "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" + +static int set_cmt_path(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 =3D RESULT_FILE_NAME, .mask =3D ~(long_mask << n) & long_mask, .num_of_runs =3D 0, + .init =3D set_cmt_path, .setup =3D cmt_setup, .measure =3D cmt_measure, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index 0939f86514f7..22c1f5e43352 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -8,6 +8,8 @@ * Sai Praneeth Prakhya , * Fenghua Yu */ +#include + #include "resctrl.h" =20 #define RESULT_FILE_NAME "result_mba" @@ -17,6 +19,25 @@ #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 =20 +#define CON_MBM_LOCAL_BYTES_PATH \ + "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" + +static char mbm_total_path[PATH_MAX]; + +static int set_mba_path(const struct resctrl_val_param *param, int domain_= id) +{ + int ret; + + ret =3D initialize_mem_bw_imc(); + if (ret) + return ret; + + sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, + RESCTRL_PATH, param->ctrlgrp, domain_id); + + return 0; +} + /* * Change schemata percentage from 100 to 10%. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -54,7 +75,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, mbm_total_path); } =20 static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) @@ -156,6 +177,7 @@ static int mba_run_test(const struct resctrl_test *test= , const struct user_param .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, .bw_report =3D "reads", + .init =3D set_mba_path, .setup =3D mba_setup, .measure =3D mba_measure, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index 17398cd3aace..ffbfcecf9bd6 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -8,12 +8,19 @@ * Sai Praneeth Prakhya , * Fenghua Yu */ +#include + #include "resctrl.h" =20 #define RESULT_FILE_NAME "result_mbm" #define MAX_DIFF_PERCENT 8 #define NUM_OF_RUNS 5 =20 +#define CON_MON_MBM_LOCAL_BYTES_PATH \ + "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" + +static char mbm_total_path[PATH_MAX]; + static int show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, size_t span) { @@ -86,6 +93,20 @@ static int check_results(size_t span) return ret; } =20 +static int set_mbm_path(const struct resctrl_val_param *param, int domain_= id) +{ + int ret; + + ret =3D initialize_mem_bw_imc(); + if (ret) + return ret; + + sprintf(mbm_total_path, CON_MON_MBM_LOCAL_BYTES_PATH, + RESCTRL_PATH, param->ctrlgrp, param->mongrp, domain_id); + + return 0; +} + static int mbm_setup(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *p) @@ -108,7 +129,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, mbm_total_path); } =20 void mbm_test_cleanup(void) @@ -124,6 +145,7 @@ static int mbm_run_test(const struct resctrl_test *test= , const struct user_param .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, .bw_report =3D "reads", + .init =3D set_mbm_path, .setup =3D mbm_setup, .measure =3D mbm_measure, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 2da642e11b61..d9c6443a8524 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -84,7 +84,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 { @@ -95,6 +96,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); @@ -147,8 +150,10 @@ unsigned char *alloc_buffer(size_t buf_size, int memfl= ush); 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); + struct resctrl_val_param *param, + pid_t bm_pid, const char *mbm_total_path); 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 13d89d24474e..1a96298592ed 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -19,29 +19,6 @@ #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" - -#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" =20 struct membw_read_format { __u64 value; /* The value of the event */ @@ -59,7 +36,6 @@ struct imc_counter_config { int fd; }; =20 -static char mbm_total_path[1024]; static int imcs; static struct imc_counter_config imc_counters_config[MAX_IMCS][2]; =20 @@ -275,7 +251,7 @@ static int num_of_imcs(void) return count; } =20 -static int initialize_mem_bw_imc(void) +int initialize_mem_bw_imc(void) { int imc, j; =20 @@ -411,56 +387,10 @@ static int get_mem_bw_imc(char *bw_report, float *bw_= imc) return 0; } =20 -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 *mon= grp, - int domain_id, char *resctrl_val) -{ - 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); - } -} - /* * 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 m= on 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 */ -static int get_mem_bw_resctrl(unsigned long *mbm_total) +static int get_mem_bw_resctrl(const char *mbm_total_path, unsigned long *m= bm_total) { FILE *fp; =20 @@ -581,43 +511,16 @@ static int print_results_bw(char *filename, pid_t bm_= pid, float bw_imc, return 0; } =20 -static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char soc= k_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 *m= ongrp, - 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 * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark + * @mbm_total_path: Resctrl FS monitoring file to read mem BW from */ 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 *mbm_total_path) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; @@ -634,13 +537,13 @@ int measure_mem_bw(const struct user_params *uparams, if (ret < 0) return ret; =20 - ret =3D get_mem_bw_resctrl(&bw_resc_start); + ret =3D get_mem_bw_resctrl(mbm_total_path, &bw_resc_start); if (ret < 0) return ret; =20 do_imc_mem_bw_test(); =20 - ret =3D get_mem_bw_resctrl(&bw_resc_end); + ret =3D get_mem_bw_resctrl(mbm_total_path, &bw_resc_end); if (ret < 0) return ret; =20 @@ -826,17 +729,11 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; =20 - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret =3D initialize_mem_bw_imc(); + if (param->init) { + ret =3D param->init(param, domain_id); if (ret) goto out; - - initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); + } =20 /* Parent waits for child to be ready. */ close(pipefd[1]); --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 2591041C87; Mon, 11 Mar 2024 13:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165252; cv=none; b=om9R5ZGmv49M+1tLpnGXhMcPvwIOuoTk2hKl1p3F5wclNq+b5FkK2s0dYeObvfHiRU6IJxDjrlWKPZSsLxRn1CwW39YbZ5sTIUuX9rCm9B+t0Xkcs+/9agDFhZi+ita/OD4iZoDg0D1p2Tsq168nzF68V/HXUac5iwbQ3CjEmLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165252; c=relaxed/simple; bh=6TdbMNuNIygJmkdm0Aj4jKqBVcr35/Oplbv/oqfHVIg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=VZCgDVYU93FjDubuxoCpz5dW2lORqnbFkcUmtAfTzhkyJiHFzFaxlKPw8K+6fAWlvdGJ1TLy7zXPZjgPGQOspCN2htC1LvdbxfXCoViWvESGucVahsEWN/170kSS5vo5VFcFP0/zEdPVzrqQkJsguYWrL/40z78iEPFjeEQWOcg= 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=gxx1kI0Q; arc=none smtp.client-ip=198.175.65.11 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="gxx1kI0Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165251; x=1741701251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6TdbMNuNIygJmkdm0Aj4jKqBVcr35/Oplbv/oqfHVIg=; b=gxx1kI0QYTAuHFz7LtdbhA6yDf0r6elDld5ymoFbJyl5nK+hG87iE6gd VSkZfAG4ZQuOkDgwrNHrO9sKI+ialFL/iKbi02pV9fdRjH6shpIKxDKAG 51uIfFIt5B3ZkWfk/5gU8y05dnVIekr/YbgbKoYHsLQUiIyOGHU1ueBsl VshuFGibiFwcKgJVDWHQeCg5+reL68LYMjkg6MtO9E9dyQcczFePOZB4A fXbCoBo7yR1ipqDFeqGw03ZTl90SLpxZ7wXNjnX53C2CdvhhLvzWT+TnA KHVlEIlL4lbXjLiOvNKWh2V63c3bQSsV5g1e6MAOnItKAOZckguOjXIxP w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15388876" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15388876" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11166926" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:08 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 09/13] selftests/resctrl: Simplify bandwidth report type handling Date: Mon, 11 Mar 2024 15:52:26 +0200 Message-Id: <20240311135230.7007-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/sel= ftests/resctrl/mba_test.c index 22c1f5e43352..89ad7f2cdd65 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -75,7 +75,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, mbm_total_path); + return measure_mem_bw(uparams, param, bm_pid, mbm_total_path, "reads"); } =20 static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) @@ -176,7 +176,6 @@ static int mba_run_test(const struct resctrl_test *test= , const struct user_param .ctrlgrp =3D "c1", .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, - .bw_report =3D "reads", .init =3D set_mba_path, .setup =3D mba_setup, .measure =3D mba_measure, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index ffbfcecf9bd6..c8c9aba81db8 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -129,7 +129,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, mbm_total_path); + return measure_mem_bw(uparams, param, bm_pid, mbm_total_path, "reads"); } =20 void mbm_test_cleanup(void) @@ -144,7 +144,6 @@ static int mbm_run_test(const struct resctrl_test *test= , const struct user_param .ctrlgrp =3D "c1", .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, - .bw_report =3D "reads", .init =3D set_mbm_path, .setup =3D mbm_setup, .measure =3D mbm_measure, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index d9c6443a8524..0931c5c09c4f 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -83,7 +83,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) @@ -93,7 +92,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, @@ -133,7 +131,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); @@ -153,7 +151,8 @@ 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, const char *mbm_total_path); + pid_t bm_pid, const char *mbm_total_path, + const char *bw_report); 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 1a96298592ed..2f166a5c0c9b 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -320,7 +320,7 @@ static void do_imc_mem_bw_test(void) * * Return: =3D 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, j; @@ -517,15 +517,21 @@ static int print_results_bw(char *filename, pid_t bm_= pid, float bw_imc, * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark * @mbm_total_path: Resctrl FS monitoring file to read mem BW from + * @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, const char *mbm_total_path) + pid_t bm_pid, const char *mbm_total_path, + const char *bw_report) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; int ret; =20 + bw_report =3D get_bw_report_type(bw_report); + if (!bw_report) + return -1; + /* * Measure memory bandwidth from resctrl and from * another source which is perf imc value or could @@ -547,7 +553,7 @@ int measure_mem_bw(const struct user_params *uparams, if (ret < 0) return ret; =20 - ret =3D get_mem_bw_imc(param->bw_report, &bw_imc); + ret =3D get_mem_bw_imc(bw_report, &bw_imc); if (ret < 0) return ret; =20 @@ -642,13 +648,6 @@ int resctrl_val(const struct resctrl_test *test, return ret; } =20 - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || - !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - ret =3D 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/se= lftests/resctrl/resctrlfs.c index 1cade75176eb..5f113b813253 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; } =20 -int validate_bw_report_request(char *bw_report) +const char *get_bw_report_type(const char *bw_report) { if (strcmp(bw_report, "reads") =3D=3D 0) - return 0; + return bw_report; if (strcmp(bw_report, "writes") =3D=3D 0) - return 0; + return bw_report; if (strcmp(bw_report, "nt-writes") =3D=3D 0) { - strcpy(bw_report, "writes"); - return 0; + return "writes"; } if (strcmp(bw_report, "total") =3D=3D 0) - return 0; + return bw_report; =20 fprintf(stderr, "Requested iMC B/W report type unavailable\n"); =20 - return -1; + return NULL; } =20 int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 919894436C; Mon, 11 Mar 2024 13:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165261; cv=none; b=tPJTgJObL3pBNEOflA+JtND6CFY8nlznzusnUmbAQg6Zoe5l0cGyzILXUBgVj1QE0wbDX5DG0sJMeIZdJMWDPuu1wYg5ZBH01vGxJPyaCuA6Fg1m5g2oNV0dhnP741EsfQDAdeKDZl+zz6xdSDfY+Uhb12rDaPYEzJuL1kmTzxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165261; c=relaxed/simple; bh=RD6s2NfuqJBUw+NQzViVKLI2kjqtbfHgFrQbviPmH1g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=bdhfNOxhz5G5kieDRP596iEKsOTcUbaFQDzzgNIACps56j0V4zL61oEsMtti9cqKLuyA/MxZ7soKh1Pqf2ThlFIs3k99PfAaV5yUjQgZWLHRqiRncmUayOq/0PPSdY85EN4/IpV9xsVxOe3OwBf84Mb9lWI7k4Gob57KD3kAm4o= 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=NYeXj3QF; arc=none smtp.client-ip=198.175.65.11 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="NYeXj3QF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165259; x=1741701259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RD6s2NfuqJBUw+NQzViVKLI2kjqtbfHgFrQbviPmH1g=; b=NYeXj3QFNsANjf45r1TMYTYMHYTcCgwKGAvtjoqnFRrrQoecpfsOxO/X m59B0Gc5Dj5o+JyelrDA7IMcL3xosqAaEg1+CmSnGhaInAMMuH8gGi9IX mW7yjDJyT/8yz0Cn2MqTGS9rn8C/ugLYT4aIHjC6ADA4EdYTkcMUr711z 6q8bjlI34l5xMxSFGMFfMV5IpF/JLwi7q5t0tp4kz3LVCnATujfz2Zave /RaH82s+p7zIMUypyYvQO+hfn1Metixl0r44TM/7M0bFeNsfKyrMYWjFQ gLy/CjxJKT6eRBEf2M5joEKxvMvdqgx6B3kPAWScqHKTzi5Q+wU3vuSO4 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="15388895" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15388895" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="15814568" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:16 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 10/13] selftests/resctrl: Make some strings passed to resctrlfs functions const Date: Mon, 11 Mar 2024 15:52:27 +0200 Message-Id: <20240311135230.7007-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/self= tests/resctrl/resctrl.h index 0931c5c09c4f..52769b075233 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -139,9 +139,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/se= lftests/resctrl/resctrlfs.c index 5f113b813253..79cf1c593106 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] =3D {}; int domain_id, fd, schema_len, ret =3D 0; --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 328D74437C; Mon, 11 Mar 2024 13:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165269; cv=none; b=H5HAhPMtoDjESihO4HfU6OoqB36EGfN7G+NHQ087Y8NefkhaWsLm+/DdQ7TFB+rcqJjZzoIttKXIbXdllkyzjrfBepw8Lb7A3sjFkWouzZ4l+WKjr6Rv77wIhicW2DYrJwFGXQBYObbNWFgmjQZNqC1jsxTOhKONGwFHOwfxZlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165269; c=relaxed/simple; bh=wiEt/mNCP6TC3G2ncRVWx2EtVH6HXJqveGGLYP/G6RU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=FZs5JcPLjt/no4mwNU2ka1fz36a+mYbn4H/7yOys0QCdB8yeB01D8duwfHNv/zwB7tNCpTg9bMR4DiUf62yIPpRYQj0WjZno9qO+bqvbktlXGHwaSAS38GLz3JR01KGapQY5qCvIkGQmUp+qXRESvX6Q7xx8GZkSER/EhqYNjok= 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=lAIrf2q+; arc=none smtp.client-ip=198.175.65.20 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="lAIrf2q+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165267; x=1741701267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wiEt/mNCP6TC3G2ncRVWx2EtVH6HXJqveGGLYP/G6RU=; b=lAIrf2q+TAGg2w6ymjKqbDDFE2SUotwVTeZZrU5IkO/YCOnNgGT2SSx3 Ax8gLsxkQJyZlVg1t6Ukgylwm8dhusxS1Eaf4jYDUeuj93B8bTfwbt+7z AI1OU5XkDLzgYrSjQzaP7BGViYbbV6s12wUAXsCaa3fEqS12CswMROxEd NvzvhkHVjtMKuQ0cQqHuEvmPjFTn0Igzqvo785d+Lg4PO4nrSXQ8C6iLo 4RQSCsmNmOAn+v3XXiX5AuSpDZRkdmeRqlJtRJEMCRzOkOaZE6zAgb4dx SJAc5Q8Req2VMwbfAq/dQS7Cu1q1BzKPMsE8sAu+GdHxgzs9YiN7/J1mh w==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4705347" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4705347" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11243364" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:25 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 11/13] selftests/resctrl: Convert ctrlgrp & mongrp to pointers Date: Mon, 11 Mar 2024 15:52:28 +0200 Message-Id: <20240311135230.7007-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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. Signed-off-by: Ilpo J=C3=A4rvinen --- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrlfs.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 52769b075233..54e5bce4c698 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -89,8 +89,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/se= lftests/resctrl/resctrlfs.c index 79cf1c593106..dbe0cc6d74fa 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -469,7 +469,7 @@ static int create_grp(const char *grp_name, char *grp, = const char *parent_grp) * length of grp_name =3D=3D 0, it means, user wants to use root con_mon * grp, so do nothing */ - if (strlen(grp_name) =3D=3D 0) + if (!grp_name) return 0; =20 /* Check if requested grp exists or not */ @@ -541,7 +541,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *c= trlgrp, char tasks[1024]; int ret =3D 0; =20 - if (strlen(ctrlgrp)) + if (ctrlgrp) sprintf(controlgroup, "%s/%s", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s", RESCTRL_PATH); @@ -558,7 +558,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *c= trlgrp, /* 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 =3D create_grp(mongrp, monitorgroup, monitorgroup_p); @@ -612,7 +612,7 @@ int write_schemata(const char *ctrlgrp, char *schemata,= int cpu_no, goto out; } =20 - if (strlen(ctrlgrp) !=3D 0) + if (ctrlgrp) sprintf(controlgroup, "%s/%s/schemata", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s/schemata", RESCTRL_PATH); --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 7D58C446AE; Mon, 11 Mar 2024 13:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165277; cv=none; b=RkSFjqnECmXFF9h9wIP61E+r0648gO84t2vUGNFpMhQRPDc0p23Ejb3oW+dWr9YP9/V8ZAjzObm4PFRTb0ZY10bQ15TZt1+SbFhiTEQqOhiJ7EfPYeK/TZxQfFmZsLz/vGuUcLHjcdRL4BG61LQyUcH5T90NoiYIQnTiXtC4h34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165277; c=relaxed/simple; bh=mcF/oOZCuYZck6jzS/HrVV81jGUzLr+iH551WCD2YyI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Jhk2G/Edrv0CQgdMQUPhyrxZA1+AEkt57zDFEKjOWMvyM+dKZ6DRdIgMMLT/pki97qaTJiRoOLYVfKGTZVCWt8g7dY+t8izZ4Q+hQOjjmNhH5KCFmw/6FLFvJFfxyuv9xoQCAFHp2XGagajkb+GBAipGiN4Hi734NopFb/35+jA= 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=dZI+rwOH; arc=none smtp.client-ip=198.175.65.20 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="dZI+rwOH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165275; x=1741701275; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mcF/oOZCuYZck6jzS/HrVV81jGUzLr+iH551WCD2YyI=; b=dZI+rwOHERwcSedGECI6H6I0wGP8cGvMMmHme42WtoJCdoSJN7qGNcjc K0TYx9FGpLdaq+O9W6aQou8wyQSHuxtxfGsoPBkxhWrs5A6bXZUB7I3Qv r5Dltzg4IXC7kRcFq93oGX6YLGGmj2LIj/Ef1tRo5my+4SOD8tqDtlIh0 MQGAfHeopU8eD3wQqX6Ke5GGugTdJXv4Z+romcqSfL5irjgUCKFhZ7XR0 1+MedqHNzHYDFjuHoYEsgfv3efEYu66oHlPy14BnZn6BrCmkHFq/tFtk1 4s0Mz2neGBeHm+9W2i17hfSNO950JF/4DzzTVe/SfKLZns/KS8aIxeh6U Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4705367" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4705367" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11243480" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:33 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 12/13] selftests/resctrl: Remove mongrp from MBA test Date: Mon, 11 Mar 2024 15:52:29 +0200 Message-Id: <20240311135230.7007-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/sel= ftests/resctrl/mba_test.c index 89ad7f2cdd65..5bb73e6cabc3 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -174,7 +174,6 @@ static int mba_run_test(const struct resctrl_test *test= , const struct user_param struct resctrl_val_param param =3D { .resctrl_val =3D MBA_STR, .ctrlgrp =3D "c1", - .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, .init =3D set_mba_path, .setup =3D mba_setup, --=20 2.39.2 From nobody Sun Feb 8 12:39:01 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 A40F6446C8; Mon, 11 Mar 2024 13:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165287; cv=none; b=USd83i4XgPBeJNPsxCtvMh8HdFDpx3SXOohjQAES7PfFaRf0raI7p+GKRItb3tcD6QHg3xjsrURNpG9Ry5bVubH7jJwHa+Yg+8QUUEgEIkINPUOtmlHSZkNp+wW88xwz6DFheEqVearqkyjCjRNq2jgrXxCRVqhqJwKnRD1oZSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710165287; c=relaxed/simple; bh=VPYe+KPk8aOURavBcr5qgfEgzrTuYjayKHJkJ4aZNR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c5PBj5oq5t8TI4GZooDtfbR25p2Qup8ITWZyLhhvt7ZYBGI4g8saMTgT9FE2bw/DWmdDwpg8I5lnIj8pR29bzCuTM4QEwHG/MEtQ3FI75EJgvnI/Pl2P6XIEbCD/hZaIzIgfWmYxN07gWqnU/7Y2/+ZkxN6AHoH5ppgy10dShTo= 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=PLfgWJJq; arc=none smtp.client-ip=198.175.65.17 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="PLfgWJJq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710165285; x=1741701285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VPYe+KPk8aOURavBcr5qgfEgzrTuYjayKHJkJ4aZNR0=; b=PLfgWJJqD422tEw3CNl7XMmOxVfL078+Fqmkoyi9C8sk0b3n3aZZvhAv BkGRW0vHG5B1oJ+QSjl1c422tf9AZXCMi3JjeMoWJFjpWSUsDlSwpkukT l5M1bwNWQt7D1jof2qmKqZUHhH+CDYR+e0UAG8GfggwOK+EiHTQoIUxVV SmED4KwBcXnYin+p6FY8L92UwCm/ko3HOZ7whnj1ztdz9ka6zynSqHp1l oNIhuZDJgliyMSJEzfT3E3QqNblR9uaUlF7HmYbTK2Wp0o/GRtwc9m/Qk LATryHKv2cXLooR5s97EHAfnPL5y4Olyj6RMcnyMUoC3bj5ok6jj/iUJd A==; X-IronPort-AV: E=McAfee;i="6600,9927,11009"; a="4963959" X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="4963959" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,116,1708416000"; d="scan'208";a="11065436" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.201]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 06:54:41 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 13/13] selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl() Date: Mon, 11 Mar 2024 15:52:30 +0200 Message-Id: <20240311135230.7007-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> References: <20240311135230.7007-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4rvinen --- 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/sel= ftests/resctrl/cat_test.c index 4cb991be8e31..c0291ecf1d1c 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 =3D 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; =20 /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/ - ret =3D write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret =3D write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto reset_affinity; =20 @@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test= , const struct user_param start_mask =3D create_bit_mask(start, n); =20 struct resctrl_val_param param =3D { - .resctrl_val =3D CAT_STR, .ctrlgrp =3D "c1", .filename =3D RESULT_FILE_NAME, .num_of_runs =3D 0, diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/sel= ftests/resctrl/cmt_test.c index e79eca9346f3..ab96411d1015 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 } =20 struct resctrl_val_param param =3D { - .resctrl_val =3D CMT_STR, .ctrlgrp =3D "c1", .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index 5bb73e6cabc3..c44af1f62f55 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -172,7 +172,6 @@ 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 =3D { - .resctrl_val =3D MBA_STR, .ctrlgrp =3D "c1", .filename =3D RESULT_FILE_NAME, .init =3D set_mba_path, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index c8c9aba81db8..120c356a069e 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -140,7 +140,6 @@ 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 =3D { - .resctrl_val =3D MBM_STR, .ctrlgrp =3D "c1", .mongrp =3D "m1", .filename =3D RESULT_FILE_NAME, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index 54e5bce4c698..4cd7997b39e6 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -79,7 +79,6 @@ struct resctrl_test { =20 /* * 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 @@ -88,7 +87,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]; @@ -111,11 +109,6 @@ struct perf_event_read { } values[2]; }; =20 -#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 @@ -141,8 +134,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 2f166a5c0c9b..f2101ee665ba 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -632,7 +632,6 @@ int resctrl_val(const struct resctrl_test *test, const char * const *benchmark_cmd, struct resctrl_val_param *param) { - char *resctrl_val =3D param->resctrl_val; struct sigaction sigact; int ret =3D 0, pipefd[2]; char pipe_message =3D 0; @@ -723,8 +722,7 @@ int resctrl_val(const struct resctrl_test *test, goto out; =20 /* Write benchmark to specified control&monitoring grp in resctrl FS */ - ret =3D write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret =3D write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto out; =20 diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/se= lftests/resctrl/resctrlfs.c index dbe0cc6d74fa..1bd70ac73ae2 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -524,7 +524,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. @@ -534,8 +533,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]; @@ -555,22 +553,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char = *ctrlgrp, if (ret) goto out; =20 - /* 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 =3D create_grp(mongrp, monitorgroup, monitorgroup_p); - if (ret) - goto out; - - sprintf(tasks, "%s/mon_groups/%s/tasks", - controlgroup, mongrp); - ret =3D 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 =3D create_grp(mongrp, monitorgroup, monitorgroup_p); + if (ret) + goto out; + + sprintf(tasks, "%s/mon_groups/%s/tasks", + controlgroup, mongrp); + ret =3D write_pid_to_tasks(tasks, bm_pid); + if (ret) + goto out; } =20 out: --=20 2.39.2