From patchwork Mon Apr 8 16:32:32 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: 13621361 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 2978F1422B6; Mon, 8 Apr 2024 16:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712593988; cv=none; b=O+Q6Bx5YhZfjk3Upe+khUimlNh8QCZC5Q6cvfbniCj+w3ePmCbY6q7BFLwEgK3N0TNKVkHfMg0/6jfOo/OrUfirdoKNDPstZgPTH8CjxORpper0K75EnH/0hlE9LLBqPZwHbS10TKA1lJp5UL4zeyoYBLVdhTFS8b8lMGmoaU9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712593988; c=relaxed/simple; bh=71cUFvAzehRxSZdklPpJpVnAoyEo60TGfSsg9zhZQ0c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=n+lYfIguYOztJg4OGcVlQCVvtquDUE9sT9Rug+NrVQMmT+PgoyzoATPJ3Qcza5krrnQ/J82QfLSXN/vmUWVdEdZay8oGV6HR1XfbcfyjOW0URhbtEowShodGw/UA0P9YwaLYnPPotwW+ineH71qUIDEY4RnrSkFxrO7i+Qdi++0= 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=Ihd4n6nj; arc=none smtp.client-ip=192.198.163.14 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="Ihd4n6nj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712593987; x=1744129987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=71cUFvAzehRxSZdklPpJpVnAoyEo60TGfSsg9zhZQ0c=; b=Ihd4n6njAd5b/LkmPFbCnBZYRYhgRQ3FviOUJkZgFWikVqULcxiBk/lf VJTfl40NGbmXu+hndCtETGuT7G/NqTT87pIUz67XhnGiW8nViwRW5VVuZ iGZFN784gutOexzvSHwpiUk+YxXXROZkcpwkWWSyNsioWOLnQ3ubpmvwy KCrQBKRoT0nNrhqg6PJ7oO9VOXsIjVHDVGbtoLtJcMFHO6DeUJuxNa/WP 2RNuCmK6ydmJRTZA7duBcioTaPCcb8crO9c5OPjsIj/JiGGxi/Snh8uIj 625HHAloFAJ8YaYF/8m5O9X7k5QgFDsR8fdzGCuAaRxF5n1dEMQas6YQI A==; X-CSE-ConnectionGUID: GJU4Qmb9RkyN1/jsWNgdTQ== X-CSE-MsgGUID: dAMDAWJfQau/7mJjKJ6Krw== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8106708" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="8106708" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:06 -0700 X-CSE-ConnectionGUID: 0IBiYZ/7T1itHHg9OMDnKA== X-CSE-MsgGUID: u0ar28nxTGyMUypeUDdD7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="50935020" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:03 -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 v3 01/16] selftests/resctrl: Open get_mem_bw_imc() fd for loops Date: Mon, 8 Apr 2024 19:32:32 +0300 Message-Id: <20240408163247.3224-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-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 get_mem_bw_imc() handles fds in a for loop but close() is based on two fixed indexes READ and WRITE. Open code all for loops to READ+WRITE entries for clarity. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v3: - Rework entirely, use open coding instead of for loops for clarity --- tools/testing/selftests/resctrl/resctrl_val.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 445f306d4c2f..456cf0d0b8ca 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -306,26 +306,28 @@ static int initialize_mem_bw_imc(void) static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) { float reads, writes, of_mul_read, of_mul_write; - int imc, j, ret; + int imc, ret; /* Start all iMC counters to log values (both read and write) */ reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; for (imc = 0; imc < imcs; imc++) { - for (j = 0; j < 2; j++) { - ret = open_perf_event(imc, cpu_no, j); - if (ret) - return -1; - } - for (j = 0; j < 2; j++) - membw_ioctl_perf_event_ioc_reset_enable(imc, j); + ret = open_perf_event(imc, cpu_no, READ); + if (ret) + return -1; + ret = open_perf_event(imc, cpu_no, WRITE); + if (ret) + return -1; + + membw_ioctl_perf_event_ioc_reset_enable(imc, READ); + membw_ioctl_perf_event_ioc_reset_enable(imc, WRITE); } sleep(1); /* Stop counters after a second to get results (both read and write) */ for (imc = 0; imc < imcs; imc++) { - for (j = 0; j < 2; j++) - membw_ioctl_perf_event_ioc_disable(imc, j); + membw_ioctl_perf_event_ioc_disable(imc, READ); + membw_ioctl_perf_event_ioc_disable(imc, WRITE); } /* From patchwork Mon Apr 8 16:32:33 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: 13621362 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 DE4661428E2; Mon, 8 Apr 2024 16:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712593997; cv=none; b=LFqmCHGaTvwaDNlkmI8NCzvPXIdyUBkSXuXUOwoueUIvAmoi2hAVt6l2D+0NvW00x1ZFkNbgDInDQGH6g25sEB4dryWSWwJMk4fJco9RDJkGIjj//Ml0eu5pjwHHxgCbdS7u006Zo2WrDKl+65kqMGBejf1osyZEQoPHdYXCRl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712593997; c=relaxed/simple; bh=MR/3kQosYswddmPsSqRKHNFA2bPIav4MO/96clktDoI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SZtqjogBGBtmY7KvIplNjDq5pUJUgsJ8ak3udwM9Arjny+Y8wno4GweNL3LrVPKqXxQCQiA6asCHLcLOxdhfULosh1nrdKsiGOF9yXO8W8lDnRhbNrHgbUm6Y8vif8lpbEFZTrV5WLZqH2zmQtnIqA2CYJ+DQFC/zojMwMRlvuI= 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=KDBzlhYE; arc=none smtp.client-ip=192.198.163.14 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="KDBzlhYE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712593995; x=1744129995; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MR/3kQosYswddmPsSqRKHNFA2bPIav4MO/96clktDoI=; b=KDBzlhYEdzgRHIyDWj+WOeZeILThItbnezG0tjBE4tMAIxuBZKUCUc4H r3bghwTR8FcI0+xguc4+r2uk5l0giXzFGcMKWsYyjAeTsvK9fK/jSYj9s Bi8g/Ox5L7KWNrCJ0wWEmYFaWyskwe1c5JX+KXGHq9hfJo5gSERQdAQg/ Nufxteljo9ZadSPHoiic66jfIR5EJ8jjosZPS5BIBteeiFnR0N0nTibl5 R/TWEA6nKOq4IFFEV/6aC3h6QsyGK3UUs0hnen3nrbP3+WZNhBqYhLbQm U69Ih0eCI7/zLjYVi+U3MfcJmbbQEP21ebGKTHIE2qbfYN67JOJuiOub3 w==; X-CSE-ConnectionGUID: yROIcwhbQ4yIIkLXp0F6aA== X-CSE-MsgGUID: mNQa3MasS9uBljCrpdvhpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8106732" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="8106732" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:15 -0700 X-CSE-ConnectionGUID: j3YKSgO7RKGqHLT6pFiKog== X-CSE-MsgGUID: 4gM1l4wTRp+VWiFQptweOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="50935071" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:12 -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 v3 02/16] selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only Date: Mon, 8 Apr 2024 19:32:33 +0300 Message-Id: <20240408163247.3224-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-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 --- v3: - Don't drop Return: entry from perf_open_imc_mem_bw() func comment --- tools/testing/selftests/resctrl/resctrl_val.c | 71 +++++++++++++------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 456cf0d0b8ca..ca4da7f4cf25 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -294,22 +294,15 @@ static int initialize_mem_bw_imc(void) } /* - * get_mem_bw_imc: Memory band width as reported by iMC counters - * @cpu_no: CPU number that the benchmark PID is binded to - * @bw_report: Bandwidth report type (reads, writes) - * - * Memory B/W utilized by a process on a socket can be calculated using - * iMC counters. Perf events are used to read these counters. + * perf_open_imc_mem_bw - Open perf fds for IMCs + * @cpu_no: CPU number that the benchmark PID is binded to * * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) +static int perf_open_imc_mem_bw(int cpu_no) { - float reads, writes, of_mul_read, of_mul_write; int imc, ret; - /* Start all iMC counters to log values (both read and write) */ - reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; for (imc = 0; imc < imcs; imc++) { ret = open_perf_event(imc, cpu_no, READ); if (ret) @@ -317,7 +310,22 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) ret = open_perf_event(imc, cpu_no, WRITE); if (ret) 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; + + for (imc = 0; imc < imcs; imc++) { membw_ioctl_perf_event_ioc_reset_enable(imc, READ); membw_ioctl_perf_event_ioc_reset_enable(imc, WRITE); } @@ -329,6 +337,24 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) membw_ioctl_perf_event_ioc_disable(imc, READ); membw_ioctl_perf_event_ioc_disable(imc, WRITE); } +} + +/* + * get_mem_bw_imc - Memory band width as reported by iMC counters + * @bw_report: Bandwidth report type (reads, writes) + * + * Memory B/W utilized by a process on a socket can be calculated using + * iMC counters. Perf events are used to read these counters. + * + * Return: = 0 on success. < 0 on failure. + */ +static int get_mem_bw_imc(char *bw_report, float *bw_imc) +{ + float reads, writes, of_mul_read, of_mul_write; + int imc; + + /* Start all iMC counters to log values (both read and write) */ + reads = 0, writes = 0, of_mul_read = 1, of_mul_write = 1; /* * Get results which are stored in struct type imc_counter_config @@ -600,10 +626,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; @@ -614,22 +639,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); } /* @@ -703,7 +733,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; @@ -845,7 +874,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 Apr 8 16:32:34 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: 13621363 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 9CFA1142659; Mon, 8 Apr 2024 16:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594007; cv=none; b=eMr0iRoWBMASpvp/3xbmh2OlA/gu26OkUdUJeblSGzeTJNaUu4OzDaHYpxh13WbgCZ9Sw/I4SH/AjPNK88XBfKl49CfCkGlercMAX4bIiKS4V+Tf10q9qy8a66fEsFXNOkv2a81jaPOkblPlt8G/v2zL/HfgQ4/lxj7+tdxT8x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594007; c=relaxed/simple; bh=L8Z1o9K9nI1MPYErA9ajVwGVoAB0a3M5Z1Be5+Oc34M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jTL2OzAeen1szmku+TA4lIRr9VIJ3WmkyEXByj4XV35T4KJ/byCVchqolyIbhrHIxFqi8fAhX1mcgImwsVBP+QVkhoz5jCkqw4JJ+XABsB6pSiGoq6oFXHsLosbOLoDVTHyJXT0aUeLpbv9MrUkRTQttwtTFoNWew4pYog03yCY= 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=hrFAxQ2B; arc=none smtp.client-ip=192.198.163.14 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="hrFAxQ2B" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594005; x=1744130005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L8Z1o9K9nI1MPYErA9ajVwGVoAB0a3M5Z1Be5+Oc34M=; b=hrFAxQ2BMgN4hbM8XsiiakPb0+i35XSd75A6xHPzCTP3Vk7yw7fyoxx0 V1qN8bi5e7sCihndFZUux13tAXBFqi1X31JuYspepO2udHnxSedOzhNNn Oth0ctLF/HIK7DF1Fphg+UTrH/wcuOpPzkVylbbUBanKVGdLbLAA9V5Dx 9kcgqi49H4nKDL/BuMMgzTdyrG7fEGEQxAzgTP+9B/b5+7g07UjwaccJe wmRul7V34A4j+QAqrFnwkegb+ayRmu6upXsZNkc0vRTztP11qEo2Lxoys P58oB37jbTvTnXMlrx0jm2Mye+FitMeOWUftcmEPl5aX72f2Yt16GnZaf g==; X-CSE-ConnectionGUID: jHwQs98USsm9Hq4qakijAQ== X-CSE-MsgGUID: uXKyFN1JT9aj4HKnrMWDPQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8106764" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="8106764" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:24 -0700 X-CSE-ConnectionGUID: BG7XzqkzTR68vDM9fyhJ1g== X-CSE-MsgGUID: y1LeY0BKS8qAG8a6ofM3Nw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="50935138" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:21 -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 v3 03/16] selftests/resctrl: Fix closing IMC fds on error Date: Mon, 8 Apr 2024 19:32:34 +0300 Message-Id: <20240408163247.3224-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-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 If perf_open_imc_mem_bw() fails to open for a perf fd after the first one, the already opened fds remain open and error is directly returned. Close the fds inside perf_open_imc_mem_bw() if an error occurs. Fixes: 7f4d257e3a2a ("selftests/resctrl: Add callback to start a benchmark") Signed-off-by: Ilpo Järvinen --- v3: - New patch --- tools/testing/selftests/resctrl/resctrl_val.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index ca4da7f4cf25..f2b6824cd5f2 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -306,13 +306,23 @@ static int perf_open_imc_mem_bw(int cpu_no) for (imc = 0; imc < imcs; imc++) { ret = open_perf_event(imc, cpu_no, READ); if (ret) - return -1; + goto close_fds; ret = open_perf_event(imc, cpu_no, WRITE); if (ret) - return -1; + goto close_read_fd; } return 0; + +close_read_fd: + close(imc_counters_config[imc][READ].fd); +close_fds: + while (imc--) { + close(imc_counters_config[imc][READ].fd); + close(imc_counters_config[imc][WRITE].fd); + } + + return -1; } /* From patchwork Mon Apr 8 16:32:35 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: 13621364 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 7111E14291D; Mon, 8 Apr 2024 16:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594014; cv=none; b=MeFOepN8se4HsMcpCiHTnqYucHGz0wHWiI5CIXMHQiLKkAOcoLBp5FN9M0asWZfQz0E2vYtomcku0leFUgNSjD7bVw6OLnDSyZu44aud1o/EAp35uf95OVSjo7Y6BrhDfY//2brkUCDnJqKjBv8w7RbzbV5+3Wx+4mVi0c8XLWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594014; c=relaxed/simple; bh=xTfFrwH1xgFVTljhCAm/asdXv1HKcLDnfZLy3W8Rb5M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=YD1OXpFxbaDq/vB/e+ZuqT9J5dLmtor4PmR2b4kjJg46u3O+X/sSF8mNJfB2IzDlBKwkQ21mJP5/AiL86u4RxpE4KvxrZ/IEe7FGYwHyuT7tI1hhZNoUWN/yBt2HflM5RHuwrJ8fBMKZDWCSkh+CW/ayapI8A4Rk57m5E3jEP7Y= 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=kx4puvFb; arc=none smtp.client-ip=198.175.65.12 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="kx4puvFb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594014; x=1744130014; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xTfFrwH1xgFVTljhCAm/asdXv1HKcLDnfZLy3W8Rb5M=; b=kx4puvFb0xEHngXa1gTvZrewb640U2LHvs6BV9v/6Rc7xi/1CU34SbBu pQ9SOfX9kFudrjQ96A1MzdRdLqylyttaMmzuE2wnovk+PuNnQpMUwabQP TuecYOdH4TOp7zZKzq5JqR1w3TUVX9ulv2hA5Q+snBOmGlUVA/8KEN0J9 pFOvKTLMgOuILOdtYz0tsNw+IKzmoO6f8R1tnySzsMTA8xW7RZ3tnyCG8 j2qgCNYQx62YMkxhxPDHi4oTg8g6mKMJqwQ521msjZtgMqTY+pk0tGvAq p1IfpuSXF3cos1pIcyufxrzhlgN7k7VYrr/Yk0OHNek4WRJumxheAPAZf A==; X-CSE-ConnectionGUID: h8klxeZoSJmwAmW2Auyf+Q== X-CSE-MsgGUID: ARDREjtrSrWAoaXWr+qsQA== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="19315282" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19315282" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:33 -0700 X-CSE-ConnectionGUID: o1nDEQd8RZmbOnQx5kA8ew== X-CSE-MsgGUID: u0LjE35YS9G/3+oFgFzuqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="43113529" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:29 -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 v3 04/16] selftests/resctrl: Make "bandwidth" consistent in comments & prints Date: Mon, 8 Apr 2024 19:32:35 +0300 Message-Id: <20240408163247.3224-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Resctrl selftests refer to "bandwidth" currently in two other forms in the code ("B/W" and "band width"). Use "bandwidth" consistently everywhere. While at it, fix also one "over flow" -> "overflow" on a line that is touched by the change. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v3: - New patch --- tools/testing/selftests/resctrl/resctrl_val.c | 14 +++++++------- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index f2b6824cd5f2..e28a1ebef730 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -350,11 +350,11 @@ static void do_imc_mem_bw_test(void) } /* - * get_mem_bw_imc - Memory band width as reported by iMC counters + * get_mem_bw_imc - Memory bandwidth as reported by iMC counters * @bw_report: Bandwidth report type (reads, writes) * - * Memory B/W utilized by a process on a socket can be calculated using - * iMC counters. Perf events are used to read these counters. + * Memory bandwidth utilized by a process on a socket can be calculated + * using iMC counters. Perf events are used to read these counters. * * Return: = 0 on success. < 0 on failure. */ @@ -368,7 +368,7 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) /* * Get results which are stored in struct type imc_counter_config - * Take over flow into consideration before calculating total b/w + * Take overflow into consideration before calculating total bandwidth. */ for (imc = 0; imc < imcs; imc++) { struct imc_counter_config *r = @@ -378,14 +378,14 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) if (read(r->fd, &r->return_value, sizeof(struct membw_read_format)) == -1) { - ksft_perror("Couldn't get read b/w through iMC"); + ksft_perror("Couldn't get read bandwidth through iMC"); return -1; } if (read(w->fd, &w->return_value, sizeof(struct membw_read_format)) == -1) { - ksft_perror("Couldn't get write bw through iMC"); + ksft_perror("Couldn't get write bandwidth through iMC"); return -1; } @@ -488,7 +488,7 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total) fp = fopen(mbm_total_path, "r"); if (!fp) { - ksft_perror("Failed to open total bw file"); + ksft_perror("Failed to open total memory bandwidth file"); return -1; } diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 1cade75176eb..9b86f826a40c 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -850,7 +850,7 @@ int validate_bw_report_request(char *bw_report) if (strcmp(bw_report, "total") == 0) return 0; - fprintf(stderr, "Requested iMC B/W report type unavailable\n"); + fprintf(stderr, "Requested iMC bandwidth report type unavailable\n"); return -1; } From patchwork Mon Apr 8 16:32:36 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: 13621365 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C97142651; Mon, 8 Apr 2024 16:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594023; cv=none; b=DeiKfswYtscwHsWQHhwfQRfxyDwy/rE0Y72hsIB4f9/lgOZzEwzDomHAvpa4kAeT5iP9uVL3IRfZXXB3V/4XnL8DsjpK1R92sVSwmHgEzbW6Ce/UHR/juxXykWh3aYM5NL5aMTfQLTyZHTmD4/Uhrj5rfXRMxzb5+MSjLErQ+A0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594023; c=relaxed/simple; bh=XRhgrSVE+Ccbo/1mafBVP6+lTEkURptm3cPIo+6wO0E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=NskfQlsOeGqM6VeKV7KNZ0f48EkzBkFCIQ/pRa0hYgYvm0WdN2nROqn2rBb6z2xTpg4cQrUkzvzQSAibP9jQ199gXRquNbVgC+7g9ZgzuveGGcpP0FyD3hNw3n5YfxJS5ZTB76VN7l8Crvl6JpVwbyB1P5p8xvae3nuM5qlQhd4= 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=V5uolRQy; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V5uolRQy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594022; x=1744130022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XRhgrSVE+Ccbo/1mafBVP6+lTEkURptm3cPIo+6wO0E=; b=V5uolRQyjjJqXtMVGskg+tDuJRxJu8VPtk1A8vMLC2ijRmJ10PKoIVt7 ImxPFx5ThXMsM+6I0qo/aB1DudmTvznmuht5J+gSCxlgHqVtq5pFom/sq kQ/Nh4MFnH+Sxqjs6uQQLtpWkDEEtkCRi0WK9H/d9j9A5Zg4fFq/d0rfH fH8N1hWtlsQuPyq7TtP5CwWEXXrr3JEuy0I75sUQ+IoMqe7JvYNt/KjD1 WaK1wlLuMEkhdiLccsrmi6onPjlr+DhvqjZnofJ5VH+dCGZd7NXSI87kE rJMu/OD5Kh9ccB6IHnMfDEhdsmxzPc9Jm9r5jdBPwAsMgVWtSFWG0eP4e A==; X-CSE-ConnectionGUID: 9h6ac7WwRheVS5Y7i7WvSQ== X-CSE-MsgGUID: C0oKpTFxQ8GA8QQEB7t++w== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8460985" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="8460985" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:41 -0700 X-CSE-ConnectionGUID: n8T0kgPORWKzqvDVKLYLFQ== X-CSE-MsgGUID: VwUXSNZHSN28610qxa4o6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19812967" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:38 -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 v3 05/16] selftests/resctrl: Consolidate get_domain_id() into resctrl_val() Date: Mon, 8 Apr 2024 19:32:36 +0300 Message-Id: <20240408163247.3224-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl() that are called from resctrl_val() need to determine domain ID to construct resctrl fs related paths. Both functions do it by taking CPU ID which neither needs for any other purpose than determining the domain ID. Consolidate determining the domain ID into resctrl_val() and pass the domain ID instead of CPU ID to initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl(). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index e28a1ebef730..9753914b2250 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -446,19 +446,12 @@ void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id) * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @cpu_no: CPU number that the benchmark PID is binded to + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) */ static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, - int cpu_no, char *resctrl_val) + int domain_id, char *resctrl_val) { - int domain_id; - - if (get_domain_id("MB", cpu_no, &domain_id) < 0) { - ksft_print_msg("Could not get domain ID\n"); - return; - } - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) set_mbm_path(ctrlgrp, mongrp, domain_id); @@ -618,19 +611,12 @@ static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num) * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @cpu_no: CPU number that the benchmark PID is binded to + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) */ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, - int cpu_no, char *resctrl_val) + int domain_id, char *resctrl_val) { - int domain_id; - - if (get_domain_id("L3", cpu_no, &domain_id) < 0) { - ksft_print_msg("Could not get domain ID\n"); - return; - } - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) set_cmt_path(ctrlgrp, mongrp, domain_id); } @@ -747,10 +733,17 @@ int resctrl_val(const struct resctrl_test *test, int ret = 0, pipefd[2]; char pipe_message = 0; union sigval value; + int domain_id; if (strcmp(param->filename, "") == 0) sprintf(param->filename, "stdio"); + ret = get_domain_id(test->resource, uparams->cpu, &domain_id); + if (ret < 0) { + ksft_print_msg("Could not get domain ID\n"); + return ret; + } + if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { ret = validate_bw_report_request(param->bw_report); @@ -845,10 +838,10 @@ int resctrl_val(const struct resctrl_test *test, goto out; initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val); } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val); /* Parent waits for child to be ready. */ close(pipefd[1]); From patchwork Mon Apr 8 16:32:37 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: 13621368 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 54DB4142E61; Mon, 8 Apr 2024 16:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594069; cv=none; b=E5Ef4NAhft5YNTbTdvs10EgwKedFZxmTqbOx2921GC+jOL417HxSFjLzl/M+9+jSdxgAuS7M39lsD1quqq17Y1cojCQVGF+BhmJZbcg57+vv+qhMUgSP5WsP+IcimHVqmLb7IpuQyx+2yyk6UDJP6Fs6GcoVNhFMJTTJGraO4kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594069; c=relaxed/simple; bh=QpW5brB/LvcI+rpeDm/UJI1VDqdShQHuflR/NQJVaaI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=m+mLKb4J3pbddXhJh/Rhkvd4wtZAHhPrqeBiELkOYwvLbZJjmBK0D3PsN63lk4Kt8Oa0IlhF/MZWr/t8+S8DgofkjOz+BGkv1R6vSQIpizDslQ+Myq/q3xLy7Ql0gk3B4iBdaRGdy4WPkVZgrbuq5u8Y5mNv9C8swBaVbC3pr1Q= 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=ixvJhA/A; arc=none smtp.client-ip=198.175.65.12 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="ixvJhA/A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594069; x=1744130069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QpW5brB/LvcI+rpeDm/UJI1VDqdShQHuflR/NQJVaaI=; b=ixvJhA/AGp+64iNCcp/nDDM9xLU6T/vFrWQi8LlCam325Ii0FwxN/q5V ypmAKbr4Qk2/jSGqASAjj++VMVc8KgcpaCaYMm5AVNUeBx1jZC3dzfGep X3AdPAugFjK/jnZjLmESuWNq7s5QIsHRqG/sdkVD61RTWwwHfTuY+nbl1 Qx+IXtaYBpSW9vYA9B/rilcr65chHmaEKJhpjmmc0hWr2JpUKyoYW5xuQ XG7BfRUQNiM+TaUAoRyPzRXA5rvdi2ZypbG+j/fYeqal2KSUbUx/L+++g +vgVkR717YR/wQZFkAVFkD6ZSAClG3mtmJLK4Oy1GrzInLjOwmGcqVhGZ Q==; X-CSE-ConnectionGUID: 6W+HkiYKQDuC/2yYodzykw== X-CSE-MsgGUID: 5706C/blS1SPpBKupXOBKQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="19315347" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19315347" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:50 -0700 X-CSE-ConnectionGUID: SYvaqgBmTZu5+3bWi/zjmg== X-CSE-MsgGUID: 7xcyE4X4T+e0vxaQO7tv3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="43113574" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:46 -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 v3 06/16] selftests/resctrl: Use correct type for pids Date: Mon, 8 Apr 2024 19:32:37 +0300 Message-Id: <20240408163247.3224-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A few functions receive PIDs through int arguments. PIDs variables should be of type pid_t, not int. Convert pid arguments from int to pid_t. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 6 +++--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 1b339d6bbff1..9b74fce80037 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -101,7 +101,7 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy) * * Return: 0 on success, < 0 on error. */ -static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value) +static int print_results_cache(const char *filename, pid_t bm_pid, __u64 llc_value) { FILE *fp; @@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value * Return: =0 on success. <0 on failure. */ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid) + const char *filename, pid_t bm_pid) { int ret; @@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, * * Return: =0 on success. <0 on failure. */ -int measure_llc_resctrl(const char *filename, int bm_pid) +int measure_llc_resctrl(const char *filename, pid_t bm_pid) { unsigned long llc_occu_resc = 0; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 00d51fa7531c..e6f221236c79 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -174,8 +174,8 @@ void perf_event_initialize_read_format(struct perf_event_read *pe_read); int perf_open(struct perf_event_attr *pea, pid_t pid, int cpu_no); int perf_event_reset_enable(int pe_fd); int perf_event_measure(int pe_fd, struct perf_event_read *pe_read, - const char *filename, int bm_pid); -int measure_llc_resctrl(const char *filename, int bm_pid); + const char *filename, pid_t bm_pid); +int measure_llc_resctrl(const char *filename, pid_t bm_pid); void show_cache_info(int no_of_bits, __u64 avg_llc_val, size_t cache_span, bool lines); /* diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 9753914b2250..5ef97d171cef 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -563,7 +563,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 Apr 8 16:32:38 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: 13621369 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 002AE142E6D; Mon, 8 Apr 2024 16:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594071; cv=none; b=J8dGTOMxqtS9ljSntXXksl+neu5Atmfb56r40T2K1LOfBu3+BO2rvdPpJ/S9JKnkS/M3jN8vZcN/SFpkjbZahcqOcONsDbNO/EJ+augcG2yhqeueZIVhEPFnQy8fs84yrGDBAiH4akZdga02Cc5aXRDZ4nkpZgr7fYcgJXpQyyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594071; c=relaxed/simple; bh=iFMcF4sxF33XR0Lkc9Cq46XcFGCgzur5ZS+neQp1wWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=hU3L0Yc+Ms78spJ91MU2zd341vghuE4pgz4uA8k+0cY1pACxvImxWIuST8J8mhE9mEgvFwrtMg3wkiwYMlTy0S/7MTSQxR7H2mqEjsEhzy3LakLayEkYp/vbqHVDsNq0/rHjavV29rbeCFgsJK++CnpiM7j5SdPuipkrdTzfr/8= 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=P+adrHRL; arc=none smtp.client-ip=198.175.65.12 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="P+adrHRL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594071; x=1744130071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iFMcF4sxF33XR0Lkc9Cq46XcFGCgzur5ZS+neQp1wWE=; b=P+adrHRLZl6H9xRP9qLJHdufvLVPRC3VjxeehokucKLM6EE7fyzVj8P0 iKXAx7TosY06e5Oe3anE/RWnQJ+n4tWJAlBIfunR4FV5nGkFTEqT64uLA kfwS64m/Y/XVquDh2yZVtAc/itQCtVo4thYcXQG2ahOJrRERYOHoPdvC/ flqrJm8Tn7QhE00Bw47PqVupCPmwnlTgGd3X91uAqqciFKXYzJYPOGwm9 Z2EtmrmENG4JdhqS9lEBk9D1wgg/6b4lrHMLUsvac2uNjLGtZvQqJ/t4z kBvGb9v/GbJNHI7Fh0u6b5j6vpGf2eHMKO9GN4zwfciG6EzzrZ1hhpaSS Q==; X-CSE-ConnectionGUID: cBiNJ4h8QoGR87sOU/L18g== X-CSE-MsgGUID: wjjGYG3WRhOJczl2CjsCxQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="19315363" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19315363" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:59 -0700 X-CSE-ConnectionGUID: LT2GzFtkS7qSQ3N55rtxKg== X-CSE-MsgGUID: iY1ZCACeRRaG7V1N+76N+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="43113598" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:33:54 -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 v3 07/16] selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope Date: Mon, 8 Apr 2024 19:32:38 +0300 Message-Id: <20240408163247.3224-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'bm_pid' and 'ppid' are global variables. As they are used by different processes and in signal handler, they cannot be entirely converted into local variables. The scope of those variables can still be reduced into resctrl_val.c only. As PARENT_EXIT() macro is using 'ppid', make it a function in resctrl_val.c and pass ppid to it as an argument because it is easier to understand than using the global variable directly. Pass 'bm_pid' into measure_val() instead of relying on the global variable which helps to make the call signatures of measure_val() and measure_llc_resctrl() more similar to each other. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 9 -------- tools/testing/selftests/resctrl/resctrl_val.c | 23 ++++++++++++------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index e6f221236c79..e4b6dc672ecc 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -43,13 +43,6 @@ #define DEFAULT_SPAN (250 * MB) -#define PARENT_EXIT() \ - do { \ - kill(ppid, SIGKILL); \ - umount_resctrlfs(); \ - exit(EXIT_FAILURE); \ - } while (0) - /* * user_params: User supplied parameters * @cpu: CPU number to which the benchmark will be bound to @@ -127,8 +120,6 @@ struct perf_event_read { */ extern volatile int *value_sink; -extern pid_t bm_pid, ppid; - extern char llc_occup_path[1024]; int get_vendor(void); diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 5ef97d171cef..928c31903af2 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -496,7 +496,7 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total) return 0; } -pid_t bm_pid, ppid; +static pid_t bm_pid, ppid; void ctrlc_handler(int signum, siginfo_t *info, void *ptr) { @@ -554,6 +554,13 @@ void signal_handler_unregister(void) } } +static void parent_exit(pid_t ppid) +{ + kill(ppid, SIGKILL); + umount_resctrlfs(); + exit(EXIT_FAILURE); +} + /* * print_results_bw: the memory bandwidth results are stored in a file * @filename: file that stores the results @@ -622,7 +629,7 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, } static int measure_vals(const struct user_params *uparams, - struct resctrl_val_param *param) + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; @@ -682,7 +689,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) fp = freopen("/dev/null", "w", stdout); if (!fp) { ksft_perror("Unable to direct benchmark status to /dev/null"); - PARENT_EXIT(); + parent_exit(ppid); } if (strcmp(benchmark_cmd[0], "fill_buf") == 0) { @@ -696,7 +703,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) once = false; } else { ksft_print_msg("Invalid once parameter\n"); - PARENT_EXIT(); + parent_exit(ppid); } if (run_fill_buf(span, memflush, operation, once)) @@ -710,7 +717,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) fclose(stdout); ksft_print_msg("Unable to run specified benchmark\n"); - PARENT_EXIT(); + parent_exit(ppid); } /* @@ -789,7 +796,7 @@ int resctrl_val(const struct resctrl_test *test, /* Register for "SIGUSR1" signal from parent */ if (sigaction(SIGUSR1, &sigact, NULL)) { ksft_perror("Can't register child for signal"); - PARENT_EXIT(); + parent_exit(ppid); } /* Tell parent that child is ready */ @@ -807,7 +814,7 @@ int resctrl_val(const struct resctrl_test *test, sigsuspend(&sigact.sa_mask); ksft_perror("Child is done"); - PARENT_EXIT(); + parent_exit(ppid); } ksft_print_msg("Benchmark PID: %d\n", bm_pid); @@ -877,7 +884,7 @@ int resctrl_val(const struct resctrl_test *test, if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_vals(uparams, param); + ret = measure_vals(uparams, param, bm_pid); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { From patchwork Mon Apr 8 16:32:39 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: 13621366 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3042414264D; Mon, 8 Apr 2024 16:34:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594048; cv=none; b=F4T1QhZARIADIbzp8+kyhyVUZ19ttyZ81B9Z4pvoaHA6acAkRtvM5gl0oj3VitDbo2+0c5ZJxGmVfdeubN+2hJPteyBHpXg2nz4I7dhssJw3ghomTxMhFk8Xow83tqehPXOFZilOzyv7lJ70FEotyzOyeMYdiNqlGjQ4lCY+Mrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594048; c=relaxed/simple; bh=e6yPicx1vzBwO5X4sy8D6sFs8x4CvbrZODV7UJSyblM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Cuox2dRta8NzQjkYPUSR9GjHxBOwBkctiVpfXc6jmoYIXMhtQwOGGbxwOBfP2+NSeU4M+C8qA1SwxutnGJuot/WuXSLVkG7jui+DyRh5GrIWC55rOvSbd5wBkHO+LoNASUcrKfs5/PYBhQMGq4iWpwCF4itMRli2nmCAbkl3qEo= 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=kAOKQRY6; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kAOKQRY6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594047; x=1744130047; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e6yPicx1vzBwO5X4sy8D6sFs8x4CvbrZODV7UJSyblM=; b=kAOKQRY60ZkLbapMC69DICodn4vlkqA3/43o4LoN/J9bNK2rhBYc4Uxv 8RmQ5FTxK5n92NTSJI2iQbWHfX4oVeYzJeV+1iHDDpenC4rNFgfNkGd3J gwkYlI+kZ3QQ9sJ/cmpsakwirHeZr3a2ieTXWEsQrz06SLseHmcbq14eJ r2uScpeZnH1Bedt6F/zaEZTgayxVk7GdZdtANLOb/tXANW3HO91OV4RXN mpPdoc07kuO248P7kjY2k3KHbhpPsFzH5XO7wfSB8PUaZUyUv7zQ3+RTn xxUfOQKziX5m02kc6lmFUseRAdsvR4FSBIWuMlPEOpcWDXLsoAHTczEcb A==; X-CSE-ConnectionGUID: CfsTOY9EQf2Q7Oe/RZJ69Q== X-CSE-MsgGUID: iyF9ShedRFuu9xGvawEHvg== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="8461084" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="8461084" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:06 -0700 X-CSE-ConnectionGUID: u9trlsRxSRK02Ty7GgLAPA== X-CSE-MsgGUID: szICwBOkR4Gu3nRLSaCzTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19813003" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:03 -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 v3 08/16] selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() & document Date: Mon, 8 Apr 2024 19:32:39 +0300 Message-Id: <20240408163247.3224-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-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 928c31903af2..e4ad60963b0d 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -628,8 +628,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; @@ -884,7 +890,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 Apr 8 16:32:40 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: 13621367 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 75FED142645; Mon, 8 Apr 2024 16:34:15 +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=1712594057; cv=none; b=ErtlobZCGGvZaY7QEyZZY/PKuunLau5/RfkJeq90EOdFuyHh8jWdka7m5NqzWRxe5+LXFLySAU/CmNjHoAQdLWDD3fESrAfoi/cPoC1AsASQvmLc6H4TXD6fS3cwW84rbINBzKDIAUoGGX3vsVmjRF0MMZ8IpTpWxHxdK1HJG0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594057; c=relaxed/simple; bh=alWzWN2ftIOPpRJfvQ2aIf1EVnWbL1UAxa6aRGpE7OE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=n+r549k2GMRfs73cBp75+lEWJ4pWMKVkX86ZqQ/CAKP1BfZ4XjV24l7F+RjFAGvLnlOqCHbVq9CtVwO1WegItKLVAGWFFCSPjIi1h6WfPTMtk58gRv/997FvM0/rnU0Lcz6G1uuGZYxnnT0btDqOOV79k1XRyWRoWFrqyK2OEY0= 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=gwBkg93u; 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="gwBkg93u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594055; x=1744130055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=alWzWN2ftIOPpRJfvQ2aIf1EVnWbL1UAxa6aRGpE7OE=; b=gwBkg93u3VIUcSoprB4cWH9NkTEB5c0Rznzq/mbZ6pqS3GfQdBA6NkjV fd+Eb+pWi8kglm4eBsR1I61Biogqey+GLC5bamLkB0uvapaW7Qg+g7rqz wWtm6pxqd/7mGDdgfvTkMZeqCLa2wXRn9aBW8j6epT/ilB0Q0o1yzfban JAlhDLcKU7O76Ad4c4zUrB78htEOJE3Gk3BHRWIkCF7H4FtRfcGk/otmN YFiUcdgelbDOBeFEF/n4HTnIXHyDy6bqsUkL4X6bOU3qCoM5MZ1dW8arw PrN+3zbIx5g/7Cgw9fTyvBbiG2m4pEEgZNeyPlqXF/9uT9xA1E1CSSoU6 A==; X-CSE-ConnectionGUID: tBvhCMsXTeaDllJSWpdzIA== X-CSE-MsgGUID: oDljG+ZgTDmQvAsN/ksZ/w== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="18454186" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="18454186" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:14 -0700 X-CSE-ConnectionGUID: VJ0UqzJIRhqayuwRA4w9Gw== X-CSE-MsgGUID: ACwO3W6mT+ilgpNC2Spe8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="20062567" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:11 -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 v3 09/16] selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests Date: Mon, 8 Apr 2024 19:32:40 +0300 Message-Id: <20240408163247.3224-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 initialize_mem_bw_resctrl() and set_mbm_path() contain complicated set of conditions, each yielding different file to be opened to measure memory bandwidth through resctrl FS. In practice, only two of them are used. For MBA test, ctrlgrp is always provided, and for MBM test both ctrlgrp and mongrp are set. The file used differ between MBA/MBM test, however, MBM test unnecessarily create monitor group because resctrl FS already provides monitoring interface underneath any ctrlgrp too, which is what the MBA selftest uses. Consolidate memory bandwidth file used to the one used by the MBA selftest. Remove all unused branches opening other files to simplify the code. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- v3: - New patch --- tools/testing/selftests/resctrl/resctrl_val.c | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index e4ad60963b0d..e8e5c0f7f20b 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -19,18 +19,10 @@ #define MAX_TOKENS 5 #define READ 0 #define WRITE 1 -#define CON_MON_MBM_LOCAL_BYTES_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" #define CON_MBM_LOCAL_BYTES_PATH \ "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define MON_MBM_LOCAL_BYTES_PATH \ - "%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" - -#define MBM_LOCAL_BYTES_PATH \ - "%s/mon_data/mon_L3_%02d/mbm_local_bytes" - #define CON_MON_LCC_OCCUP_PATH \ "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" @@ -426,43 +418,15 @@ 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) +static void initialize_mem_bw_resctrl(const char *ctrlgrp, int domain_id) { - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) - set_mbm_path(ctrlgrp, mongrp, domain_id); - - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - if (ctrlgrp) - sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, ctrlgrp, domain_id); - else - sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH, - RESCTRL_PATH, domain_id); - } + sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, + ctrlgrp, domain_id); } /* @@ -850,8 +814,7 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; - initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); + initialize_mem_bw_resctrl(param->ctrlgrp, domain_id); } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, domain_id, resctrl_val); From patchwork Mon Apr 8 16:32:41 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: 13621370 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 369BE143867; Mon, 8 Apr 2024 16:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594071; cv=none; b=lv8/JhKqVEBl7wG1LSRcAWws3vfXPnTP7299P8SSTHMHP4BXTD9+QjZzEuB8qUm1l1WezZbINy7xF5X6U5It7LsvC2qfXfI45l8bJW3TtBHMYSSvRxHgIGyavxn0VMHELwg7Ae0/raEK0lNa9+WWfOWeYG5N7Qj7/77FTthniIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594071; c=relaxed/simple; bh=sd+UWMBUD1go7uGvWVLMqLFM6s7Hi1DdydnFYfzCGMs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=AFgnVXfn8o4gmdlNU911z14TenZMf2L7/J3z6jaCOBmwhsdMTw/CyPUI1kcjcRQmDuIoo+OdHiMstyQl9141yhaaxJYOuAMgHTTBzUsmPGAEXnr4SQ7H6blqerKlAZUQecDE9w7jv1TggxUT8vLWL8ve3Oi3oGzq6Yz/dRTGiM4= 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=RE02mwzb; arc=none smtp.client-ip=192.198.163.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="RE02mwzb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594070; x=1744130070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sd+UWMBUD1go7uGvWVLMqLFM6s7Hi1DdydnFYfzCGMs=; b=RE02mwzbq8SYXgjYB2woQsVNPSJASMWlJ/MDsjzb2iH6rzIPFKvmd0Um laQRu/ZlMTosQA/BE9aghQN8BPnx2SGYACdKSl41U//v61PJvfm8DjeWO JOdSN/N/o2UeGNLrQQLAvJXLsVM7yysojad7pY9QVl2Gbxw0Zui2a+d9M x+QfZQ4g/IY9d5Xy61dQE/CwsgxMeg/eNKcisPEc9kwjXqYXKp7/qI2V0 pUeR9h7MaESvdvL86cjA6wfMcuhXpdc7b3YyPfZmMESYnaRLZfVyFjdMD uJKE3A2BNGxIbMNw4m3Z/vKUjEvd4afjV29/UCO4Y/1ExMpi2iRCjLbwy Q==; X-CSE-ConnectionGUID: x1sZu1aCQ9aGnG2WRY5OUA== X-CSE-MsgGUID: 0KJZdj9TR7KOCMToPswh5w== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="7750046" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="7750046" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:29 -0700 X-CSE-ConnectionGUID: AA8YnXt7S46HRnOtBCkfdg== X-CSE-MsgGUID: Ynt99UfrQjuGXofDzRROUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="57396648" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:20 -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 v3 10/16] selftests/resctrl: Add ->measure() callback to resctrl_val_param Date: Mon, 8 Apr 2024 19:32:41 +0300 Message-Id: <20240408163247.3224-11-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The measurement done in resctrl_val() varies depending on test type. The decision for how to measure is decided based on the string compare to test name which is quite inflexible. Add ->measure() callback into the struct resctrl_val_param to allow each test to provide necessary code as a function which simplifies what resctrl_val() has to do. Signed-off-by: Ilpo Järvinen --- v2: - spaces -> tabs --- tools/testing/selftests/resctrl/cmt_test.c | 8 ++++++++ tools/testing/selftests/resctrl/mba_test.c | 9 ++++++++- tools/testing/selftests/resctrl/mbm_test.c | 9 ++++++++- tools/testing/selftests/resctrl/resctrl.h | 6 ++++++ tools/testing/selftests/resctrl/resctrl_val.c | 18 +++++------------- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index a44e6fcd37b7..d8521386cd18 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -29,6 +29,13 @@ static int cmt_setup(const struct resctrl_test *test, return 0; } +static int cmt_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + sleep(1); + return measure_llc_resctrl(param->filename, bm_pid); +} + static int show_results_info(unsigned long sum_llc_val, int no_of_bits, unsigned long cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, @@ -133,6 +140,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, .setup = cmt_setup, + .measure = cmt_measure, }; span = cache_portion_size(cache_total_size, param.mask, long_mask); diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 5d6af9e8afed..de6e29faf214 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -51,6 +51,12 @@ static int mba_setup(const struct resctrl_test *test, return 0; } +static int mba_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + return measure_mem_bw(uparams, param, bm_pid); +} + static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) { int allocation, runs; @@ -150,7 +156,8 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mba_setup + .setup = mba_setup, + .measure = mba_measure, }; int ret; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 3059ccc51a5a..b88762c4228a 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -105,6 +105,12 @@ static int mbm_setup(const struct resctrl_test *test, return ret; } +static int mbm_measure(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) +{ + return measure_mem_bw(uparams, param, bm_pid); +} + static void mbm_test_cleanup(void) { remove(RESULT_FILE_NAME); @@ -118,7 +124,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mbm_setup + .setup = mbm_setup, + .measure = mbm_measure, }; int ret; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index e4b6dc672ecc..5dc3def70669 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -87,6 +87,7 @@ struct resctrl_test { * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) * @setup: Call back function to setup test environment + * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { char *resctrl_val; @@ -99,6 +100,9 @@ struct resctrl_val_param { int (*setup)(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *param); + int (*measure)(const struct user_params *uparams, + struct resctrl_val_param *param, + pid_t bm_pid); }; struct perf_event_read { @@ -145,6 +149,8 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush); void mem_flush(unsigned char *buf, size_t buf_size); void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); +int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index e8e5c0f7f20b..990648bcc366 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -598,8 +598,8 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark */ -static int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) +int measure_mem_bw(const struct user_params *uparams, + struct resctrl_val_param *param, pid_t bm_pid) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; @@ -851,17 +851,9 @@ int resctrl_val(const struct resctrl_test *test, if (ret < 0) break; - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = measure_mem_bw(uparams, param, bm_pid); - if (ret) - break; - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { - sleep(1); - ret = measure_llc_resctrl(param->filename, bm_pid); - if (ret) - break; - } + ret = param->measure(uparams, param, bm_pid); + if (ret) + break; } out: From patchwork Mon Apr 8 16:32:42 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: 13621371 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 5CD2D1442FB; Mon, 8 Apr 2024 16:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594076; cv=none; b=NRbYoiZE3h74HPmhFZQQYfqUL/bwyVyCZUPOv+4ZHrecnvouk+6Fa9Y3jjUmh2eLbxXqGhlbgGkKWg5GvBRzaiQKEygaR9qu/q87Xx0evczWHCWUQU82VlDgMBEk1hu7d60r7ukZFopHkaIgeGAK1yhNgu4rXJCj9XeujIevKus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594076; c=relaxed/simple; bh=E6a+edsBc8hVa3inDnP8g5QAu0I2U/ilnEv5j/oNLnU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=SKnIkDl+t+B5EOwCU312aFnzcLsHsEU/zpbF1zjeppBYRi1i9xsI36BpKuNcEVVDqc1nxxpUCqfiytEhrj5mwrRVZ524YokZhQY4ASZ3m2E+ExpGQqelYxIzzyziWpcYm5ofzRCa5kPVeQPe8OL09T6jHjUHtiWcSe78UYq7D1E= 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=ieSVO7XT; arc=none smtp.client-ip=192.198.163.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="ieSVO7XT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594074; x=1744130074; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E6a+edsBc8hVa3inDnP8g5QAu0I2U/ilnEv5j/oNLnU=; b=ieSVO7XTLkUJp+FRT6NT9HFBnYNUNRKtDlJWdVcQeQQLjbMGYQGhk/iT CXagxGssXTQ3XTdVTO6pxnGDDXCMGraUMCDkidLiEW7eRBoZXdaqUYnnj liFO5EL+8k1RxO3oFdM1HYp3i4x0e/4APK/p6plfbbpntQeA2W+ySJuf6 Evsng4eMhxy88iMm0YSY9GG/i8GVuu1zrsvHhWVO7qKJBCXA+hLPP9OmE U+qVLSOS/hxKMnb7XmeNv/EY7RDUElYKYjqPWuLMsrwPlH+oYIvO4F/Vl JliD/P6ImRUNBvX306N+RKOIkwKJe5S4n3faxqBcnRAuR6xUk+6cK3mDa A==; X-CSE-ConnectionGUID: dyF+B+6PTH6mZkkHpfT3mA== X-CSE-MsgGUID: OcO641dkRO2cuUCJ13GH6g== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="7750062" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="7750062" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:34 -0700 X-CSE-ConnectionGUID: QNBkHGw3SbS1jyN+T0UaOw== X-CSE-MsgGUID: 4hdRXfdKRhGJ8MugDuxP4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="57396652" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:31 -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 v3 11/16] selftests/resctrl: Add ->init() callback into resctrl_val_param Date: Mon, 8 Apr 2024 19:32:42 +0300 Message-Id: <20240408163247.3224-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct resctrl_val_param is there to customize behavior inside resctrl_val() which is currently not used to full extent and there are number of strcmp()s for test name in resctrl_val done by resctrl_val(). Create ->init() hook into the struct resctrl_val_param to cleanly do per test initialization. Remove also unused branches to setup paths and the related #defines for CMT test. Signed-off-by: Ilpo Järvinen --- v3: - Rename init functions to _init() - Removed tabs intermixed with code - Leave now common mbm bw filename setup into resctrl_val.c --- tools/testing/selftests/resctrl/cmt_test.c | 12 +++ tools/testing/selftests/resctrl/mba_test.c | 14 ++++ tools/testing/selftests/resctrl/mbm_test.c | 14 ++++ tools/testing/selftests/resctrl/resctrl.h | 8 +- tools/testing/selftests/resctrl/resctrl_val.c | 76 +++---------------- 5 files changed, 59 insertions(+), 65 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index d8521386cd18..238f514ba7e6 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -16,6 +16,17 @@ #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 +#define CON_MON_LCC_OCCUP_PATH \ + "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" + +static int cmt_init(const struct resctrl_val_param *param, int domain_id) +{ + sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, + param->ctrlgrp, param->mongrp, domain_id); + + return 0; +} + static int cmt_setup(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *p) @@ -139,6 +150,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, + .init = cmt_init, .setup = cmt_setup, .measure = cmt_measure, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index de6e29faf214..0a95c42f1616 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -17,6 +17,19 @@ #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 +static int mba_init(const struct resctrl_val_param *param, int domain_id) +{ + int ret; + + ret = initialize_mem_bw_imc(); + if (ret) + return ret; + + initialize_mem_bw_resctrl(param, domain_id); + + return 0; +} + /* * Change schemata percentage from 100 to 10%. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -156,6 +169,7 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = mba_init, .setup = mba_setup, .measure = mba_measure, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index b88762c4228a..90716917e6ef 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -86,6 +86,19 @@ static int check_results(size_t span) return ret; } +static int mbm_init(const struct resctrl_val_param *param, int domain_id) +{ + int ret; + + ret = initialize_mem_bw_imc(); + if (ret) + return ret; + + initialize_mem_bw_resctrl(param, domain_id); + + return 0; +} + static int mbm_setup(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *p) @@ -124,6 +137,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 = mbm_init, .setup = mbm_setup, .measure = mbm_measure, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 5dc3def70669..d3fbb957309d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -86,7 +86,8 @@ struct resctrl_test { * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) - * @setup: Call back function to setup test environment + * @init: Callback function to initialize test environment + * @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { @@ -97,6 +98,8 @@ struct resctrl_val_param { char *bw_report; unsigned long mask; int num_of_runs; + int (*init)(const struct resctrl_val_param *param, + int domain_id); int (*setup)(const struct resctrl_test *test, const struct user_params *uparams, struct resctrl_val_param *param); @@ -149,8 +152,11 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush); void mem_flush(unsigned char *buf, size_t buf_size); void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); +int initialize_mem_bw_imc(void); int measure_mem_bw(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid); +void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, + int domain_id); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 990648bcc366..d289c17f1f03 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -23,18 +23,6 @@ #define CON_MBM_LOCAL_BYTES_PATH \ "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define CON_MON_LCC_OCCUP_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define CON_LCC_OCCUP_PATH \ - "%s/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define MON_LCC_OCCUP_PATH \ - "%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" - -#define LCC_OCCUP_PATH \ - "%s/mon_data/mon_L3_%02d/llc_occupancy" - struct membw_read_format { __u64 value; /* The value of the event */ __u64 time_enabled; /* if PERF_FORMAT_TOTAL_TIME_ENABLED */ @@ -268,7 +256,7 @@ static int num_of_imcs(void) return count; } -static int initialize_mem_bw_imc(void) +int initialize_mem_bw_imc(void) { int imc, j; @@ -420,26 +408,20 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc) /* * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) + * @param: parameters passed to resctrl_val() + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) */ -static void initialize_mem_bw_resctrl(const char *ctrlgrp, int domain_id) +void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, + int domain_id) { sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH, - ctrlgrp, domain_id); + param->ctrlgrp, domain_id); } /* * Get MBM Local bytes as reported by resctrl FS - * For MBM, - * 1. If con_mon grp and mon grp are given, then read from con_mon grp's mon grp - * 2. If only con_mon grp is given, then read from con_mon grp - * 3. If both are not given, then read from root con_mon grp - * For MBA, - * 1. If con_mon grp is given, then read from it - * 2. If con_mon grp is not given, then read from root con_mon grp */ -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; @@ -563,35 +545,6 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, return 0; } -static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num) -{ - if (strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, mongrp, sock_num); - else if (!strlen(ctrlgrp) && strlen(mongrp)) - sprintf(llc_occup_path, MON_LCC_OCCUP_PATH, RESCTRL_PATH, - mongrp, sock_num); - else if (strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, CON_LCC_OCCUP_PATH, RESCTRL_PATH, - ctrlgrp, sock_num); - else if (!strlen(ctrlgrp) && !strlen(mongrp)) - sprintf(llc_occup_path, LCC_OCCUP_PATH, RESCTRL_PATH, sock_num); -} - -/* - * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" - * @ctrlgrp: Name of the control monitor group (con_mon grp) - * @mongrp: Name of the monitor group (mon grp) - * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) - * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) - */ -static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, - int domain_id, char *resctrl_val) -{ - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - set_cmt_path(ctrlgrp, mongrp, domain_id); -} - /* * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs * @uparams: User supplied parameters @@ -616,13 +569,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; @@ -808,16 +761,11 @@ int resctrl_val(const struct resctrl_test *test, if (ret) goto out; - if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || - !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = initialize_mem_bw_imc(); + if (param->init) { + ret = param->init(param, domain_id); if (ret) goto out; - - initialize_mem_bw_resctrl(param->ctrlgrp, domain_id); - } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) - initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); + } /* Parent waits for child to be ready. */ close(pipefd[1]); From patchwork Mon Apr 8 16:32:43 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: 13621372 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 713C014534F; Mon, 8 Apr 2024 16:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594085; cv=none; b=E//zf+M/wKVl4O4GvS8aYmG7FYBwvahgsvhTHYIe8Q//KQaxs6tyreay1W5PZ7NdW7w5Kqz40ew7K1tWkthnTEsMdAG3h9U+W8NUxNiTSqAxOyqvvGOuIDoXIKiYyBBdQzUdRVRLYnLMKP+nJNm7BiuIZl3v1PZ1VGvdVDS8DrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594085; c=relaxed/simple; bh=ou95bQenO6eaVT0zNYeAL1pHVoXX2ezb5k+zzB03VxQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=d/GDQCqAc+xwS9RrjxBRRb/S8+mt+vs8wToWkc851kigCXNbugB2jqT0idvsfDGvtuFEnwcfyXtQTMdfE3DoWUaYn1ttQ0dnxyxRtW1H1DF9NshmdEVPnkfgTzKiDa18zknVezfpH4x1ZEC+QctAQIajfe7NWGVq1GbObWkkylU= 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=WvnLlk9j; arc=none smtp.client-ip=192.198.163.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="WvnLlk9j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594083; x=1744130083; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ou95bQenO6eaVT0zNYeAL1pHVoXX2ezb5k+zzB03VxQ=; b=WvnLlk9jEaI5EDRzPb1x84Jkbwg8rMh8gWHU1siMBRn9YgJjI3Oxopub Ftb1bzXK2BYyH2+Vr159rNZ9+/dpUi9sfqYh6GTAzLQrP6B6pZFll0W2c YSn2mK1YVa8LBN6ihjKck4beDTdv6YY1Ln5VOA/mRfzG9lWnh4Pyi/sGU Ksr9KdHSS4WuPJyXHG9Iof5YIWcabLxFdE/hfKcsuDQAlYE1HGgF2+Ard EWqA2TbM0aPDc1WuHY8sSUMJIvN4LhuvTD7qPB+AkccoS80t0/3aa7eDQ 3eDg5P1IhH/nUfnK2mvPOqUzsTbjxJAmPDaVMSzdlaXGS5Y4IaxSxS0sX A==; X-CSE-ConnectionGUID: xp+jwV+6SjK017f+divwhQ== X-CSE-MsgGUID: DgIimFZcQPStKZFGLHtIog== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="7750077" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="7750077" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:43 -0700 X-CSE-ConnectionGUID: hf3wv+xnQg+vQoMtHJVsaQ== X-CSE-MsgGUID: 9/kPExKzQ3CHElAQJAR6nQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="57396660" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:39 -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 v3 12/16] selftests/resctrl: Simplify bandwidth report type handling Date: Mon, 8 Apr 2024 19:32:43 +0300 Message-Id: <20240408163247.3224-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 bw_report is only needed for selecting the correct value from the values IMC measured. It is a member in the resctrl_val_param struct and is always set to "reads". The value is then checked in resctrl_val() using validate_bw_report_request() that besides validating the input, assumes it can mutate the string which is questionable programming practice. Simplify handling bw_report: - Convert validate_bw_report_request() into get_bw_report_type() that inputs and returns const char *. Use NULL to indicate error. - Validate the report types inside measure_mem_bw(), not in resctrl_val(). - As resctrl_val() no longer needs bw_report for anything, it can just be passed to measure_mem_bw() by the ->measure() hooks. Signed-off-by: Ilpo Järvinen --- v2: - Rebased on top of next to resolve conflict in resctrl.h --- tools/testing/selftests/resctrl/mba_test.c | 3 +-- tools/testing/selftests/resctrl/mbm_test.c | 3 +-- tools/testing/selftests/resctrl/resctrl.h | 7 +++---- tools/testing/selftests/resctrl/resctrl_val.c | 19 +++++++++---------- tools/testing/selftests/resctrl/resctrlfs.c | 13 ++++++------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 0a95c42f1616..9c9a4f22e529 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -67,7 +67,7 @@ static int mba_setup(const struct resctrl_test *test, static int mba_measure(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid) { - return measure_mem_bw(uparams, param, bm_pid); + return measure_mem_bw(uparams, param, bm_pid, "reads"); } static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) @@ -168,7 +168,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mba_init, .setup = mba_setup, .measure = mba_measure, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 90716917e6ef..0a3ab99b31ab 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -121,7 +121,7 @@ static int mbm_setup(const struct resctrl_test *test, static int mbm_measure(const struct user_params *uparams, struct resctrl_val_param *param, pid_t bm_pid) { - return measure_mem_bw(uparams, param, bm_pid); + return measure_mem_bw(uparams, param, bm_pid, "reads"); } static void mbm_test_cleanup(void) @@ -136,7 +136,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mbm_init, .setup = mbm_setup, .measure = mbm_measure, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index d3fbb957309d..4446a0e493ef 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -85,7 +85,6 @@ struct resctrl_test { * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written - * @bw_report: Bandwidth report type (reads vs writes) * @init: Callback function to initialize test environment * @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test) @@ -95,7 +94,6 @@ struct resctrl_val_param { char ctrlgrp[64]; char mongrp[64]; char filename[64]; - char *bw_report; unsigned long mask; int num_of_runs; int (*init)(const struct resctrl_val_param *param, @@ -135,7 +133,7 @@ int filter_dmesg(void); int get_domain_id(const char *resource, int cpu_no, int *domain_id); int mount_resctrlfs(void); int umount_resctrlfs(void); -int validate_bw_report_request(char *bw_report); +const char *get_bw_report_type(const char *bw_report); bool resctrl_resource_exists(const char *resource); bool resctrl_mon_feature_exists(const char *resource, const char *feature); bool resource_info_file_exists(const char *resource, const char *file); @@ -154,7 +152,8 @@ void fill_cache_read(unsigned char *buf, size_t buf_size, bool once); int run_fill_buf(size_t buf_size, int memflush, int op, bool once); int initialize_mem_bw_imc(void); int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid); + struct resctrl_val_param *param, pid_t bm_pid, + const char *bw_report); void initialize_mem_bw_resctrl(const struct resctrl_val_param *param, int domain_id); int resctrl_val(const struct resctrl_test *test, diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index d289c17f1f03..a9e0bb35a4ab 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -338,7 +338,7 @@ static void do_imc_mem_bw_test(void) * * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc(char *bw_report, float *bw_imc) +static int get_mem_bw_imc(const char *bw_report, float *bw_imc) { float reads, writes, of_mul_read, of_mul_write; int imc; @@ -550,14 +550,20 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc, * @uparams: User supplied parameters * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark + * @bw_report: Bandwidth report type (reads, writes) */ int measure_mem_bw(const struct user_params *uparams, - struct resctrl_val_param *param, pid_t bm_pid) + struct resctrl_val_param *param, pid_t bm_pid, + const char *bw_report) { unsigned long bw_resc, bw_resc_start, bw_resc_end; float bw_imc; int ret; + bw_report = 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 @@ -579,7 +585,7 @@ int measure_mem_bw(const struct user_params *uparams, if (ret < 0) return ret; - ret = get_mem_bw_imc(param->bw_report, &bw_imc); + ret = get_mem_bw_imc(bw_report, &bw_imc); if (ret < 0) return ret; @@ -674,13 +680,6 @@ int resctrl_val(const struct resctrl_test *test, return ret; } - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || - !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - ret = validate_bw_report_request(param->bw_report); - if (ret) - return ret; - } - /* * If benchmark wasn't successfully started by child, then child should * kill parent, so save parent's pid diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 9b86f826a40c..aac382eaa032 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -837,22 +837,21 @@ int filter_dmesg(void) return 0; } -int validate_bw_report_request(char *bw_report) +const char *get_bw_report_type(const char *bw_report) { if (strcmp(bw_report, "reads") == 0) - return 0; + return bw_report; if (strcmp(bw_report, "writes") == 0) - return 0; + return bw_report; if (strcmp(bw_report, "nt-writes") == 0) { - strcpy(bw_report, "writes"); - return 0; + return "writes"; } if (strcmp(bw_report, "total") == 0) - return 0; + return bw_report; fprintf(stderr, "Requested iMC bandwidth report type unavailable\n"); - return -1; + return NULL; } int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, From patchwork Mon Apr 8 16:32:44 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: 13621373 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 B2F82145FF1; Mon, 8 Apr 2024 16:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594093; cv=none; b=Y4LsDvs64+k0mZg+hhxymgwsFQMGLyWNYrPoqwnaDsBaQaR9AuWbl1A97qxns46XH88TL2ycakNQKn/Egy7TwHqI2wbv2+1DPbQwJNhhmuLtyNkRcdGtNLWAnl7HMEvGg9+FI/boa5H7ZkZESpMdCEjWUwePTmrjwI9Sc0UiAhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594093; c=relaxed/simple; bh=530we9tbb1br2D5djQ/lnp1n4VHVKq4UhHt+32wQESQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HqGHDZhErXS+8EyCOwMgWs6mEIGPqlCTkIQeJfpaoMoc+zwZqf8cN7+Psdh6XhMIDZr0gOrse6yRVWB5gqeWKr36lfy6Zt5V7em1VIGwKExnOgSa4znfpGyQBRBg/hk7PNurWVP7UMYh5U/E9CXt0VXhpJiMvx46NcN5PJbSx64= 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=XUyyhXYW; arc=none smtp.client-ip=192.198.163.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="XUyyhXYW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594092; x=1744130092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=530we9tbb1br2D5djQ/lnp1n4VHVKq4UhHt+32wQESQ=; b=XUyyhXYWem4JwYea+eWmDo8xGG/CsIcrJI+3ZTfb5KLrrMSKfZRuCxcp Ed8mIFGwnDhbXJkTinRw2TiNbcksC/7eZSRQKaPBJIVczjKW8oDtzGFm9 IIJW0n8BrfjOwpd7ohH6DbpEg4u+2EASPjENNMqUkm8aaPQ0tcnnO3+3H kAIvdwr3/Fipnq2txrJtb0mRcG9nPH3u2dIFmymtNDvy3oxbpNbwQeyHD G/8v9wGEGVIjRftdW1ITu5b4ZA8MyDoHo/drlTHkZNKJUTTv23R4RlA/B DtY65JrRueHwuuDZC+bJgQAbxMcBXJSySrREDAVjw+yXbvRWFoJzz4zyF w==; X-CSE-ConnectionGUID: LEtF753+Sgu8mK1pJUnbpA== X-CSE-MsgGUID: KOVaHBkSTpOWxS2VxSH/HQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="7750091" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="7750091" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:51 -0700 X-CSE-ConnectionGUID: u9ZmcFUxR+CQrfR1YRRegw== X-CSE-MsgGUID: q6bWzXGLS8acwixytYsBWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="57396663" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:34:48 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Babu Moger , =?utf-8?q?Maciej_Wiecz=C3=B3r-Retman?= Cc: Fenghua Yu , linux-kernel@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v3 13/16] selftests/resctrl: Make some strings passed to resctrlfs functions const Date: Mon, 8 Apr 2024 19:32:44 +0300 Message-Id: <20240408163247.3224-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Control group, monitor group and resctrl_val are not mutated and should not be mutated within resctrlfs.c functions. Mark this by using const char * for the arguments. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 7 ++++--- tools/testing/selftests/resctrl/resctrlfs.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 4446a0e493ef..5967389038d4 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -141,9 +141,10 @@ bool test_resource_feature_check(const struct resctrl_test *test); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity); -int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource); -int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, - char *resctrl_val); +int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, + const char *resource); +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, + const char *mongrp, const char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); unsigned char *alloc_buffer(size_t buf_size, int memflush); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index aac382eaa032..a0e84157eb63 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -534,8 +534,8 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, - char *resctrl_val) +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, + const char *mongrp, const char *resctrl_val) { char controlgroup[128], monitorgroup[512], monitorgroup_p[256]; char tasks[1024]; @@ -593,7 +593,8 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, * * Return: 0 on success, < 0 on error. */ -int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource) +int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, + const char *resource) { char controlgroup[1024], reason[128], schema[1024] = {}; int domain_id, fd, schema_len, ret = 0; From patchwork Mon Apr 8 16:32:45 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: 13621374 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 48B61142640; Mon, 8 Apr 2024 16:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594110; cv=none; b=kFcJBRPoQCnhPBhHT99wQtw13tRxHaIWs6T4msPUVGkSgeaCuC3SMmPTfyfAVTu8kIsH34p/KKwyhC3a8PSN2Hvj0ZPAXHQprM4B/WTZg0liLgHEvRZ3UpssPPDg+GtdNWxkzcAA1JB0yQZEo5+GRO4Z4mtx2eaUFnv9eQqujo0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594110; c=relaxed/simple; bh=zcaBoK/ACFrIjjdFXj8eyQESy8iAslUg8GB4EQy4ers=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=q9+mWew3/kqKUcLOZqgJtdbc0U+CK3Wrxe/0N4jL2SLdV+Nkieh4hdEohgwphieoHvgId+6dvemc7bmrf8bBGVKA927tH9dGM61yYIhTcP/G+wsUAsUeYO2An+r7Y/dDSD+NlwZJ+1+EATXo2AHHnebqHdeCPF6Y5O7AGBXnII4= 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=Afmh9qgx; arc=none smtp.client-ip=192.198.163.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="Afmh9qgx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594109; x=1744130109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zcaBoK/ACFrIjjdFXj8eyQESy8iAslUg8GB4EQy4ers=; b=Afmh9qgxHu+jm4FaAErrhGXAFylybNzDnlKIfsEcwXA1yEoeb8rLNl/L OV3cx/mGQdcLi3s7mL2uw8InHFniOUpqiBjnKVrvmxezgYT+L8jFTdLGk ojAOOpg2QkJmLkLjKxwUtD3QTWLWQ5qnACVeCbzMaVyyZYKyocH39n6Wq Y467TPiLOMhlqpR05oiOEGKRNibzzLw7g5xExU81BUXWiB0uG2fnlQbPN sCd6R0RV4tx1yGsVU+1/K2FVVReM/qsmrx1Yt9hn8YmGjv8SUjyw6eISW WuH1zPYnYD1UNkzHw7ie3vDks3XGc3RJk/e2u1iygoeAJA2NYxh63ch2N g==; X-CSE-ConnectionGUID: UH8M2wKYT5iU5+ieTuEFog== X-CSE-MsgGUID: E+dUqzQTQY2wPgPRae5Hrw== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="18492258" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="18492258" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:08 -0700 X-CSE-ConnectionGUID: nVeyn8h8TA6CR78BjNZ55w== X-CSE-MsgGUID: XeFqQqoRT66DOLOjlFQ8SQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="20376584" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:06 -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 v3 14/16] selftests/resctrl: Convert ctrlgrp & mongrp to pointers Date: Mon, 8 Apr 2024 19:32:45 +0300 Message-Id: <20240408163247.3224-15-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The struct resctrl_val_param has control and monitor groups as char arrays but they are not supposed to be mutated within resctrl_val(). Convert the ctrlgrp and mongrp char array within resctrl_val_param to plain const char pointers and adjust the strlen() based checks to check NULL instead. Convert !grp_name check in create_grp() into internal sanity check by returning error if the caller asked to create a group but doesn't provide a name for the group. The existing code already abides this by only calling create_grp() if mongrp is non-NULL so the error should never be returned with the current selftests (ctrlgrp is never NULL). Signed-off-by: Ilpo Järvinen --- v3: - Removed wrong comment - Changed grp_name check to return -1 on fail (internal sanity check) --- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrlfs.c | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 5967389038d4..a999fbc13fd3 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -91,8 +91,8 @@ struct resctrl_test { */ struct resctrl_val_param { char *resctrl_val; - char ctrlgrp[64]; - char mongrp[64]; + const char *ctrlgrp; + const char *mongrp; char filename[64]; unsigned long mask; int num_of_runs; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index a0e84157eb63..6b4448588666 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -464,13 +464,8 @@ static int create_grp(const char *grp_name, char *grp, const char *parent_grp) struct dirent *ep; DIR *dp; - /* - * At this point, we are guaranteed to have resctrl FS mounted and if - * length of grp_name == 0, it means, user wants to use root con_mon - * grp, so do nothing - */ - if (strlen(grp_name) == 0) - return 0; + if (!grp_name) + return -1; /* Check if requested grp exists or not */ dp = opendir(parent_grp); @@ -541,7 +536,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, char tasks[1024]; int ret = 0; - if (strlen(ctrlgrp)) + if (ctrlgrp) sprintf(controlgroup, "%s/%s", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s", RESCTRL_PATH); @@ -558,7 +553,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, /* Create mon grp and write pid into it for "mbm" and "cmt" test */ if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) || !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - if (strlen(mongrp)) { + if (mongrp) { sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); ret = create_grp(mongrp, monitorgroup, monitorgroup_p); @@ -612,7 +607,7 @@ int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, goto out; } - if (strlen(ctrlgrp) != 0) + if (ctrlgrp) sprintf(controlgroup, "%s/%s/schemata", RESCTRL_PATH, ctrlgrp); else sprintf(controlgroup, "%s/schemata", RESCTRL_PATH); From patchwork Mon Apr 8 16:32:46 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: 13621375 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 253E0142651; Mon, 8 Apr 2024 16:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594119; cv=none; b=tJcJYnX2Trl9iIyeHwPyIxeP8RWKprBCdJsikgTRdUVjfB1zfIQG0Qu0Ai2jIUNmFtQ1vjdiQmWlAzSp/qGS6hjDgLk9R5/0UNwhVClg1BUW17TDvhxeGAIYyPOzO/UlS22RJtNnSygE5qhgT6PNcgtMatZwtJNoecW6UV2X2x0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594119; c=relaxed/simple; bh=Iy0JjcLUSebL6oRihQ/kvCDMmxysZknFiWvlqSKnjQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ihPgF7FKqlfRKidjLUTHf7zS/q1YO1KT+7lv0wN5ioufRex4qcOn38gr0IEo6r+sP5rooLpdFZe+ET8HfbnQ31tm6Bw7APmm8mCCFjqV71T3CJGDuHB5oLd1NZi/mDPUSSpFNplBxIMsQCfiRai6HA8pJCdnAwEABVBwf5CUKcs= 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=mn3Kt9d5; arc=none smtp.client-ip=192.198.163.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="mn3Kt9d5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594118; x=1744130118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iy0JjcLUSebL6oRihQ/kvCDMmxysZknFiWvlqSKnjQo=; b=mn3Kt9d5KLeWM03M4pHem8A5kxopO3Z9Pi80gZ2FWQLzhGLshQLKb6YR qc4jsV2/3G1ModW00qqFcrpwqoN4aCahy+KPcvcAisvlCR9U/mGr8lafu 2w+VpOZAr/UR5NA5Z3xvCpopC9MuALVLYSO8C3xTfYSlLKyxUmaBhNkew F9VFmWte87ZPD5w7vKvJcksNpkjuHzJe/7+5FviBJZe+tMHMEu5emfaGI GJtvcncxAXMTrwE6FOaaZrcrbfUqPy4fxNUESebenvxfB8yv8YEemVasb orSngunce+LgguAITGAp0nEd/9XieMP4JJDxfAXOl7mx7D+E21kPQKRfS A==; X-CSE-ConnectionGUID: fAXFECH9TbySQrF+evDj7A== X-CSE-MsgGUID: LacixLC7QAu7IPcHZBXkNQ== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="18492271" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="18492271" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:17 -0700 X-CSE-ConnectionGUID: WL63UZH8SMmsGGf7Omzw+A== X-CSE-MsgGUID: htVhNVgVSp+7wvLH4OV0zg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="20376626" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:15 -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 v3 15/16] selftests/resctrl: Remove mongrp from MBA test Date: Mon, 8 Apr 2024 19:32:46 +0300 Message-Id: <20240408163247.3224-16-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Nothing during MBA test uses mongrp even if it has been defined ever since the introduction of the MBA test in the commit 01fee6b4d1f9 ("selftests/resctrl: Add MBA test"). Remove the mongrp from MBA test. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/mba_test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 9c9a4f22e529..5e0b1e794295 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -166,7 +166,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param struct resctrl_val_param param = { .resctrl_val = MBA_STR, .ctrlgrp = "c1", - .mongrp = "m1", .filename = RESULT_FILE_NAME, .init = mba_init, .setup = mba_setup, From patchwork Mon Apr 8 16:32:47 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: 13621376 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82163143C56; Mon, 8 Apr 2024 16:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594132; cv=none; b=e+GoFfIMRAbsiOl0Vyi+sT73HgYU8qwhJEGLDWRoAau8Hrwi2irmKlYQDY8AuXROWT+Aer0nYaNkaZU967vxIh/FM8JzBjageGheO0Pl1/e8t9pb6h9+0pjjQvPALZQzDhpS9p/tj+WMOzzgN69ZDeSkRSd+mMvHQbACAypY7P8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712594132; c=relaxed/simple; bh=Pi8iFK7pv9gVSy4zoMZi823T9m60lWJMkW/RGNBSPt4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=BlNwzvYoGV5YlDTa+VJ7Tye0xf4HmYpfvqphFTpHHkETxfzCMaJDibOWSuhQzP/iaVyFl3q67QvhjMcX2YEuULy1ark0epYb8b4xKxsyXMBenlu3wxqUZ5+sH6Qy+VHwQlayKEoFp9ybvrRc3jB9fB+y18GrLnL0qHVRS5K/lKc= 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=P7nkEvgr; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="P7nkEvgr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712594130; x=1744130130; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pi8iFK7pv9gVSy4zoMZi823T9m60lWJMkW/RGNBSPt4=; b=P7nkEvgr+4+oj9fWOeCFnBb/Fz985GiVB6Qh4fvZXiHrkmvww1bKeLrF N9niTH7h/sdgSsQbr1qCgS9FW1t+ls4kxREMSwDunP31WVCVlMEYQBwjH T53uEXSMQiKks8N8ZgYxaqs2BvUacCmt6KYoc/vA59omE2o2lSOh8maZo eEUQrpRqmHKEt8vOxCUbf9I6fkDBGj158UonzqHgkqqVvrryeFOuQxSut G28gXmgZNpC/hIYUbyjg+knEeZYmijgc47dRcfGdl8ju98dRiUPiMsCwk GFSQ8gPZUZn9FgGOh8iWZkGiK5/xtG/DdrG3aNG3U7CbCHhdE2pcjBzjq A==; X-CSE-ConnectionGUID: u6/IEKL/QJ+fPhuLLyt6OA== X-CSE-MsgGUID: oGxkhFJrTnO6jtgW3twb2g== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="7739013" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="7739013" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:30 -0700 X-CSE-ConnectionGUID: d3Vm6xtjSLekTdGc28CwmA== X-CSE-MsgGUID: QzRKYmE9RQSZG364hhtU4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="20503591" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.28]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 09:35:27 -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 v3 16/16] selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl() Date: Mon, 8 Apr 2024 19:32:47 +0300 Message-Id: <20240408163247.3224-17-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> References: <20240408163247.3224-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 write_bm_pid_to_resctrl() uses resctrl_val to check test name which is not a good interface generic resctrl FS functions should provide. Only MBM and CMT tests define mongrp so the test name check in write_bm_pid_to_resctrl() can be changed to depend simply on mongrp being non-NULL. With last user of resctrl_val gone, the parameter and member from the struct resctrl_val_param can removed. Test name constants can also be removed because they are not used anymore. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cat_test.c | 5 +-- tools/testing/selftests/resctrl/cmt_test.c | 1 - tools/testing/selftests/resctrl/mba_test.c | 1 - tools/testing/selftests/resctrl/mbm_test.c | 1 - tools/testing/selftests/resctrl/resctrl.h | 10 +----- tools/testing/selftests/resctrl/resctrl_val.c | 4 +-- tools/testing/selftests/resctrl/resctrlfs.c | 33 ++++++++----------- 7 files changed, 17 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index c7686fb6641a..d4dffc934bc3 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -158,7 +158,6 @@ static int cat_test(const struct resctrl_test *test, struct resctrl_val_param *param, size_t span, unsigned long current_mask) { - char *resctrl_val = param->resctrl_val; struct perf_event_read pe_read; struct perf_event_attr pea; cpu_set_t old_affinity; @@ -178,8 +177,7 @@ static int cat_test(const struct resctrl_test *test, return ret; /* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/ - ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto reset_affinity; @@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param start_mask = create_bit_mask(start, n); struct resctrl_val_param param = { - .resctrl_val = CAT_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .num_of_runs = 0, diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 238f514ba7e6..e1fadc1bfa37 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -144,7 +144,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param } struct resctrl_val_param param = { - .resctrl_val = CMT_STR, .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 5e0b1e794295..1f2a7dc73b62 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -164,7 +164,6 @@ static void mba_test_cleanup(void) static int mba_run_test(const struct resctrl_test *test, const struct user_params *uparams) { struct resctrl_val_param param = { - .resctrl_val = MBA_STR, .ctrlgrp = "c1", .filename = RESULT_FILE_NAME, .init = mba_init, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 0a3ab99b31ab..b027d17b57c5 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -132,7 +132,6 @@ static void mbm_test_cleanup(void) static int mbm_run_test(const struct resctrl_test *test, const struct user_params *uparams) { struct resctrl_val_param param = { - .resctrl_val = MBM_STR, .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index a999fbc13fd3..2dda56084588 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -81,7 +81,6 @@ struct resctrl_test { /* * resctrl_val_param: resctrl test parameters - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written @@ -90,7 +89,6 @@ struct resctrl_test { * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { - char *resctrl_val; const char *ctrlgrp; const char *mongrp; char filename[64]; @@ -113,11 +111,6 @@ struct perf_event_read { } values[2]; }; -#define MBM_STR "mbm" -#define MBA_STR "mba" -#define CMT_STR "cmt" -#define CAT_STR "cat" - /* * Memory location that consumes values compiler must not optimize away. * Volatile ensures writes to this location cannot be optimized away by @@ -143,8 +136,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity); int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity); int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, const char *resource); -int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, - const char *mongrp, const char *resctrl_val); +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); unsigned char *alloc_buffer(size_t buf_size, int memflush); diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index a9e0bb35a4ab..17b93b44b013 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -664,7 +664,6 @@ int resctrl_val(const struct resctrl_test *test, const char * const *benchmark_cmd, struct resctrl_val_param *param) { - char *resctrl_val = param->resctrl_val; struct sigaction sigact; int ret = 0, pipefd[2]; char pipe_message = 0; @@ -755,8 +754,7 @@ int resctrl_val(const struct resctrl_test *test, goto out; /* Write benchmark to specified control&monitoring grp in resctrl FS */ - ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret = write_bm_pid_to_resctrl(bm_pid, param->ctrlgrp, param->mongrp); if (ret) goto out; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 6b4448588666..4bf1fe6dc308 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -519,7 +519,6 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * @bm_pid: PID that should be written * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) - * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * * If a con_mon grp is requested, create it and write pid to it, otherwise * write pid to root con_mon grp. @@ -529,8 +528,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid) * * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, - const char *mongrp, const char *resctrl_val) +int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, const char *mongrp) { char controlgroup[128], monitorgroup[512], monitorgroup_p[256]; char tasks[1024]; @@ -550,22 +548,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp, if (ret) goto out; - /* Create mon grp and write pid into it for "mbm" and "cmt" test */ - if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)) || - !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { - if (mongrp) { - sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); - sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); - ret = create_grp(mongrp, monitorgroup, monitorgroup_p); - if (ret) - goto out; - - sprintf(tasks, "%s/mon_groups/%s/tasks", - controlgroup, mongrp); - ret = write_pid_to_tasks(tasks, bm_pid); - if (ret) - goto out; - } + /* Create monitor group and write pid into if it is used */ + if (mongrp) { + sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); + sprintf(monitorgroup, "%s/%s", monitorgroup_p, mongrp); + ret = create_grp(mongrp, monitorgroup, monitorgroup_p); + if (ret) + goto out; + + sprintf(tasks, "%s/mon_groups/%s/tasks", + controlgroup, mongrp); + ret = write_pid_to_tasks(tasks, bm_pid); + if (ret) + goto out; } out: