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: Sai Praneeth Prakhya X-Patchwork-Id: 208493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D41E5C433E2 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 AF58920842 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: Sai Praneeth Prakhya X-Patchwork-Id: 208494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C812C433E1 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 EC0F520842 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:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A7BC433E5 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 7A64720674 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:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 072FBC433E1 for ; Mon, 18 May 2020 22:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDFD4206D4 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:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208490 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B05CC433E3 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 4C23220878 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:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E745BC433E0 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 C98B120878 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:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01548C433E8 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 D1C4320888 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: Sai Praneeth Prakhya X-Patchwork-Id: 208487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C621C433E1 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 DA10420674 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:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Praneeth Prakhya X-Patchwork-Id: 208486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 081BCC433E4 for ; Mon, 18 May 2020 22:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E393720674 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);