From patchwork Mon Mar 11 13:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779583 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For MBM/MBA tests, measure_vals() calls get_mem_bw_imc() that performs the measurement over a duration of sleep(1) call. The memory bandwidth numbers from IMC are derived over this duration. The resctrl FS derived memory bandwidth, however, is calculated inside measure_vals() and only takes delta between the previous value and the current one which besides the actual test, also samples inter-test noise. Rework the logic in measure_vals() and get_mem_bw_imc() such that the resctrl FS memory bandwidth section covers much shorter duration closely matching that of the IMC perf counters to improve measurement accuracy. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- 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) } /* - * 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: = 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; - /* Start all iMC counters to log values (both read and write) */ - reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; for (imc = 0; imc < imcs; imc++) { for (j = 0; j < 2; j++) { ret = open_perf_event(imc, cpu_no, j); if (ret) return -1; } + } + + return 0; +} + +/* + * do_mem_bw_test - Perform memory bandwidth test + * + * Runs memory bandwidth test over one second period. Also, handles starting + * and stopping of the IMC perf counters around the test. + */ +static void do_imc_mem_bw_test(void) +{ + int imc, j; + + for (imc = 0; imc < imcs; imc++) { for (j = 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 = 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: = 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 = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; /* * Get results which are stored in struct type imc_counter_config @@ -593,10 +618,9 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, } static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param, - unsigned long *bw_resc_start) + struct resctrl_val_param *param) { - unsigned long bw_resc, bw_resc_end; + unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; int ret; @@ -607,22 +631,27 @@ static int measure_vals(const struct user_params *uparams, * Compare the two values to validate resctrl value. * It takes 1sec to measure the data. */ - ret = get_mem_bw_imc(uparams->cpu, param->bw_report, &bw_imc); + ret = perf_open_imc_mem_bw(uparams->cpu); if (ret < 0) return ret; + ret = get_mem_bw_resctrl(&bw_resc_start); + if (ret < 0) + return ret; + + do_imc_mem_bw_test(); + ret = get_mem_bw_resctrl(&bw_resc_end); if (ret < 0) return ret; - bw_resc = (bw_resc_end - *bw_resc_start) / MB; - ret = print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); - if (ret) + ret = get_mem_bw_imc(param->bw_report, &bw_imc); + if (ret < 0) return ret; - *bw_resc_start = bw_resc_end; + bw_resc = (bw_resc_end - bw_resc_start) / MB; - return 0; + return print_results_bw(param->filename, bm_pid, bw_imc, bw_resc); } /* @@ -696,7 +725,6 @@ int resctrl_val(const struct resctrl_test *test, struct resctrl_val_param *param) { char *resctrl_val = param->resctrl_val; - unsigned long bw_resc_start = 0; struct sigaction sigact; int ret = 0, pipefd[2]; char pipe_message = 0; @@ -838,7 +866,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param, &bw_resc_start); + ret = measure_vals(uparams, param); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon Mar 11 13:52:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779582 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A few functions receive PIDs through int arguments. PIDs variables should be of type pid_t, not int. Convert pid arguments from int to pid_t. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 6 +++--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 1b339d6bbff1..9b74fce80037 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -101,7 +101,7 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy) * * Return: 0 on success, < 0 on error. */ -static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value) +static int print_results_cache(const char *filename, pid_t bm_pid, __u64 llc_value) { FILE *fp; @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value * Return: =0 on success. <0 on failure. */ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid) + const char *filename, pid_t bm_pid) { int ret; @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, * * Return: =0 on success. <0 on failure. */ -int measure_llc_resctrl(const char *filename, int bm_pid) +int measure_llc_resctrl(const char *filename, pid_t bm_pid) { unsigned long llc_occu_resc = 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 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_event_read *pe_read); int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no); int perf_event_reset_enable(int pe_fd); int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid); -int measure_llc_resctrl(const char *filename, int bm_pid); + const char *filename, pid_t bm_pid); +int measure_llc_resctrl(const char *filename, pid_t bm_pid); void show_cache_info(int no_of_bits, __u64 avg_llc_val, size_t cache_span, bool lines); /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 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 = fabs(bw_imc - bw_resc); From patchwork Mon Mar 11 13:52:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779581 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 measure_val() is awfully generic name so rename it to measure_mem_bw() to describe better what it does and document the function parameters. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 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 *ctrlgrp, const char *mongrp, set_cmt_path(ctrlgrp, mongrp, domain_id); } -static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) +/* + * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs + * @uparams: User supplied parameters + * @param: parameters passed to resctrl_val() + * @bm_pid: PID that runs the benchmark + */ +static int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; @@ -866,7 +872,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param, bm_pid); + ret = measure_mem_bw(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon Mar 11 13:52:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779580 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct resctrl_val_param is there to customize behavior inside resctrl_val() which is currently not used to full extent and there are number of strcmp()s for test name in resctrl_val done by resctrl_val(). Create ->init() hook into the struct resctrl_val_param to cleanly do per test initialization. Remove also unused branches to setup paths and the related #defines. Signed-off-by: Ilpo Järvinen --- 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/selftests/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 +#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 = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, + .init = set_cmt_path, .setup = cmt_setup, .measure = cmt_measure, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 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" #define RESULT_FILE_NAME "result_mba" @@ -17,6 +19,25 @@ #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 +#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 = 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); } 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 = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = set_mba_path, .setup = mba_setup, .measure = mba_measure, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 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" #define RESULT_FILE_NAME "result_mbm" #define MAX_DIFF_PERCENT 8 #define NUM_OF_RUNS 5 +#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; } +static int set_mbm_path(const struct resctrl_val_param *param, int domain_id) +{ + int ret; + + ret = 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); } void mbm_test_cleanup(void) @@ -124,6 +145,7 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = set_mbm_path, .setup = mbm_setup, .measure = mbm_measure, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/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 memflush); void mem_flush(unsigned char *buf, size_t buf_size); void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); +int initialize_mem_bw_imc(void); int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid); + 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" struct membw_read_format { __u64 value; /* The value of the event */ @@ -59,7 +36,6 @@ struct imc_counter_config { int fd; }; -static char mbm_total_path[1024]; static int imcs; static struct imc_counter_config imc_counters_config[MAX_IMCS][2]; @@ -275,7 +251,7 @@ static int num_of_imcs(void) return count; } -static int initialize_mem_bw_imc(void) +int initialize_mem_bw_imc(void) { int imc, j; @@ -411,56 +387,10 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) return 0; } -void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id) -{ - if (ctrlgrp && mongrp) - sprintf(mbm_total_path, CON_MON_MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, ctrlgrp, mongrp, domain_id); - else if (!ctrlgrp && mongrp) - sprintf(mbm_total_path, MON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - mongrp, domain_id); - else if (ctrlgrp && !mongrp) - sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - ctrlgrp, domain_id); - else if (!ctrlgrp && !mongrp) - sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - domain_id); -} - -/* - * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @mongrp: Name of the monitor group (mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) - */ -static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, - int domain_id, char *resctrl_val) -{ - 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 mon grp - * 2. If only con_mon grp is given, then read from con_mon grp - * 3. If both are not given, then read from root con_mon grp - * For MBA, - * 1. If con_mon grp is given, then read from it - * 2. If con_mon grp is not given, then read from root con_mon grp */ -static int get_mem_bw_resctrl(unsigned long *mbm_total) +static int get_mem_bw_resctrl(const char *mbm_total_path, unsigned long *mbm_total) { FILE *fp; @@ -581,43 +511,16 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, return 0; } -static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num) -{ - if (strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, mongrp, sock_num); - else if (!strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, MON_LCC_OCCUP_PATH, RESCTRL_PATH, - mongrp, sock_num); - else if (strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, CON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, sock_num); - else if (!strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, LCC_OCCUP_PATH, RESCTRL_PATH, sock_num); -} - -/* - * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @mongrp: Name of the monitor group (mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) - * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) - */ -static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, - int domain_id, char *resctrl_val) -{ - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - set_cmt_path(ctrlgrp, mongrp, domain_id); -} - /* * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs * @uparams: User supplied parameters * @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; - ret = get_mem_bw_resctrl(&bw_resc_start); + ret = get_mem_bw_resctrl(mbm_total_path, &bw_resc_start); if (ret < 0) return ret; do_imc_mem_bw_test(); - ret = get_mem_bw_resctrl(&bw_resc_end); + ret = get_mem_bw_resctrl(mbm_total_path, &bw_resc_end); if (ret < 0) return ret; @@ -826,17 +729,11 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = initialize_mem_bw_imc(); + if (param->init) { + ret = param->init(param, domain_id); if (ret) goto out; - - initialize_mem_bw_resctrl(param->ctrlgrp, 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); + } /* Parent waits for child to be ready. */ close(pipefd[1]); From patchwork Mon Mar 11 13:52:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779579 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Control group, monitor group and resctrl_val are not mutated and should not be mutated within resctrlfs.c functions. Mark this by using const char * for the arguments. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 7 ++++--- tools/testing/selftests/resctrl/resctrlfs.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 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/selftests/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] = {}; int domain_id, fd, schema_len, ret = 0; From patchwork Mon Mar 11 13:52:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 779578 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_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=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-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Nothing during MBA test uses mongrp even if it has been defined ever since the introduction of the MBA test in the commit 01fee6b4d1f9 ("selftests/resctrl: Add MBA test"). Remove the mongrp from MBA test. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mba_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 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 = { .resctrl_val = MBA_STR, .ctrlgrp = "c1", - .mongrp = "m1", .filename = RESULT_FILE_NAME, .init = set_mba_path, .setup = mba_setup,