From patchwork Mon May 18 22:08:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DC49138A for ; Mon, 18 May 2020 22:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11B752083E for ; Mon, 18 May 2020 22:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726386AbgERWNx (ORCPT ); Mon, 18 May 2020 18:13:53 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWNx (ORCPT ); Mon, 18 May 2020 18:13:53 -0400 IronPort-SDR: 55fxvMTrLc90fC7ULgfla7EgtVnidL73PUKYMnlKReqvCRQ9QyV0r0tDPpnHnh8FV5hnKGphZ+ BSTsdrS7vZeQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:53 -0700 IronPort-SDR: uQ6JfH8qguBlU/UqkcEseMNUEoC/hkoiXOwrk61vrRSbtQIiSHK/O23UTdcrj0Wiff9fg57jVB jt5/vDEWSJsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420331" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:52 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 01/19] selftests/resctrl: Rename CQM test as CMT test Date: Mon, 18 May 2020 15:08:21 -0700 Message-Id: <42e1dd83fdef7162743936287febaebd6a6e0523.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org CQM (Cache Quality Monitoring) and CMT (Cache Monitoring Technology) are synonyms referring to the same feature (i.e. measuring cache occupancy) in Intel CPU's. Presently, resctrl test suit refers to this feature as CQM but SDM refers to the same feature as CMT. SDM usage should be treated as official naming, hence, rename cqm_test as cmt_test and change all the places (functions, comments, variable names etc.) from cqm to cmt. No functional changes intended. Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Suggested-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/README | 4 +-- tools/testing/selftests/resctrl/cache.c | 4 +-- .../resctrl/{cqm_test.c => cmt_test.c} | 20 +++++++------- tools/testing/selftests/resctrl/resctrl.h | 4 +-- .../testing/selftests/resctrl/resctrl_tests.c | 26 +++++++++---------- tools/testing/selftests/resctrl/resctrl_val.c | 12 ++++----- tools/testing/selftests/resctrl/resctrlfs.c | 10 +++---- 7 files changed, 40 insertions(+), 40 deletions(-) rename tools/testing/selftests/resctrl/{cqm_test.c => cmt_test.c} (89%) diff --git a/tools/testing/selftests/resctrl/README b/tools/testing/selftests/resctrl/README index 6e5a0ffa18e8..4b36b25b6ac0 100644 --- a/tools/testing/selftests/resctrl/README +++ b/tools/testing/selftests/resctrl/README @@ -46,8 +46,8 @@ ARGUMENTS Parameter '-h' shows usage information. usage: resctrl_tests [-h] [-b "benchmark_cmd [options]"] [-t test list] [-n no_of_bits] - -b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM default benchmark is builtin fill_buf - -t test list: run tests specified in the test list, e.g. -t mbm, mba, cqm, cat + -b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CMT default benchmark is builtin fill_buf + -t test list: run tests specified in the test list, e.g. -t mbm, mba, cmt, cat -n no_of_bits: run cache tests using specified no of bits in cache bit mask -p cpu_no: specify CPU number to run the test. 1 is default -h: help diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 38dbf4962e33..4d73edd81293 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -111,7 +111,7 @@ static int get_llc_perf(unsigned long *llc_perf_miss) /* * Get LLC Occupancy as reported by RESCTRL FS - * For CQM, + * For CMT, * 1. If con_mon grp and mon grp given, then read from mon grp in * con_mon grp * 2. If only con_mon grp given, then read from con_mon grp @@ -192,7 +192,7 @@ int measure_cache_vals(struct resctrl_val_param *param, int bm_pid) /* * Measure llc occupancy from resctrl. */ - if (!strcmp(param->resctrl_val, "cqm")) { + if (!strcmp(param->resctrl_val, "cmt")) { ret = get_llc_occu_resctrl(&llc_occu_resc); if (ret < 0) return ret; diff --git a/tools/testing/selftests/resctrl/cqm_test.c b/tools/testing/selftests/resctrl/cmt_test.c similarity index 89% rename from tools/testing/selftests/resctrl/cqm_test.c rename to tools/testing/selftests/resctrl/cmt_test.c index c8756152bd61..13b01e010238 100644 --- a/tools/testing/selftests/resctrl/cqm_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Cache Monitoring Technology (CQM) test + * Cache Monitoring Technology (CMT) test * * Copyright (C) 2018 Intel Corporation * @@ -11,7 +11,7 @@ #include "resctrl.h" #include -#define RESULT_FILE_NAME "result_cqm" +#define RESULT_FILE_NAME "result_cmt" #define NUM_OF_RUNS 5 #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 @@ -21,7 +21,7 @@ char cbm_mask[256]; unsigned long long_mask; unsigned long cache_size; -static int cqm_setup(int num, ...) +static int cmt_setup(int num, ...) { struct resctrl_val_param *p; va_list param; @@ -58,7 +58,7 @@ static void show_cache_info(unsigned long sum_llc_occu_resc, int no_of_bits, else res = false; - printf("%sok CQM: diff within %d, %d\%%\n", res ? "" : "not", + printf("%sok CMT: diff within %d, %d\%%\n", res ? "" : "not", MAX_DIFF, (int)MAX_DIFF_PERCENT); printf("# diff: %ld\n", avg_diff); @@ -106,12 +106,12 @@ static int check_results(struct resctrl_val_param *param, int no_of_bits) return 0; } -void cqm_test_cleanup(void) +void cmt_test_cleanup(void) { remove(RESULT_FILE_NAME); } -int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd) +int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) { int ret, mum_resctrlfs; @@ -122,7 +122,7 @@ int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd) if (ret) return ret; - if (!validate_resctrl_feature_request("cqm")) + if (!validate_resctrl_feature_request("cmt")) return -1; ret = get_cbm_mask("L3"); @@ -145,7 +145,7 @@ int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd) } struct resctrl_val_param param = { - .resctrl_val = "cqm", + .resctrl_val = "cmt", .ctrlgrp = "c1", .mongrp = "m1", .cpu_no = cpu_no, @@ -154,7 +154,7 @@ int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd) .mask = ~(long_mask << n) & long_mask, .span = cache_size * n / count_of_bits, .num_of_runs = 0, - .setup = cqm_setup, + .setup = cmt_setup, }; if (strcmp(benchmark_cmd[0], "fill_buf") == 0) @@ -170,7 +170,7 @@ int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd) if (ret) return ret; - cqm_test_cleanup(); + cmt_test_cleanup(); return 0; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 39bf59c6b9c5..68522b19b235 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -98,9 +98,9 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int cat_val(struct resctrl_val_param *param); void cat_test_cleanup(void); int cat_perf_miss_val(int cpu_no, int no_of_bits, char *cache_type); -int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd); +int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd); unsigned int count_bits(unsigned long n); -void cqm_test_cleanup(void); +void cmt_test_cleanup(void); int get_core_sibling(int cpu_no); int measure_cache_vals(struct resctrl_val_param *param, int bm_pid); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 425cc85ac883..35a91cab1b88 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -37,10 +37,10 @@ void detect_amd(void) static void cmd_help(void) { printf("usage: resctrl_tests [-h] [-b \"benchmark_cmd [options]\"] [-t test list] [-n no_of_bits]\n"); - printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CQM"); + printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CMT"); printf("\t default benchmark is builtin fill_buf\n"); printf("\t-t test list: run tests specified in the test list, "); - printf("e.g. -t mbm, mba, cqm, cat\n"); + printf("e.g. -t mbm, mba, cmt, cat\n"); printf("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n"); printf("\t-p cpu_no: specify CPU number to run the test. 1 is default\n"); printf("\t-h: help\n"); @@ -50,13 +50,13 @@ void tests_cleanup(void) { mbm_test_cleanup(); mba_test_cleanup(); - cqm_test_cleanup(); + cmt_test_cleanup(); cat_test_cleanup(); } int main(int argc, char **argv) { - bool has_ben = false, mbm_test = true, mba_test = true, cqm_test = true; + bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 5; char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64]; char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE]; @@ -82,15 +82,15 @@ int main(int argc, char **argv) mbm_test = false; mba_test = false; - cqm_test = false; + cmt_test = false; cat_test = false; while (token) { if (!strcmp(token, "mbm")) { mbm_test = true; } else if (!strcmp(token, "mba")) { mba_test = true; - } else if (!strcmp(token, "cqm")) { - cqm_test = true; + } else if (!strcmp(token, "cmt")) { + cmt_test = true; } else if (!strcmp(token, "cat")) { cat_test = true; } else { @@ -178,13 +178,13 @@ int main(int argc, char **argv) tests_run++; } - if (cqm_test) { - printf("# Starting CQM test ...\n"); + if (cmt_test) { + printf("# Starting CMT test ...\n"); if (!has_ben) - sprintf(benchmark_cmd[5], "%s", "cqm"); - res = cqm_resctrl_val(cpu_no, no_of_bits, benchmark_cmd); - printf("%sok CQM: test\n", res ? "not " : ""); - cqm_test_cleanup(); + sprintf(benchmark_cmd[5], "%s", "cmt"); + res = cmt_resctrl_val(cpu_no, no_of_bits, benchmark_cmd); + printf("%sok CMT: test\n", res ? "not " : ""); + cmt_test_cleanup(); tests_run++; } diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 520fea3606d1..270cd95e0026 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -492,7 +492,7 @@ static int print_results_bw(char *filename, int bm_pid, float bw_imc, return 0; } -static void set_cqm_path(const char *ctrlgrp, const char *mongrp, char sock_num) +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, @@ -512,7 +512,7 @@ static void set_cqm_path(const char *ctrlgrp, const char *mongrp, char sock_num) * @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 - * @resctrl_val: Resctrl feature (Eg: cat, cqm.. etc) + * @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) @@ -524,8 +524,8 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, return; } - if (strcmp(resctrl_val, "cqm") == 0) - set_cqm_path(ctrlgrp, mongrp, resource_id); + if (strcmp(resctrl_val, "cmt") == 0) + set_cmt_path(ctrlgrp, mongrp, resource_id); } static int @@ -682,7 +682,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, param->cpu_no, resctrl_val); - } else if (strcmp(resctrl_val, "cqm") == 0) + } else if (strcmp(resctrl_val, "cmt") == 0) initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, param->cpu_no, resctrl_val); @@ -721,7 +721,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) ret = measure_vals(param, &bw_resc_start); if (ret) break; - } else if (strcmp(resctrl_val, "cqm") == 0) { + } else if (strcmp(resctrl_val, "cmt") == 0) { ret = param->setup(1, param); if (ret) { ret = 0; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 19c0ec4045a4..727e667e2cc9 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -334,7 +334,7 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) operation = atoi(benchmark_cmd[4]); sprintf(resctrl_val, "%s", benchmark_cmd[5]); - if (strcmp(resctrl_val, "cqm") != 0) + if (strcmp(resctrl_val, "cmt") != 0) buffer_span = span * MB; else buffer_span = span; @@ -458,8 +458,8 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, if (ret) goto out; - /* Create mon grp and write pid into it for "mbm" and "cqm" test */ - if ((strcmp(resctrl_val, "cqm") == 0) || + /* Create mon grp and write pid into it for "mbm" and "cmt" test */ + if ((strcmp(resctrl_val, "cmt") == 0) || (strcmp(resctrl_val, "mbm") == 0)) { if (strlen(mongrp)) { sprintf(monitorgroup_p, "%s/mon_groups", controlgroup); @@ -507,7 +507,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val) if ((strcmp(resctrl_val, "mba") != 0) && (strcmp(resctrl_val, "cat") != 0) && - (strcmp(resctrl_val, "cqm") != 0)) + (strcmp(resctrl_val, "cmt") != 0)) return -ENOENT; if (!schemata) { @@ -528,7 +528,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val) else sprintf(controlgroup, "%s/schemata", RESCTRL_PATH); - if (!strcmp(resctrl_val, "cat") || !strcmp(resctrl_val, "cqm")) + if (!strcmp(resctrl_val, "cat") || !strcmp(resctrl_val, "cmt")) sprintf(schema, "%s%d%c%s", "L3:", resource_id, '=', schemata); if (strcmp(resctrl_val, "mba") == 0) sprintf(schema, "%s%d%c%s", "MB:", resource_id, '=', schemata); From patchwork Mon May 18 22:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C70F1739 for ; Mon, 18 May 2020 22:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF42B20674 for ; Mon, 18 May 2020 22:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgERWNy (ORCPT ); Mon, 18 May 2020 18:13:54 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWNy (ORCPT ); Mon, 18 May 2020 18:13:54 -0400 IronPort-SDR: dMqgvTkkWu/IqqiQMsygqfqnwO63CLjJdA+BYXqMYEsfE9fngOAP+865/RQz01sFtPNj/kQ4xQ ycyzd+iz+1qg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:53 -0700 IronPort-SDR: qcYHO40FXABctetjn48ijClHnXIdMAacRhW8jNfFaHZ0pJ3yrBPHyh0fU3crIeWyP7d7F+C411 vrsA0T7v2buQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420335" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:53 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 02/19] selftests/resctrl: Fix typo Date: Mon, 18 May 2020 15:08:22 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Reinette Chatre The format "%sok" is used to print results of a test. If the test passes, the empty string is printed and if the test fails "not " is printed. This results in output of "ok" when test passes and "not ok" when test fails. Fix one instance where "not" (without a space) is printed on test failure resulting in output of "notok" on test failure. Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Signed-off-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/cmt_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 13b01e010238..6ffb56c6a1e2 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -58,7 +58,7 @@ static void show_cache_info(unsigned long sum_llc_occu_resc, int no_of_bits, else res = false; - printf("%sok CMT: diff within %d, %d\%%\n", res ? "" : "not", + printf("%sok CMT: diff within %d, %d\%%\n", res ? "" : "not ", MAX_DIFF, (int)MAX_DIFF_PERCENT); printf("# diff: %ld\n", avg_diff); From patchwork Mon May 18 22:08:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FF9E138A for ; Mon, 18 May 2020 22:13:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC60A2084C for ; Mon, 18 May 2020 22:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgERWNy (ORCPT ); Mon, 18 May 2020 18:13:54 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWNy (ORCPT ); Mon, 18 May 2020 18:13:54 -0400 IronPort-SDR: XHtaScW65e4JLKiI8QiAhNR9sAVyOTnEf0oAMHVr+hszpyO6LdwctVUfjxa8RPHSfQQLK4tywd e8wnLrqzl6yQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:54 -0700 IronPort-SDR: Az5gOzGHo+JSUDV4mvnUrYKbRulaoJ4lbN0C5YG5ovQZwhhMWDWJ1w4B4d3CNTirrjr+XHEEYj 23XKHjv/63WA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420338" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:53 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 03/19] selftests/resctrl: Fix typo in help text Date: Mon, 18 May 2020 15:08:23 -0700 Message-Id: <5c0a4f45083c9bdfa514d95389b5d3c31c1c5863.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Reinette Chatre Add a missing newline to the help text printed and fixup the next line to line it up to previous line for improved readability. Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Signed-off-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 35a91cab1b88..b2a560c0c5dc 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -37,8 +37,8 @@ void detect_amd(void) static void cmd_help(void) { printf("usage: resctrl_tests [-h] [-b \"benchmark_cmd [options]\"] [-t test list] [-n no_of_bits]\n"); - printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CMT"); - printf("\t default benchmark is builtin fill_buf\n"); + printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CMT\n"); + printf("\t default benchmark is builtin fill_buf\n"); printf("\t-t test list: run tests specified in the test list, "); printf("e.g. -t mbm, mba, cmt, cat\n"); printf("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n"); From patchwork Mon May 18 22:08:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EB97739 for ; Mon, 18 May 2020 22:13:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 666D020674 for ; Mon, 18 May 2020 22:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727900AbgERWNz (ORCPT ); Mon, 18 May 2020 18:13:55 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWNz (ORCPT ); Mon, 18 May 2020 18:13:55 -0400 IronPort-SDR: iBX7dBcQ3g1hXvcjDxPKqh7hPE4qw2c49+RKqn7URzBkaXv4rewsmUCoIFmpPacmZSmW/PdhfQ ngRlhLk4nNaw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:54 -0700 IronPort-SDR: MLk15Xr3jpM92YntC4U3Hy2Ui8LS9WFVY2WnJRJ+X7ovwM++twmuh+4OtHMXEybGAuigMTCsJl OUIY9qMqSE6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420341" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:54 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 04/19] selftests/resctrl: Declare global variables as extern Date: Mon, 18 May 2020 15:08:24 -0700 Message-Id: <5417736f2334c43098dd64733bd220dfe56a7c90.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org resctrl test suite uses global variables (E.g: bm_pid, ppid, llc_occup_path and is_amd) that are used across .c files. Declare them as 'extern' variables in resctrl.h file so that they are defined only in one .c file. Otherwise sparse tool warns it as multiple definitions of the same variable. Sparse still complains about "bm_pid" variable name being used globally and locally to a function in cache.c file. This issue will be addressed in a later patch series. Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file system operations and data") Reported-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 68522b19b235..814d0dd517a4 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -62,11 +62,11 @@ struct resctrl_val_param { int (*setup)(int num, ...); }; -pid_t bm_pid, ppid; -int tests_run; +extern pid_t bm_pid, ppid; +extern int tests_run; -char llc_occup_path[1024]; -bool is_amd; +extern char llc_occup_path[1024]; +extern bool is_amd; bool check_resctrlfs_support(void); int filter_dmesg(void); From patchwork Mon May 18 22:08:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35C58739 for ; Mon, 18 May 2020 22:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D76020853 for ; Mon, 18 May 2020 22:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728039AbgERWNz (ORCPT ); Mon, 18 May 2020 18:13:55 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWNz (ORCPT ); Mon, 18 May 2020 18:13:55 -0400 IronPort-SDR: R+qKp6Sip0FyJFuuU94ST0QqtcFP7kuK7i50ewkQIUJdtOfJZK1Klz7Dn2HyL3fKlSb+wyz7qa AEnF76Ibs9xA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:55 -0700 IronPort-SDR: 46uiIUCjFGYyrJePkjdKdZqabN9uEr/1XQNmvzcFHY3DqZ83lfZPCRNiUveX6a7HWB6XoizMI7 Bw4w7BGRRecw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420344" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:54 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 05/19] selftests/resctrl: Return if resctrl file system is not supported Date: Mon, 18 May 2020 15:08:25 -0700 Message-Id: <0142414b5480b4325cb28656c9508292ed80ab7a.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Presently, return value of check_resctrlfs_support() is not checked and hence the test tries to execute individual tests like CAT, CMT, MBM and MBA even if resctrl file system is not supported in /proc/filesystems. Fix this by checking for the return value of check_resctrlfs_support() and if it returns false i.e. resctrl file system is not supported, then don't run any tests. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_tests.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index b2a560c0c5dc..d24de546d4ef 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -155,7 +155,11 @@ int main(int argc, char **argv) sprintf(bw_report, "reads"); sprintf(bm_type, "fill_buf"); - check_resctrlfs_support(); + if (!check_resctrlfs_support()) { + printf("Bail out! resctrl FS does not exist\n"); + goto out; + } + filter_dmesg(); if (!is_amd && mbm_test) { @@ -196,6 +200,7 @@ int main(int argc, char **argv) cat_test_cleanup(); } +out: printf("1..%d\n", tests_run); return 0; From patchwork Mon May 18 22:08:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8914F1668 for ; Mon, 18 May 2020 22:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AAC3206D4 for ; Mon, 18 May 2020 22:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728061AbgERWN4 (ORCPT ); Mon, 18 May 2020 18:13:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWN4 (ORCPT ); Mon, 18 May 2020 18:13:56 -0400 IronPort-SDR: 9sUJy+Ul37koJmIPs6/Q72TRGWhyw/9C/SbnmU2y03YH+p+M04KZbC1K6iuI7To0mBC/qlcWfj Fhn9VPfXjNLw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:56 -0700 IronPort-SDR: WuwUUgMPxHKFfNDumWaZUEVUta2d8RGygCAMBi4RwRwdTRbCdXABkoiKzmRduePSVoqlpvOJMB eDvvr2Up0Dyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420347" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:55 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 06/19] selftests/resctrl: Check for resctrl mount point only if resctrl FS is supported Date: Mon, 18 May 2020 15:08:26 -0700 Message-Id: <523fc548414652dfe2068f60b959905e5a4a0e1d.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Presently, check_resctrlfs_support() tries to open "/sys/fs/resctrl" and will also look for resctrl mount point in "/proc/mounts" even if resctrl file system is not supported. Both the above will fail if resctrl file system is not supported. Hence, return immediately if resctrl file system is not supported. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrlfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 727e667e2cc9..e43ddebd1aa4 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -581,6 +581,9 @@ bool check_resctrlfs_support(void) printf("%sok kernel supports resctrl filesystem\n", ret ? "" : "not "); tests_run++; + if (!ret) + return ret; + dp = opendir(RESCTRL_PATH); printf("%sok resctrl mountpoint \"%s\" exists\n", dp ? "" : "not ", RESCTRL_PATH); From patchwork Mon May 18 22:08:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 592E0739 for ; Mon, 18 May 2020 22:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A8CE20872 for ; Mon, 18 May 2020 22:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgERWN5 (ORCPT ); Mon, 18 May 2020 18:13:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWN4 (ORCPT ); Mon, 18 May 2020 18:13:56 -0400 IronPort-SDR: qrcTGnNea+vEpBFoovvqUesGtJ23SzkT5fxPwGiKRGLh+VkdbT7/DBdggD1Dg0hdlwPYVI2CBl yT9Zd8eF/kIQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:56 -0700 IronPort-SDR: Av4G38pSJ9qwle9giEtLeGmo40PMLtOD+ORubTABQCevD/+KKZzRZWPva2dNuitys2hEZURBFm V6wllpwtUhJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420350" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:56 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 07/19] selftests/resctrl: Use resctrl/info for feature detection Date: Mon, 18 May 2020 15:08:27 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org RDT features could be enabled or disabled through kernel command line parameters. This is not reflected in /proc/cpuinfo i.e. cpuinfo always shows the features supported by H/W whereas user could selectively enable or disable some of these features. So, before running a requested test, /proc/cpuinfo cannot be used to check if the system supports the requested RDT feature. A more appropriate place to check for this is resctrl/info. Directories like L3, MB and L3_MON are populated only if the respective feature is enabled. Hence, use resctrl/info for feature detection instead of /proc/cpuinfo. Please note that, presently, only L3_CAT, L3_CMT, MBA and MBM are supported. L2 and CDP variants of L3 are not yet supported. Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file system operations and data") Reported-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl.h | 6 ++- tools/testing/selftests/resctrl/resctrlfs.c | 51 ++++++++++++++++----- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 814d0dd517a4..65ca24bf3eac 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -28,6 +28,10 @@ #define RESCTRL_PATH "/sys/fs/resctrl" #define PHYS_ID_PATH "/sys/devices/system/cpu/cpu" #define CBM_MASK_PATH "/sys/fs/resctrl/info" +#define L3_PATH "/sys/fs/resctrl/info/L3" +#define MB_PATH "/sys/fs/resctrl/info/MB" +#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON" +#define L3_MON_FEATURES_PATH "/sys/fs/resctrl/info/L3_MON/mon_features" #define PARENT_EXIT(err_msg) \ do { \ @@ -74,7 +78,7 @@ int remount_resctrlfs(bool mum_resctrlfs); int get_resource_id(int cpu_no, int *resource_id); int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); -bool validate_resctrl_feature_request(char *resctrl_val); +bool validate_resctrl_feature_request(const char *resctrl_val); char *fgrep(FILE *inf, const char *str); int taskset_benchmark(pid_t bm_pid, int cpu_no); void run_benchmark(int signum, siginfo_t *info, void *ucontext); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index e43ddebd1aa4..67d775d03271 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -618,26 +618,55 @@ char *fgrep(FILE *inf, const char *str) * validate_resctrl_feature_request - Check if requested feature is valid. * @resctrl_val: Requested feature * - * Return: 0 on success, non-zero on failure + * Return: True if the feature is supported, else false */ -bool validate_resctrl_feature_request(char *resctrl_val) +bool validate_resctrl_feature_request(const char *resctrl_val) { - FILE *inf = fopen("/proc/cpuinfo", "r"); + struct stat statbuf; bool found = false; char *res; + FILE *inf; - if (!inf) + if (!resctrl_val) return false; - res = fgrep(inf, "flags"); - - if (res) { - char *s = strchr(res, ':'); + if (remount_resctrlfs(false)) + return false; - found = s && !strstr(s, resctrl_val); - free(res); + if (!strcmp(resctrl_val, "cat")) { + if (!stat(L3_PATH, &statbuf)) + return true; + } else if (!strcmp(resctrl_val, "mba")) { + if (!stat(MB_PATH, &statbuf)) + return true; + } else if (!strcmp(resctrl_val, "mbm") || !strcmp(resctrl_val, "cmt")) { + if (!stat(L3_MON_PATH, &statbuf)) { + inf = fopen(L3_MON_FEATURES_PATH, "r"); + if (!inf) + return false; + + if (!strcmp(resctrl_val, "cmt")) { + res = fgrep(inf, "llc_occupancy"); + if (res) { + found = true; + free(res); + } + } + + if (!strcmp(resctrl_val, "mbm")) { + res = fgrep(inf, "mbm_total_bytes"); + if (res) { + free(res); + res = fgrep(inf, "mbm_local_bytes"); + if (res) { + found = true; + free(res); + } + } + } + fclose(inf); + } } - fclose(inf); return found; } From patchwork Mon May 18 22:08:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC34E739 for ; Mon, 18 May 2020 22:13:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE2E92081A for ; Mon, 18 May 2020 22:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbgERWN5 (ORCPT ); Mon, 18 May 2020 18:13:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWN5 (ORCPT ); Mon, 18 May 2020 18:13:57 -0400 IronPort-SDR: 7ZELfbeQ19PVEVfjRlNCv1s38fpQ1q1eGXnshLf/xDR2zwsuLGAPZxm2Bz5g/ENjRX73P3iWLo l6/Uev9OQMwQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:57 -0700 IronPort-SDR: kOUfEX4IBwMWDuWkR8OOnFzyXowRBLHyiQn9oszZlpMbvqp0OX6B/tECPMr/bIKya4/CcKr+VP bMbtLQPzOrOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420358" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:56 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 08/19] selftests/resctrl: Ensure sibling CPU is not same as original CPU Date: Mon, 18 May 2020 15:08:28 -0700 Message-Id: <27ad05645247a955e1e146971c251e0825114cfb.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Reinette Chatre The resctrl tests can accept a CPU on which the tests are run and use default of CPU #1 if it is not provided. In the CAT test a "sibling CPU" is determined that is from the same package where another thread will be run. The current algorithm with which a "sibling CPU" is determined does not take the provided/default CPU into account and when that CPU is the first CPU in a package then the "sibling CPU" will be selected to be the same CPU since it starts by picking the first CPU from core_siblings_list. Fix the "sibling CPU" selection by taking the provided/default CPU into account and ensuring a sibling that is a different CPU is selected. Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Signed-off-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 67d775d03271..05956319d9ce 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -268,7 +268,7 @@ int get_core_sibling(int cpu_no) while (token) { sibling_cpu_no = atoi(token); /* Skipping core 0 as we don't want to run test on core 0 */ - if (sibling_cpu_no != 0) + if (sibling_cpu_no != 0 && sibling_cpu_no != cpu_no) break; token = strtok(NULL, "-,"); } From patchwork Mon May 18 22:08:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49A14739 for ; Mon, 18 May 2020 22:13:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3004720878 for ; Mon, 18 May 2020 22:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbgERWN7 (ORCPT ); Mon, 18 May 2020 18:13:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWN6 (ORCPT ); Mon, 18 May 2020 18:13:58 -0400 IronPort-SDR: 63vdUwZ0YhO5l7mmyqnmoWykf8GuNWunO4b8X98lkAB9pRQg0sdXx09KkNo0YF/6o3gEiCY61h HfahrNiFskCQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:58 -0700 IronPort-SDR: Y2M3KODyaSWKrmvFPg6dzMyriR7G9pEz4s7n1gCqGu9HYpD5dkfTruCqaQCz9HqA7BG5H51qcE 30sBNDQiQkZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420367" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:57 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 09/19] selftests/resctrl: Fix missing options "-n" and "-p" Date: Mon, 18 May 2020 15:08:29 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Fenghua Yu Add missing options "-n" and "-p" in getopt() so that the options can take action. Other code related to the options is in place already and no change is needed. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Fenghua Yu Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index d24de546d4ef..cab69ed8c67d 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -73,7 +73,7 @@ int main(int argc, char **argv) } } - while ((c = getopt(argc_new, argv, "ht:b:")) != -1) { + while ((c = getopt(argc_new, argv, "ht:b:n:p:")) != -1) { char *token; switch (c) { From patchwork Mon May 18 22:08:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AE82912 for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BFDB206D4 for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbgERWOA (ORCPT ); Mon, 18 May 2020 18:14:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWN7 (ORCPT ); Mon, 18 May 2020 18:13:59 -0400 IronPort-SDR: pYdjsI5hAHPynpKrrBHSxQNctuINghMhEj2G9uWkLSfydJ6lPBlBV9V4VsJtEAx3S1yPGqyrNQ 3iIC4/kgCNaQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:59 -0700 IronPort-SDR: ADt+NZ83GvRJRZr8KQ3kozYTz1r+sSJn6cisjgcTA9cqhVkRvDxi03iHrqwQLrwiZtDe+9fHpc 1OkqtKCJ9owA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420373" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:58 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 10/19] selftests/resctrl: Fix MBA/MBM results reporting format Date: Mon, 18 May 2020 15:08:30 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently MBM/MBA tests use absolute values to check results. But, iMC values and MBM resctrl values may vary on different platforms and specifically for MBA the values may vary as schemata changes. Hence, use percentage instead of absolute values to check tests result. Fixes: 01fee6b4d1f9 ("selftests/resctrl: Add MBA test") Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/mba_test.c | 20 +++++++++++--------- tools/testing/selftests/resctrl/mbm_test.c | 13 +++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7bf8eaa6204b..ba0234d4829e 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -12,7 +12,7 @@ #define RESULT_FILE_NAME "result_mba" #define NUM_OF_RUNS 5 -#define MAX_DIFF 300 +#define MAX_DIFF_PERCENT 5 #define ALLOCATION_MAX 100 #define ALLOCATION_MIN 10 #define ALLOCATION_STEP 10 @@ -62,7 +62,8 @@ static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) allocation++) { unsigned long avg_bw_imc, avg_bw_resc; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; - unsigned long avg_diff; + int avg_diff_per; + float avg_diff; /* * The first run is discarded due to inaccurate value from @@ -76,17 +77,18 @@ static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS - 1); avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS - 1); - avg_diff = labs((long)(avg_bw_resc - avg_bw_imc)); + avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff_per = (int)(avg_diff * 100); - printf("%sok MBA schemata percentage %u smaller than %d %%\n", - avg_diff > MAX_DIFF ? "not " : "", - ALLOCATION_MAX - ALLOCATION_STEP * allocation, - MAX_DIFF); + printf("%sok MBA: diff within %d%% for schemata %u\n", + avg_diff_per > MAX_DIFF_PERCENT ? "not " : "", + MAX_DIFF_PERCENT, + ALLOCATION_MAX - ALLOCATION_STEP * allocation); tests_run++; - printf("# avg_diff: %lu\n", avg_diff); + printf("# avg_diff_per: %d%%\n", avg_diff_per); printf("# avg_bw_imc: %lu\n", avg_bw_imc); printf("# avg_bw_resc: %lu\n", avg_bw_resc); - if (avg_diff > MAX_DIFF) + if (avg_diff_per > MAX_DIFF_PERCENT) failed = true; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 4700f7453f81..ca610c3ebc8c 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -11,7 +11,7 @@ #include "resctrl.h" #define RESULT_FILE_NAME "result_mbm" -#define MAX_DIFF 300 +#define MAX_DIFF_PERCENT 5 #define NUM_OF_RUNS 5 static void @@ -19,8 +19,8 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) { unsigned long avg_bw_imc = 0, avg_bw_resc = 0; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; - long avg_diff = 0; - int runs; + int runs, avg_diff_per; + float avg_diff = 0; /* * Discard the first value which is inaccurate due to monitoring setup @@ -33,12 +33,13 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) avg_bw_imc = sum_bw_imc / 4; avg_bw_resc = sum_bw_resc / 4; - avg_diff = avg_bw_resc - avg_bw_imc; + avg_diff = (float)labs(avg_bw_resc - avg_bw_imc) / avg_bw_imc; + avg_diff_per = (int)(avg_diff * 100); printf("%sok MBM: diff within %d%%\n", - labs(avg_diff) > MAX_DIFF ? "not " : "", MAX_DIFF); + avg_diff_per > MAX_DIFF_PERCENT ? "not " : "", MAX_DIFF_PERCENT); tests_run++; - printf("# avg_diff: %lu\n", labs(avg_diff)); + printf("# avg_diff_per: %d%%\n", avg_diff_per); printf("# Span (MB): %d\n", span); printf("# avg_bw_imc: %lu\n", avg_bw_imc); printf("# avg_bw_resc: %lu\n", avg_bw_resc); From patchwork Mon May 18 22:08:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4C53138A for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADF0320878 for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbgERWOA (ORCPT ); Mon, 18 May 2020 18:14:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:46557 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgERWOA (ORCPT ); Mon, 18 May 2020 18:14:00 -0400 IronPort-SDR: AZ4Ec6wNo4rn7Xmd2+BC94DJriipvoosVvemnwkw/f3Z2PGyrQbBBH9oPHnmTYikMpfHxNgnPr fXquHki48BkQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:13:59 -0700 IronPort-SDR: zFzF7zh0Z8MBwFDjsmPyaHhwaGwCX/27alClOgyDIS0xeiaM9H4rIADBXFF6rCHnHIFy1ArHNc eVIXXcV2YHsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420381" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:58 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 11/19] selftests/resctrl: Abort running tests if not root user Date: Mon, 18 May 2020 15:08:31 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Running resctrl selftest requires the test to write to resctrl file system and only root user has permission to do so. Hence, abort the test suite if the user is not running the test with root user privileges. Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test") Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_tests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index cab69ed8c67d..f005ba2b41ec 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -125,8 +125,10 @@ int main(int argc, char **argv) * 1. We write to resctrl FS * 2. We execute perf commands */ - if (geteuid() != 0) - printf("# WARNING: not running as root, tests may fail.\n"); + if (geteuid() != 0) { + printf("Bail out! not running as root, abort testing\n"); + return -1; + } /* Detect AMD vendor */ detect_amd(); From patchwork Mon May 18 22:08:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7DD1739 for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C99D820885 for ; Mon, 18 May 2020 22:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbgERWOA (ORCPT ); Mon, 18 May 2020 18:14:00 -0400 Received: from mga01.intel.com ([192.55.52.88]:46546 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWOA (ORCPT ); Mon, 18 May 2020 18:14:00 -0400 IronPort-SDR: 4ZNaAmWfdR8rmh370XDL1zypLCvN9yS5YUtXlI8IWKyGljWocBXCswUS9SHY98Iu4OkhzUN3eq Pjni+W5qFwbA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:00 -0700 IronPort-SDR: v5qWe2tEz67Z9QmPClF29+xGaOBewSBKJquyGFvwU7Fl9Us+IvAxi30UcX0oRlG1vz63Ldd73B sg14wNeX8WJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420386" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:13:59 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 12/19] selftests/resctrl: Enable gcc checks to detect buffer overflows Date: Mon, 18 May 2020 15:08:32 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Feature Test Macros man page says the below about _FORTIFY_SOURCE "Defining this macro causes some lightweight checks to be performed to detect some buffer overflow errors when employing various string and memory manipulation functions (for example, memcpy, memset, stpcpy, strcpy, strncpy, strcat, strncat, sprintf, snprintf, vsprintf, vsnprintf, gets, and wide character variants thereof). For some functions, argument consistency is checked; for example, a check is made that open has been supplied with a mode argument when the specified flags include O_CREAT. Not all problems are detected, just some common cases. If _FORTIFY_SOURCE is set to 1, with compiler optimization level 1 (gcc -O1) and above, checks that shouldn't change the behavior of conforming programs are performed. With _FORTIFY_SOURCE set to 2, some more checking is added, but some conforming programs might fail. Some of the checks can be performed at compile time (via macros logic implemented in header files), and result in compiler warnings; other checks take place at run time, and result in a run-time error if the check fails. Use of this macro requires compiler support, available with gcc since version 4.0." Enable this gcc check to catch buffer overflow bugs like the one in CMT test. Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest") Reported-by: David Binderman Suggested-by: David Binderman Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/Makefile | 2 +- tools/testing/selftests/resctrl/cmt_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile index d585cc1948cc..6bcee2ec91a9 100644 --- a/tools/testing/selftests/resctrl/Makefile +++ b/tools/testing/selftests/resctrl/Makefile @@ -1,5 +1,5 @@ CC = $(CROSS_COMPILE)gcc -CFLAGS = -g -Wall +CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 SRCS=$(wildcard *.c) OBJS=$(SRCS:.c=.o) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 6ffb56c6a1e2..282ba7fcf17c 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -86,7 +86,7 @@ static int check_results(struct resctrl_val_param *param, int no_of_bits) return errno; } - while (fgets(temp, 1024, fp)) { + while (fgets(temp, sizeof(temp), fp)) { char *token = strtok(temp, ":\t"); int fields = 0; From patchwork Mon May 18 22:08:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B69FC739 for ; Mon, 18 May 2020 22:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A812F20888 for ; Mon, 18 May 2020 22:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726386AbgERWOB (ORCPT ); Mon, 18 May 2020 18:14:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:46558 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbgERWOB (ORCPT ); Mon, 18 May 2020 18:14:01 -0400 IronPort-SDR: MPy1Pfu+HzVbltSSssgU5vfmyJQbPkOKaTemSSR7o+IMC2dzFx+Vpyd1V15Catxua+y2/zvXjn Bbl2TXG8qcmg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:00 -0700 IronPort-SDR: DjRAtaYLlKkurEdP+4JdGMtsfB4sCtVkB7qsz85lkYvVRqEfCKPPl+09o4rECL27bvCXYdeX5Z sglvHKhKBG7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420393" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:00 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 13/19] selftests/resctrl: Dynamically select buffer size for CAT test Date: Mon, 18 May 2020 15:08:33 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Presently, while running CAT test case, if user hasn't given any input for '-n' option, the test defaults to 5 bits to determine the buffer size that is used during test. This might become a problem on system with max_cbm mask <= 5 bits. Hence, instead of statically running always with 5 bits, change it such that the buffer size is always half of the cache size. Please note that CMT test is still hard coded with 5 bits. It will change in subsequent patches that change CMT test. Fixes: 790bf585b0ee ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest") Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/cat_test.c | 5 ++++- tools/testing/selftests/resctrl/resctrl_tests.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 5da43767b973..1bce84e23783 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -151,7 +151,10 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) /* Get max number of bits from default-cabm mask */ count_of_bits = count_bits(long_mask); - if (n < 1 || n > count_of_bits - 1) { + if (!n) + n = count_of_bits / 2; + + if (n > count_of_bits - 1) { printf("Invalid input value for no_of_bits n!\n"); printf("Please Enter value in range 1 to %d\n", count_of_bits - 1); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index f005ba2b41ec..fb7703413be7 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -57,7 +57,7 @@ void tests_cleanup(void) int main(int argc, char **argv) { bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; - int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 5; + int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 0; char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64]; char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE]; int ben_ind, ben_count; @@ -106,6 +106,10 @@ int main(int argc, char **argv) break; case 'n': no_of_bits = atoi(optarg); + if (no_of_bits <= 0) { + printf("Bail out! invalid argument for no_of_bits\n"); + return -1; + } break; case 'h': cmd_help(); @@ -188,7 +192,7 @@ int main(int argc, char **argv) printf("# Starting CMT test ...\n"); if (!has_ben) sprintf(benchmark_cmd[5], "%s", "cmt"); - res = cmt_resctrl_val(cpu_no, no_of_bits, benchmark_cmd); + res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); printf("%sok CMT: test\n", res ? "not " : ""); cmt_test_cleanup(); tests_run++; From patchwork Mon May 18 22:08:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0344F138A for ; Mon, 18 May 2020 22:14:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA53420674 for ; Mon, 18 May 2020 22:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbgERWOB (ORCPT ); Mon, 18 May 2020 18:14:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:46558 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWOB (ORCPT ); Mon, 18 May 2020 18:14:01 -0400 IronPort-SDR: uIGBovb8h3eamXCyI7FDFuiAMvcE9Xf+EEILqG7r1O2QCtvFD/O38CzopC2M2/kb0KMB7MnONl /yZsrPq5/FXg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:01 -0700 IronPort-SDR: NK4AfQISXkWshGuJ8s6hlRH/OMb0yzVxqOBWR6KGNquh1mixXlSRb2MEs58FWqQcGhg3Wpjkg8 0MAB6KMrKJzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420408" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:00 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 14/19] selftests/resctrl: Skip the test if requested resctrl feature is not supported Date: Mon, 18 May 2020 15:08:34 -0700 Message-Id: <485f834d4f1188056b306263d800bffbc0c43430.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Presently, if a requested resctrl feature is not supported by H/W or is disabled by user through kernel command line, the test suite treats it as an error and hence would print something like "not ok MBA: schemata change". But, not supporting a feature isn't a test error and hence shouldn't printed as a failure. So, instead of treating it as an error, use the SKIP directive of TAP protocol and print it as below i.e. don't report it as test failure. Sample o/p if CAT isn't supported: "ok CAT # SKIP Hardware does not support CAT or CAT is disabled" Suggested-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/cat_test.c | 3 --- tools/testing/selftests/resctrl/cmt_test.c | 3 --- tools/testing/selftests/resctrl/mba_test.c | 3 --- tools/testing/selftests/resctrl/mbm_test.c | 3 --- .../testing/selftests/resctrl/resctrl_tests.c | 19 +++++++++++++++++++ 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 1bce84e23783..a18a37ce626c 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -132,9 +132,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) if (ret) return ret; - if (!validate_resctrl_feature_request("cat")) - return -1; - /* Get default cbm mask for L3/L2 cache */ ret = get_cbm_mask(cache_type); if (ret) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 282ba7fcf17c..119ae65abec7 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -122,9 +122,6 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) if (ret) return ret; - if (!validate_resctrl_feature_request("cmt")) - return -1; - ret = get_cbm_mask("L3"); if (ret) return ret; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index ba0234d4829e..6f09d46a5424 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -156,9 +156,6 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd) remove(RESULT_FILE_NAME); - if (!validate_resctrl_feature_request("mba")) - return -1; - ret = resctrl_val(benchmark_cmd, ¶m); if (ret) return ret; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index ca610c3ebc8c..cb3113cb3b10 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -129,9 +129,6 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) remove(RESULT_FILE_NAME); - if (!validate_resctrl_feature_request("mbm")) - return -1; - ret = resctrl_val(benchmark_cmd, ¶m); if (ret) return ret; diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index fb7703413be7..d45ae004ed77 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -170,6 +170,10 @@ int main(int argc, char **argv) if (!is_amd && mbm_test) { printf("# Starting MBM BW change ...\n"); + if (!validate_resctrl_feature_request("mbm")) { + printf("ok MBM # SKIP Hardware does not support MBM or MBM is disabled\n"); + goto test_mba; + } if (!has_ben) sprintf(benchmark_cmd[5], "%s", "mba"); res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd); @@ -178,8 +182,13 @@ int main(int argc, char **argv) tests_run++; } +test_mba: if (!is_amd && mba_test) { printf("# Starting MBA Schemata change ...\n"); + if (!validate_resctrl_feature_request("mba")) { + printf("ok MBA # SKIP Hardware does not support MBA or MBA is disabled\n"); + goto test_cmt; + } if (!has_ben) sprintf(benchmark_cmd[1], "%d", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); @@ -188,8 +197,13 @@ int main(int argc, char **argv) tests_run++; } +test_cmt: if (cmt_test) { printf("# Starting CMT test ...\n"); + if (!validate_resctrl_feature_request("cmt")) { + printf("ok CMT # SKIP Hardware does not support CMT or CMT is disabled\n"); + goto test_cat; + } if (!has_ben) sprintf(benchmark_cmd[5], "%s", "cmt"); res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); @@ -198,8 +212,13 @@ int main(int argc, char **argv) tests_run++; } +test_cat: if (cat_test) { printf("# Starting CAT test ...\n"); + if (!validate_resctrl_feature_request("cat")) { + printf("ok CAT # SKIP Hardware does not support CAT or CAT is disabled\n"); + goto out; + } res = cat_perf_miss_val(cpu_no, no_of_bits, "L3"); printf("%sok CAT: test\n", res ? "not " : ""); tests_run++; From patchwork Mon May 18 22:08:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9990912 for ; Mon, 18 May 2020 22:14:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D17FF20674 for ; Mon, 18 May 2020 22:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbgERWOC (ORCPT ); Mon, 18 May 2020 18:14:02 -0400 Received: from mga01.intel.com ([192.55.52.88]:46558 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWOC (ORCPT ); Mon, 18 May 2020 18:14:02 -0400 IronPort-SDR: rQ8VZy1/OtQCLjMrUE+pU7lgYImIbDwgsAhAHeLiA3KyyCfTLFTr7ZQAISRilaywQTyy5u3OMG TuFMt1p2ENEg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:02 -0700 IronPort-SDR: tkP4nnxwCuLHusJT7MyrbdQod75s63mtfAJYKB3cRRdo5F3eeGXJGJCAHF87LVFTncmxzh6m+7 O8iLPInAgd2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420420" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:01 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 15/19] selftests/resctrl: Change return type of umount_resctrlfs() to void Date: Mon, 18 May 2020 15:08:35 -0700 Message-Id: <3c00e744acbfa67a1988638f1718cd67382a6f59.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org umount_resctrlfs() is used only during tear down path and there is nothing much to do if unmount of resctrl file system fails, so, all the callers of this function are not checking for the return value. Hence, change the return type of this function from int to void. Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrlfs.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 65ca24bf3eac..23b691001f0b 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -76,7 +76,7 @@ bool check_resctrlfs_support(void); int filter_dmesg(void); int remount_resctrlfs(bool mum_resctrlfs); int get_resource_id(int cpu_no, int *resource_id); -int umount_resctrlfs(void); +void umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); bool validate_resctrl_feature_request(const char *resctrl_val); char *fgrep(FILE *inf, const char *str); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 05956319d9ce..83cd3b026c52 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -90,15 +90,10 @@ int remount_resctrlfs(bool mum_resctrlfs) return ret; } -int umount_resctrlfs(void) +void umount_resctrlfs(void) { - if (umount(RESCTRL_PATH)) { + if (umount(RESCTRL_PATH)) perror("# Unable to umount resctrl"); - - return errno; - } - - return 0; } /* From patchwork Mon May 18 22:08:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1F78912 for ; Mon, 18 May 2020 22:14:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA2302089D for ; Mon, 18 May 2020 22:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgERWOD (ORCPT ); Mon, 18 May 2020 18:14:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:46558 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726502AbgERWOD (ORCPT ); Mon, 18 May 2020 18:14:03 -0400 IronPort-SDR: H/9UqkEJ5H4zJARwHTFqP3JNMOnlpzjiZM0XHquipkKfjlRgHDe4wKrOgLYynmRPFQMpkbWx7E lknYIKzd53kw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:02 -0700 IronPort-SDR: SWqeXuK/PeRlwSQ43+LrOWEvAGBpp/PO56Wdw7S2jk8xRfXISjz0zqaR25WbowL7OdcBqaZykz Gl0jHv36rbYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420433" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:02 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 16/19] selftests/resctrl: Umount resctrl FS only if mounted Date: Mon, 18 May 2020 15:08:36 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently, umount_resctrlfs() directly attempts to unmount resctrl FS without checking if resctrl FS is already mounted or not. But, there could be situations where-in the caller might not know if resctrl FS is already mounted or not. The caller might want to unmount resctrl FS _only_ if it's already mounted. Hence, change umount_resctrlfs() such that it now first checks if resctrl FS is mounted or not and unmounts resctrl FS only if it's already mounted and does nothing if it's not mounted. Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrlfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 83cd3b026c52..ebc8e3b4f7ff 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -92,8 +92,10 @@ int remount_resctrlfs(bool mum_resctrlfs) void umount_resctrlfs(void) { - if (umount(RESCTRL_PATH)) - perror("# Unable to umount resctrl"); + if (!find_resctrl_mount(NULL)) { + if (umount(RESCTRL_PATH)) + perror("# Unable to umount resctrl"); + } } /* From patchwork Mon May 18 22:08:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A6BF739 for ; Mon, 18 May 2020 22:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C34D208A7 for ; Mon, 18 May 2020 22:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726502AbgERWOD (ORCPT ); Mon, 18 May 2020 18:14:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:46558 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbgERWOD (ORCPT ); Mon, 18 May 2020 18:14:03 -0400 IronPort-SDR: cYbjDqWQtKvwtrnxtN9BT+zPhOX5t8AbSfj9cx7nmE15DHdWQ57RsXHvjotQtP3f29MbpBvWkS 260srG4v4EDw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:03 -0700 IronPort-SDR: 8c7bcOzsKScHuj0VCzI/7onjkTWO+S9RkyZcw5MEhjDFY0CqhigLwfUuHo5FX7ln6LSP2SPwRr kzZU1gw6v2FQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420450" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:02 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 17/19] selftests/resctrl: Unmount resctrl FS after running all tests Date: Mon, 18 May 2020 15:08:37 -0700 Message-Id: <79f565afd45e9f4a72a4b84ea80df63b78c47d21.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org validate_resctrl_feature_request() would mount resctrl FS (if not already mounted) to check if a requested feature is supported by the platform or not. There could be situations where in all the resctrl tests are skipped and hence main() function would return leaving the resctrl FS mounted. To avoid resctrl FS being mounted, unmount resctrl FS before returning. This shouldn't have any impact on the cases where all the tests might get to run (or some of the test cases might get to run and the individual tests unmount resctrl FS) because umount_resctrlfs() attempts to unmount resctrl FS only if it's mounted. Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index d45ae004ed77..a0c14555d259 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -226,6 +226,7 @@ int main(int argc, char **argv) } out: + umount_resctrlfs(); printf("1..%d\n", tests_run); return 0; From patchwork Mon May 18 22:08:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1C06912 for ; Mon, 18 May 2020 22:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3A8A206D4 for ; Mon, 18 May 2020 22:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728199AbgERWOE (ORCPT ); Mon, 18 May 2020 18:14:04 -0400 Received: from mga01.intel.com ([192.55.52.88]:46561 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbgERWOE (ORCPT ); Mon, 18 May 2020 18:14:04 -0400 IronPort-SDR: UWVDGlwfC6e9PGdROSBe2uW588irMkHv1xaePNpVCOEbTwOP2DjXNQuir91WFAdD+5WMHExmJm /LORakyhwSqg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:04 -0700 IronPort-SDR: zlT8TRYQqDh1ek0Fgf6peJgeKud80BCDWBl6BU3QbXDYoh66gwOLZUJtOhDyad0wzakElKcAoq 9PU1DLHbnBkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420465" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:03 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 18/19] selftests/resctrl: Fix incorrect parsing of iMC counters Date: Mon, 18 May 2020 15:08:38 -0700 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org iMC (Integrated Memory Controller) counters are usually at "/sys/bus/event_source/devices/" and are named as "uncore_imc_". num_of_imcs() function tries to count number of such iMC counters so that it could appropriately initialize required number of perf_attr structures that could be used to read these iMC counters. The present code assumes that all the directories under this path that start with "uncore_imc" are iMC counters. But, on some systems there could be directories named as "uncore_imc_free_running" which aren't iMC counters. Trying to read from such directory would result in "not found file" errors and MBM/MBA tests would fail. Hence, change the logic in num_of_imcs() such that it looks at the first character after "uncore_imc_" to check if it's a numerical digit or not. If it's a digit then the directory represents an iMC counter, else, skip the directory. Reported-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_val.c | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 270cd95e0026..94f3a34e21bb 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -222,7 +222,7 @@ static int read_from_imc_dir(char *imc_dir, int count) static int num_of_imcs(void) { unsigned int count = 0; - char imc_dir[512]; + char imc_dir[512], *temp; struct dirent *ep; int ret; DIR *dp; @@ -230,7 +230,25 @@ static int num_of_imcs(void) dp = opendir(DYN_PMU_PATH); if (dp) { while ((ep = readdir(dp))) { - if (strstr(ep->d_name, UNCORE_IMC)) { + temp = strstr(ep->d_name, UNCORE_IMC); + if (!temp) + continue; + + /* + * imc counters are named as "uncore_imc_", hence + * increment the pointer to point to . Note that + * sizeof(UNCORE_IMC) would count for null character as + * well and hence the last underscore character in + * uncore_imc'_' need not be counted. + */ + temp = temp + sizeof(UNCORE_IMC); + + /* + * Some directories under "DYN_PMU_PATH" could have + * names like "uncore_imc_free_running", hence, check if + * first character is a numerical digit or not. + */ + if (temp[0] >= '0' && temp[0] <= '9') { sprintf(imc_dir, "%s/%s/", DYN_PMU_PATH, ep->d_name); ret = read_from_imc_dir(imc_dir, count); From patchwork Mon May 18 22:08:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Prakhya, Sai Praneeth" X-Patchwork-Id: 11556477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49717912 for ; Mon, 18 May 2020 22:14:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4F320849 for ; Mon, 18 May 2020 22:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727900AbgERWOG (ORCPT ); Mon, 18 May 2020 18:14:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:46561 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbgERWOF (ORCPT ); Mon, 18 May 2020 18:14:05 -0400 IronPort-SDR: TuQ8jM+7vX6DM96eeZDnsYG4wkDgz1sphHWkAlO5DMR2ngQur/Mn/7D+W/Fg4TrZa2TifPBzyO P7EZZ6sOdbEw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2020 15:14:04 -0700 IronPort-SDR: 4F1jBJOvWspkwsl6o0wHoHsf4buKogWvuR3qEHR+A5jDdP/umr2EedjLmzfO/v7d7P7EsPPyni JaXbIFHaf3kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,407,1583222400"; d="scan'208";a="411420476" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by orsmga004.jf.intel.com with ESMTP; 18 May 2020 15:14:04 -0700 From: Sai Praneeth Prakhya To: shuah@kernel.org, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel, dan.carpenter@oracle.com, dcb314@hotmail.com, Sai Praneeth Prakhya Subject: [PATCH V2 19/19] selftests/resctrl: Fix checking for < 0 for unsigned values Date: Mon, 18 May 2020 15:08:39 -0700 Message-Id: <75653a26f64e19c5b87827b1cdfd7b8c95a3de31.1589835155.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Dan reported that he noticed following static checker warnings tools/testing/selftests/resctrl/resctrl_val.c:545 measure_vals() warn: 'bw_imc' unsigned <= 0 tools/testing/selftests/resctrl/resctrl_val.c:549 measure_vals() warn: 'bw_resc_end' unsigned <= 0 These warnings are reported because 1. measure_vals() declares 'bw_imc' and 'bw_resc_end' as unsigned long variables 2. Return value of get_mem_bw_imc() and get_mem_bw_resctrl() are assigned to 'bw_imc' and 'bw_resc_end' respectively 3. The return values are checked for <=0 to see if the calls were successful or not Checking for < 0 for an unsigned value doesn't make any sense. So, to fix this issue, change the implementation of get_mem_bw_imc() and get_mem_bw_resctrl() such that they now accept reference to a variable and set the variable appropriately upon success and return 0, else return <0 on error. Fixes: 7f4d257e3a2a: "selftests/resctrl: Add callback to start a benchmark" Reported-by: Dan Carpenter Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrl_val.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 94f3a34e21bb..003457b16ce7 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -300,9 +300,9 @@ static int initialize_mem_bw_imc(void) * 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. + * Return: = 0 on success. < 0 on failure. */ -static float get_mem_bw_imc(int cpu_no, char *bw_report) +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; @@ -374,12 +374,13 @@ static float get_mem_bw_imc(int cpu_no, char *bw_report) } if (strcmp(bw_report, "reads") == 0) - return reads; + *bw_imc = reads; if (strcmp(bw_report, "writes") == 0) - return writes; + *bw_imc = writes; - return (reads + writes); + *bw_imc = reads + writes; + return 0; } void set_mbm_path(const char *ctrlgrp, const char *mongrp, int resource_id) @@ -438,9 +439,8 @@ static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp, * 1. If con_mon grp is given, then read from it * 2. If con_mon grp is not given, then read from root con_mon grp */ -static unsigned long get_mem_bw_resctrl(void) +static int get_mem_bw_resctrl(unsigned long *mbm_total) { - unsigned long mbm_total = 0; FILE *fp; fp = fopen(mbm_total_path, "r"); @@ -449,7 +449,7 @@ static unsigned long get_mem_bw_resctrl(void) return -1; } - if (fscanf(fp, "%lu", &mbm_total) <= 0) { + if (fscanf(fp, "%lu", mbm_total) <= 0) { perror("Could not get mbm local bytes"); fclose(fp); @@ -457,7 +457,7 @@ static unsigned long get_mem_bw_resctrl(void) } fclose(fp); - return mbm_total; + return 0; } pid_t bm_pid, ppid; @@ -549,7 +549,8 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, static int measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start) { - unsigned long bw_imc, bw_resc, bw_resc_end; + unsigned long bw_resc, bw_resc_end; + float bw_imc; int ret; /* @@ -559,13 +560,13 @@ measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start) * Compare the two values to validate resctrl value. * It takes 1sec to measure the data. */ - bw_imc = get_mem_bw_imc(param->cpu_no, param->bw_report); - if (bw_imc <= 0) - return bw_imc; + ret = get_mem_bw_imc(param->cpu_no, param->bw_report, &bw_imc); + if (ret < 0) + return ret; - bw_resc_end = get_mem_bw_resctrl(); - if (bw_resc_end <= 0) - return bw_resc_end; + 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);