From patchwork Mon Jul 17 13:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B896EB64DC for ; Mon, 17 Jul 2023 13:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbjGQNP3 (ORCPT ); Mon, 17 Jul 2023 09:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjGQNPY (ORCPT ); Mon, 17 Jul 2023 09:15:24 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7682194; Mon, 17 Jul 2023 06:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599722; x=1721135722; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lK+fNz+KVwzS2wg2GQh+MHm6HXuFlGgYU4nvO5M9knQ=; b=QaaVK/M+R0GHK8xCAJhedWnuyYYykQE90iQnF/ufmxjJsjk8ZceNx9cL ZhwVrVC7fKcaPYSCk5qXb8n7SuQWbq1W2gux+xjIrbjYMAJ6YLQDQPr9z sDuN8aAgxU1e5qiQSr3f0M7gas3sXiAXrs/jUPuT9yZUY3JcE1Icj46Hd sqLdRNV23H6j/fXJbzsqdNQKuo6CmLpaZyvpk/Ae8c/sNt86orJtJt7si UfHAkB/QFoAueLtXtpkPRXb/FPshgCWjkPnz0i28zWlWtzQF+u9IGokue EGQQTENlT4hl3FqnosPpK45WKwGGZ5DoC4MKr1ya0znORHnevCsdnczP+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368568812" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368568812" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793246686" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793246686" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:19 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , Babu Moger , Sai Praneeth Prakhya , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 01/19] selftests/resctrl: Add resctrl.h into build deps Date: Mon, 17 Jul 2023 16:14:49 +0300 Message-Id: <20230717131507.32420-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Makefile only lists *.c as build dependencies for the resctrl_tests executable which excludes resctrl.h. Add *.h to wildcard() to include resctrl.h. Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file system operations and data") Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile index 73d53257df42..5073dbc96125 100644 --- a/tools/testing/selftests/resctrl/Makefile +++ b/tools/testing/selftests/resctrl/Makefile @@ -7,4 +7,4 @@ TEST_GEN_PROGS := resctrl_tests include ../lib.mk -$(OUTPUT)/resctrl_tests: $(wildcard *.c) +$(OUTPUT)/resctrl_tests: $(wildcard *.[ch]) From patchwork Mon Jul 17 13:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2283EB64DC for ; Mon, 17 Jul 2023 13:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231465AbjGQNPt (ORCPT ); Mon, 17 Jul 2023 09:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbjGQNPl (ORCPT ); Mon, 17 Jul 2023 09:15:41 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42CF794; Mon, 17 Jul 2023 06:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599730; x=1721135730; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4NHwxeGZmRaqtiPuIGz3C8d+Am2s2/WThr8AS9rsrtY=; b=SWEJwu+0lzgiGqZbmXiqyqgQIxNKyOj13PXBh+yWQWX3fhWkBZajB/ni fhk4qeD3r6Ozs4CZ7U/CmjMGJu38UfJdECFmGZvfltJ2/NKxUUllY3jKO XtQk0fBJIA8aa2xBCqXA530+d4rO9RfzTOXWVgaVqAXUxTK/oQ8cMp7LX 6lA8X1orUOw0jwdDwGJbyzVGhR8ENDr+gfL/VH+DmnZha1bQfqir7JpC6 qwMX4sGCcDsa2ECiJPgPun8HHu13bwqrC1ZbJiuUTDNVwpRDI5Qfoaoed 2ovkkWfUmMsMd4aChkPgUQkXarXuFxm8SjHOtFqtnGkY/P8Wp77eetBZB g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368568843" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368568843" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793246727" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793246727" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:27 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , Babu Moger , Sai Praneeth Prakhya , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 03/19] selftests/resctrl: Unmount resctrl FS if child fails to run benchmark Date: Mon, 17 Jul 2023 16:14:51 +0300 Message-Id: <20230717131507.32420-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org A child calls PARENT_EXIT() when it fails to run a benchmark to kill the parent process. PARENT_EXIT() lacks unmount for the resctrl FS and the parent won't be there to unmount it either after it gets killed. Add the resctrl FS unmount also to PARENT_EXIT(). Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file system operations and data") Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/resctrl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 87e39456dee0..f455f0b7e314 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -43,6 +43,7 @@ do { \ perror(err_msg); \ kill(ppid, SIGKILL); \ + umount_resctrlfs(); \ exit(EXIT_FAILURE); \ } while (0) From patchwork Mon Jul 17 13:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DA19EB64DC for ; Mon, 17 Jul 2023 13:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjGQNQG (ORCPT ); Mon, 17 Jul 2023 09:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbjGQNPu (ORCPT ); Mon, 17 Jul 2023 09:15:50 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F4F21985; Mon, 17 Jul 2023 06:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599737; x=1721135737; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gxILP+jHMTJazW2ff4rfv0rjrW3z2H5FuwKbGzXQHQg=; b=XEfhWMWWsFteQpffFEDpLJu6QfSvcVj7wJA06wZh2lO2c25E2cgblJJg R8MgizwCR4k6LkkN+Aug5noof5yyJQi9+rsC9hL9gO697wqf7H9VRZazQ PsXaZ0uuQ64B4jbWzrhjZxEoOlRsXcCwwe93n9N64w0TeJG1VXGPKClL8 4Q6T4zSvKjZBUxuRVvcdeco12rHIcO9Bd8107YP0KE+Nd+hViRY29GGM0 KHkfjadHcM0urjv86VGfsByT6IpNQ3b0vcMYn+Mfp8gXt0jjo2EuF2bow BdHDTdG4VnCQIyNci6nyygV1jCkL7YllI3J4mbLOkem2eVA+pVglSkuUy w==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368568868" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368568868" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793246758" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793246758" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:34 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 05/19] selftests/resctrl: Unmount resctrl FS before starting the first test Date: Mon, 17 Jul 2023 16:14:53 +0300 Message-Id: <20230717131507.32420-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Resctrl FS mount/remount/umount code is hard to track. Better approach is to use mount/umount pair for each test but that assumes resctrl FS is not mounted beforehand. Change umount_resctrlfs() so that it can unmount resctrl FS from any path, and enable further simplifications into mount/remount/umount logic by unmounting resctrl FS at the start if a pre-existing mountpoint is found. Suggested-by: Reinette Chatre Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_tests.c | 3 +++ tools/testing/selftests/resctrl/resctrlfs.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 9b9751206e1c..61c3882a26c8 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -250,6 +250,9 @@ int main(int argc, char **argv) if (!check_resctrlfs_support()) return ksft_exit_skip("resctrl FS does not exist. Enable X86_CPU_RESCTRL config option.\n"); + if (umount_resctrlfs()) + return ksft_exit_skip("resctrl FS unmount failed.\n"); + filter_dmesg(); ksft_set_plan(tests ? : 4); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index fb00245dee92..cf0c8dd34b8b 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -82,10 +82,16 @@ int remount_resctrlfs(bool mum_resctrlfs) int umount_resctrlfs(void) { - if (find_resctrl_mount(NULL)) + char mountpoint[256]; + int ret; + + ret = find_resctrl_mount(mountpoint); + if (ret == -ENOENT) return 0; + if (ret) + return ret; - if (umount(RESCTRL_PATH)) { + if (umount(mountpoint)) { perror("# Unable to umount resctrl"); return errno; From patchwork Mon Jul 17 13:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3362EB64DC for ; Mon, 17 Jul 2023 13:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbjGQNQZ (ORCPT ); Mon, 17 Jul 2023 09:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbjGQNP5 (ORCPT ); Mon, 17 Jul 2023 09:15:57 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47AB1BDA; Mon, 17 Jul 2023 06:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599745; x=1721135745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/1/VJsytpG9ab8tNQhkRW6NqEkFFS16dN1lelPWiwFU=; b=CJjf36mL4LGZBHkCaBvLOVAEjhPOzv2h4xnLwBMn//Yezcd7hOq/P5/z JkdTwaHyY6QngVzRO0BwrmsWRiBXe/InwAt32xW9HVstfaPQZJMNzJ7FV 7dH7N4wNBSOKPqoEHnZGvFGV+0kkMaAWyiSUegV7hKlOCx3dg0Qs5yqR2 grQrN7gdfvRg8gvMXbEtExnHHDVc94146/U644fchBPt4XWwg2+FIqTiq x+DbVM3f0YcA5qytyCfwevU3HqawJA2HbeCRtYGttRN7jGDgWCzeHT9ec O5AvnyuLtNfmBSiBibUp2XtxXKn4WwUMQVnUyrhfKoLwfWSvTjtkZ5Hg6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368568907" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368568907" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793246780" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793246780" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:41 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 07/19] selftests/resctrl: Refactor remount_resctrl(bool mum_resctrlfs) to mount_resctrl() Date: Mon, 17 Jul 2023 16:14:55 +0300 Message-Id: <20230717131507.32420-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Mount/umount of the resctrl FS is now paired nicely per test. Rename remount_resctrl(bool mum_resctrlfs) to mount_resctrl(). Make it unconditionally try to mount the resctrl FS and return error if resctrl FS was mounted already. While at it, group the mount/umount prototypes in the header. Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl.h | 2 +- .../testing/selftests/resctrl/resctrl_tests.c | 8 +++---- tools/testing/selftests/resctrl/resctrlfs.c | 23 ++++++------------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index f455f0b7e314..23af3fb73cb4 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -85,8 +85,8 @@ extern char llc_occup_path[1024]; int get_vendor(void); 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 mount_resctrlfs(void); int umount_resctrlfs(void); int validate_bw_report_request(char *bw_report); bool validate_resctrl_feature_request(const char *resctrl_val); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 6bf4ead74496..0363c4b607d2 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBM BW change ...\n"); - res = remount_resctrlfs(true); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -106,7 +106,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, ksft_print_msg("Starting MBA Schemata change ...\n"); - res = remount_resctrlfs(true); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -132,7 +132,7 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) ksft_print_msg("Starting CMT test ...\n"); - res = remount_resctrlfs(true); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; @@ -160,7 +160,7 @@ static void run_cat_test(int cpu_no, int no_of_bits) ksft_print_msg("Starting CAT test ...\n"); - res = remount_resctrlfs(true); + res = mount_resctrlfs(); if (res) { ksft_exit_fail_msg("Failed to mount resctrl FS\n"); return; diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index edc3f92b11b1..c45666942439 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -48,29 +48,20 @@ static int find_resctrl_mount(char *buffer) } /* - * remount_resctrlfs - Remount resctrl FS at /sys/fs/resctrl - * @mum_resctrlfs: Should the resctrl FS be remounted? + * mount_resctrlfs - Mount resctrl FS at /sys/fs/resctrl * - * If not mounted, mount it. - * If mounted and mum_resctrlfs then remount resctrl FS. - * If mounted and !mum_resctrlfs then noop + * Mounts resctrl FS. Fails if resctrl FS is already mounted to avoid + * pre-existing settings interfering with the test results. * * Return: 0 on success, non-zero on failure */ -int remount_resctrlfs(bool mum_resctrlfs) +int mount_resctrlfs(void) { - char mountpoint[256]; int ret; - ret = find_resctrl_mount(mountpoint); - if (ret) - strcpy(mountpoint, RESCTRL_PATH); - - if (!ret && mum_resctrlfs && umount(mountpoint)) - ksft_print_msg("Fail: unmounting \"%s\"\n", mountpoint); - - if (!ret && !mum_resctrlfs) - return 0; + ret = find_resctrl_mount(NULL); + if (ret != -ENOENT) + return -1; ksft_print_msg("Mounting resctrl to \"%s\"\n", RESCTRL_PATH); ret = mount("resctrl", RESCTRL_PATH, "resctrl", 0, NULL); From patchwork Mon Jul 17 13:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91EAAC0015E for ; Mon, 17 Jul 2023 13:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbjGQNQz (ORCPT ); Mon, 17 Jul 2023 09:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231514AbjGQNQf (ORCPT ); Mon, 17 Jul 2023 09:16:35 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 517CF1988; Mon, 17 Jul 2023 06:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599762; x=1721135762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1ibRTFaDJ2wmg9eoX7wGDRMPJaZSfG0esqmUVqxZhP8=; b=QjybEhqIcfPz17xJOneOxrGQwfx8YHgu7ErxxakXmamsTOMLYPZJDtkG Ni5FaTt8cFbxVr3hvWDgrEgrTmJo4kqhu3kjK56hORLTh8VBiWiUKUwm4 zpWdKHX6XGNejOLGgETz6O7/63VtvnNazhzEaQrjCk4/66r6nXGWLfb7f EKE9Lpq1fWjukkF7PfEPYSiMGOY/QH4gwsaaFIPbHAMBD77yV5Oz8Mp0k bUxzqpKzgTYG7b3ltwbclYhKHGf7Tdkac+n/R5aioZicpoPgZCnxbOtfF sC2bC20pVjHz1PfhlsjwB5I0oqvCQia5pCdsWqSirPARuKWZNUBmc9v+U g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569002" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569002" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793246923" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793246923" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:15:59 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 09/19] selftests/resctrl: Convert span to size_t Date: Mon, 17 Jul 2023 16:14:57 +0300 Message-Id: <20230717131507.32420-10-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Span is defined either as unsigned long or int. Consistently use size_t everywhere for span as it refers to size of the memory block. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 4 ++-- tools/testing/selftests/resctrl/cmt_test.c | 2 +- tools/testing/selftests/resctrl/fill_buf.c | 8 ++++---- tools/testing/selftests/resctrl/mbm_test.c | 8 ++++---- tools/testing/selftests/resctrl/resctrl.h | 10 +++++----- tools/testing/selftests/resctrl/resctrl_tests.c | 11 ++++++----- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 289b619116fe..53df66814cd6 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -286,7 +286,7 @@ int cat_val(struct resctrl_val_param *param) * Return: 0 on success. non-zero on failure. */ int show_cache_info(unsigned long sum_llc_val, int no_of_bits, - unsigned long cache_span, unsigned long max_diff, + size_t cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, bool platform, bool cmt) { @@ -308,7 +308,7 @@ int show_cache_info(unsigned long sum_llc_val, int no_of_bits, ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent)); ksft_print_msg("Number of bits: %d\n", no_of_bits); ksft_print_msg("Average LLC val: %lu\n", avg_llc_val); - ksft_print_msg("Cache span (%s): %lu\n", cmt ? "bytes" : "lines", + ksft_print_msg("Cache span (%s): %zu\n", cmt ? "bytes" : "lines", cache_span); return ret; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index d31e28416bb7..beb0f0687c6d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -121,7 +121,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) }; if (strcmp(benchmark_cmd[0], "fill_buf") == 0) - sprintf(benchmark_cmd[1], "%lu", param.span); + sprintf(benchmark_cmd[1], "%zu", param.span); remove(RESULT_FILE_NAME); diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 3b328c844896..785cbd8d0148 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -139,7 +139,7 @@ static int fill_cache_write(unsigned char *start_ptr, unsigned char *end_ptr, } static int -fill_cache(unsigned long long buf_size, int malloc_and_init, int memflush, +fill_cache(size_t buf_size, int malloc_and_init, int memflush, int op, char *resctrl_val) { unsigned char *start_ptr, *end_ptr; @@ -188,10 +188,10 @@ fill_cache(unsigned long long buf_size, int malloc_and_init, int memflush, return 0; } -int run_fill_buf(unsigned long span, int malloc_and_init_memory, - int memflush, int op, char *resctrl_val) +int run_fill_buf(size_t span, int malloc_and_init_memory, int memflush, int op, + char *resctrl_val) { - unsigned long long cache_size = span; + size_t cache_size = span; int ret; ret = fill_cache(cache_size, malloc_and_init_memory, memflush, op, diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 24326cb7bc21..fd116158d008 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -15,7 +15,7 @@ #define NUM_OF_RUNS 5 static int -show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) +show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, size_t span) { unsigned long avg_bw_imc = 0, avg_bw_resc = 0; unsigned long sum_bw_imc = 0, sum_bw_resc = 0; @@ -40,14 +40,14 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) ksft_print_msg("%s Check MBM diff within %d%%\n", ret ? "Fail:" : "Pass:", MAX_DIFF_PERCENT); ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per); - ksft_print_msg("Span (MB): %d\n", span); + ksft_print_msg("Span (MB): %zu\n", span); ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc); ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc); return ret; } -static int check_results(int span) +static int check_results(size_t span) { unsigned long bw_imc[NUM_OF_RUNS], bw_resc[NUM_OF_RUNS]; char temp[1024], *token_array[8]; @@ -115,7 +115,7 @@ void mbm_test_cleanup(void) remove(RESULT_FILE_NAME); } -int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) +int mbm_bw_change(size_t span, int cpu_no, char *bw_report, char **benchmark_cmd) { struct resctrl_val_param param = { .resctrl_val = MBM_STR, diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 99678d688a80..52068ceea956 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -63,7 +63,7 @@ struct resctrl_val_param { char ctrlgrp[64]; char mongrp[64]; int cpu_no; - unsigned long span; + size_t span; char filename[64]; char *bw_report; unsigned long mask; @@ -97,10 +97,10 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); -int run_fill_buf(unsigned long span, int malloc_and_init_memory, int memflush, - int op, char *resctrl_va); +int run_fill_buf(size_t span, int malloc_and_init_memory, int memflush, int op, + char *resctrl_va); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); -int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd); +int mbm_bw_change(size_t span, int cpu_no, char *bw_report, char **benchmark_cmd); void tests_cleanup(void); void mbm_test_cleanup(void); int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd); @@ -119,7 +119,7 @@ void cmt_test_cleanup(void); int get_core_sibling(int cpu_no); int measure_cache_vals(struct resctrl_val_param *param, int bm_pid); int show_cache_info(unsigned long sum_llc_val, int no_of_bits, - unsigned long cache_span, unsigned long max_diff, + size_t cache_span, unsigned long max_diff, unsigned long max_diff_percent, unsigned long num_of_runs, bool platform, bool cmt); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 0363c4b607d2..bae8f205fc3f 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -70,7 +70,7 @@ void tests_cleanup(void) cat_test_cleanup(); } -static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, +static void run_mbm_test(bool has_ben, char **benchmark_cmd, size_t span, int cpu_no, char *bw_report) { int res; @@ -99,7 +99,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, umount_resctrlfs(); } -static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, +static void run_mba_test(bool has_ben, char **benchmark_cmd, size_t span, int cpu_no, char *bw_report) { int res; @@ -118,7 +118,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, } if (!has_ben) - sprintf(benchmark_cmd[1], "%d", span); + sprintf(benchmark_cmd[1], "%zu", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); @@ -181,11 +181,12 @@ static void run_cat_test(int cpu_no, int no_of_bits) int main(int argc, char **argv) { bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; - int 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 c, cpu_no = 1, argc_new = argc, i, no_of_bits = 0; int ben_ind, ben_count, tests = 0; bool cat_test = true; + size_t span = 250; for (i = 0; i < argc; i++) { if (strcmp(argv[i], "-b") == 0) { @@ -273,7 +274,7 @@ int main(int argc, char **argv) benchmark_cmd[i] = benchmark_cmd_area[i]; strcpy(benchmark_cmd[0], "fill_buf"); - sprintf(benchmark_cmd[1], "%d", span); + sprintf(benchmark_cmd[1], "%zu", span); strcpy(benchmark_cmd[2], "1"); strcpy(benchmark_cmd[3], "1"); strcpy(benchmark_cmd[4], "0"); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index c45666942439..14fb85a7e526 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -303,7 +303,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no) void run_benchmark(int signum, siginfo_t *info, void *ucontext) { int operation, ret, malloc_and_init_memory, memflush; - unsigned long span, buffer_span; + size_t span, buffer_span; char **benchmark_cmd; char resctrl_val[64]; FILE *fp; From patchwork Mon Jul 17 13:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCF74C001B0 for ; Mon, 17 Jul 2023 13:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbjGQNRS (ORCPT ); Mon, 17 Jul 2023 09:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjGQNRD (ORCPT ); Mon, 17 Jul 2023 09:17:03 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 119BE13E; Mon, 17 Jul 2023 06:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599784; x=1721135784; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aK7jbebXRGb8FKB1MW4zoqRf8HpNU5bNcvdF3+o9RRw=; b=LIEiirHIdPsb+tXi8jtHvvqBxWIhrHpeBpM5jfaMuFBXxVrmAf2dKDLr L7mvoy520Diq83GH2duwbYc2k0Eg/DzaiLC2m3kOCgd1eG1g2qeoKoVGl AQ7gtyLN1yfT77HhIYxxDnp8lBvax5kLwc+JVGa4g4niIIMtkURrCfAKS 6zbgz6qS0xsMgrzPQOs5CaJNJqWmLPySfEI0NrVS9Qbs0wGVmNr8NhwU9 rM0u4UXJwHgWmZ1UY1Oyej7aEK27QFNjhSmRUlJCgpJ8+j2kbdvmgdGWs yc6YzK1MQ+yv4NSLSiC1NvqJlKMtARI06aSYHasJkDD9qXi8OujRwuCPC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569089" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569089" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793247073" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793247073" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:21 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 11/19] selftests/resctrl: Remove duplicated preparation for span arg Date: Mon, 17 Jul 2023 16:14:59 +0300 Message-Id: <20230717131507.32420-12-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When no benchmark_cmd is given, benchmark_cmd[1] is set to span in main(). There's no need to do it again in run_mba_test(). Remove the duplicated preparation for span argument into benchmark_cmd[1] from run_mba_test(). After this, the has_ben and span arguments to run_mba_test() can be removed. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/resctrl_tests.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 3a65dacb441e..bf0cadab36b0 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -99,8 +99,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, size_t span, umount_resctrlfs(); } -static void run_mba_test(bool has_ben, char **benchmark_cmd, size_t span, - int cpu_no, char *bw_report) +static void run_mba_test(char **benchmark_cmd, int cpu_no, char *bw_report) { int res; @@ -117,8 +116,6 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, size_t span, goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[1], "%zu", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); @@ -299,7 +296,7 @@ int main(int argc, char **argv) run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); if (mba_test) - run_mba_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); + run_mba_test(benchmark_cmd, cpu_no, bw_report); if (cmt_test) run_cmt_test(has_ben, benchmark_cmd, cpu_no); From patchwork Mon Jul 17 13:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 890ACEB64DC for ; Mon, 17 Jul 2023 13:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbjGQNRm (ORCPT ); Mon, 17 Jul 2023 09:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjGQNRR (ORCPT ); Mon, 17 Jul 2023 09:17:17 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423CE1FF1; Mon, 17 Jul 2023 06:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599799; x=1721135799; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ogx0qj3LX5irrJwshgW9nYSxrngHHmC2qLUGm2TgldA=; b=JulPL2T+SUUE6e1xynFRFAa2ThcMiHgaEP9W+8rkxOcic2n7iV5REJp2 REzb2VOU5yJ4dN2v5or/sgGN0B3EEcZTr/Mzas0iVWcv545GfrKNARnEN C5Lwzm0r9a0jkSeVaDgnyaW10eCaplrr8LvZgRG3Nir2uVnurNx9p+42C QAPE5MI3t0eMJKiBHMB72snnD5Zp2OfZFv5AKa7zpCAwDy1ECefiF0A2t xlRPXlyKm4mGk/AK3kCqdMLzhKtHRKXM32cY+3vUfP0AY3J4571/pHnfc uzefV3nZOx4HnqKtv1UlxX/avAU24ZzlVGdgwHkqjVi8LEAH5FzyOpNEq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569115" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569115" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793247103" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793247103" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:28 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 13/19] selftests/resctrl: Remove unnecessary startptr global from fill_buf Date: Mon, 17 Jul 2023 16:15:01 +0300 Message-Id: <20230717131507.32420-14-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org fill_buf stores buffer pointer into global variable startptr that is only used in fill_cache(). Remove startptr as global variable, the local variable in fill_cache() is enough to keep the pointer. Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/fill_buf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index d8f5505eb9e6..a5ec9c82a960 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -22,8 +22,6 @@ #define PAGE_SIZE (4 * 1024) #define MB (1024 * 1024) -static unsigned char *startptr; - static void sb(void) { #if defined(__i386) || defined(__x86_64) @@ -147,7 +145,6 @@ static int fill_cache(size_t buf_size, int memflush, int op, char *resctrl_val) if (!start_ptr) return -1; - startptr = start_ptr; end_ptr = start_ptr + buf_size; /* Flush the memory before using to avoid "cache hot pages" effect */ @@ -159,7 +156,7 @@ static int fill_cache(size_t buf_size, int memflush, int op, char *resctrl_val) else ret = fill_cache_write(start_ptr, end_ptr, resctrl_val); - free(startptr); + free(start_ptr); if (ret) { printf("\n Error in fill cache read/write...\n"); From patchwork Mon Jul 17 13:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E295C001B0 for ; Mon, 17 Jul 2023 13:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbjGQNSK (ORCPT ); Mon, 17 Jul 2023 09:18:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbjGQNRd (ORCPT ); Mon, 17 Jul 2023 09:17:33 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13DB35A4; Mon, 17 Jul 2023 06:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599809; x=1721135809; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eM7kiPjmTLQio1i2Y+4XMgthvj6f/Qoaha85fysez6A=; b=hnmYm43gcfZ/+CdyaXr0bph6AGwH/LZ+4cPcffC1aoTXPZkjxcW65L29 2Nl2kgT55IWm5Gj6ByHwZNF4qR8XfqatJEjdxJUI9hfDwDXbSxfTviwdW ri0fXLtWJ4MLD7iiSEw8ChwZmbH2c1TFk8+i7DaqdzjqtL7QWSX1p4dIL 2gMIJMdTt2IajSezKg1VVsSUnZmi3bF0Tc6SrnWWnEfucCr5XvWY1ocpy nFR/ONdmUFd4CVzmowNWVsFu5oAjPo3Q2ZZdS2/ZCTVYsUKJAyQK/rhYu CTtI3gPWj2s4zj53G8ZyFu4Alfg1WS1iheqOuH+oH5mifiOWSgvOTzl3R A==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569149" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569149" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793247156" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793247156" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:35 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 15/19] selftests/resctrl: Don't pass test name to fill_buf Date: Mon, 17 Jul 2023 16:15:03 +0300 Message-Id: <20230717131507.32420-16-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Test name is passed to fill_buf functions so that they can loop around buffer only once. This is required for CAT test case. To loop around buffer only once, caller doesn't need to let fill_buf know which test case it is. Instead, pass a boolean argument 'once' which makes fill_buf more generic. As run_benchmark() no longer needs to pass the test name to run_fill_buf(), a few test running functions can be simplified to not write the test name into the default benchmark_cmd. The has_ben argument can also be removed now from those test running functions. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cache.c | 3 +-- tools/testing/selftests/resctrl/fill_buf.c | 20 +++++++++---------- tools/testing/selftests/resctrl/resctrl.h | 2 +- .../testing/selftests/resctrl/resctrl_tests.c | 14 +++++-------- tools/testing/selftests/resctrl/resctrlfs.c | 11 +++++++--- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 63b551c44f1d..8ae9ac150fd3 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -247,8 +247,7 @@ int cat_val(struct resctrl_val_param *param) if (ret) break; - if (run_fill_buf(param->span, memflush, operation, - resctrl_val)) { + if (run_fill_buf(param->span, memflush, operation, true)) { fprintf(stderr, "Error-running fill buffer\n"); ret = -1; goto pe_close; diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 5f16c4f5dfbf..0d425f26583a 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -101,15 +101,14 @@ static void fill_one_span_write(unsigned char *buf, size_t buf_size) } } -static int fill_cache_read(unsigned char *buf, size_t buf_size, - char *resctrl_val) +static int fill_cache_read(unsigned char *buf, size_t buf_size, bool once) { int ret = 0; FILE *fp; while (1) { ret = fill_one_span_read(buf, buf_size); - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) + if (once) break; } @@ -125,19 +124,18 @@ static int fill_cache_read(unsigned char *buf, size_t buf_size, return 0; } -static int fill_cache_write(unsigned char *buf, size_t buf_size, - char *resctrl_val) +static int fill_cache_write(unsigned char *buf, size_t buf_size, bool once) { while (1) { fill_one_span_write(buf, buf_size); - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) + if (once) break; } return 0; } -static int fill_cache(size_t buf_size, int memflush, int op, char *resctrl_val) +static int fill_cache(size_t buf_size, int memflush, int op, bool once) { unsigned char *buf; int ret; @@ -151,9 +149,9 @@ static int fill_cache(size_t buf_size, int memflush, int op, char *resctrl_val) mem_flush(buf, buf_size); if (op == 0) - ret = fill_cache_read(buf, buf_size, resctrl_val); + ret = fill_cache_read(buf, buf_size, once); else - ret = fill_cache_write(buf, buf_size, resctrl_val); + ret = fill_cache_write(buf, buf_size, once); free(buf); @@ -166,12 +164,12 @@ static int fill_cache(size_t buf_size, int memflush, int op, char *resctrl_val) return 0; } -int run_fill_buf(size_t span, int memflush, int op, char *resctrl_val) +int run_fill_buf(size_t span, int memflush, int op, bool once) { size_t cache_size = span; int ret; - ret = fill_cache(cache_size, memflush, op, resctrl_val); + ret = fill_cache(cache_size, memflush, op, once); if (ret) { printf("\n Error in fill cache\n"); return -1; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 3054cc4ef0e3..645ad407bd8d 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -97,7 +97,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp, char *resctrl_val); int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags); -int run_fill_buf(size_t span, int memflush, int op, char *resctrl_val); +int run_fill_buf(size_t span, int memflush, int op, bool once); int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param); int mbm_bw_change(size_t span, int cpu_no, char *bw_report, char **benchmark_cmd); void tests_cleanup(void); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 125ed0ca11e3..d511daeb6851 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -70,7 +70,7 @@ void tests_cleanup(void) cat_test_cleanup(); } -static void run_mbm_test(bool has_ben, char **benchmark_cmd, size_t span, +static void run_mbm_test(char **benchmark_cmd, size_t span, int cpu_no, char *bw_report) { int res; @@ -88,8 +88,6 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, size_t span, goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[4], "%s", MBA_STR); res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBM: bw change\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -123,7 +121,7 @@ static void run_mba_test(char **benchmark_cmd, int cpu_no, char *bw_report) umount_resctrlfs(); } -static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) +static void run_cmt_test(char **benchmark_cmd, int cpu_no) { int res; @@ -140,8 +138,6 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) goto umount; } - if (!has_ben) - sprintf(benchmark_cmd[4], "%s", CMT_STR); res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); ksft_test_result(!res, "CMT: test\n"); if ((get_vendor() == ARCH_INTEL) && res) @@ -274,7 +270,7 @@ int main(int argc, char **argv) sprintf(benchmark_cmd[1], "%zu", span); strcpy(benchmark_cmd[2], "1"); strcpy(benchmark_cmd[3], "0"); - strcpy(benchmark_cmd[4], ""); + strcpy(benchmark_cmd[4], "false"); benchmark_cmd[5] = NULL; } @@ -292,13 +288,13 @@ int main(int argc, char **argv) ksft_set_plan(tests ? : 4); if (mbm_test) - run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report); + run_mbm_test(benchmark_cmd, span, cpu_no, bw_report); if (mba_test) run_mba_test(benchmark_cmd, cpu_no, bw_report); if (cmt_test) - run_cmt_test(has_ben, benchmark_cmd, cpu_no); + run_cmt_test(benchmark_cmd, cpu_no); if (cat_test) run_cat_test(cpu_no, no_of_bits); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 8a66445079f8..bd36ee206602 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -304,8 +304,8 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) { int operation, ret, memflush; char **benchmark_cmd; - char resctrl_val[64]; size_t span; + bool once; FILE *fp; benchmark_cmd = info->si_ptr; @@ -323,9 +323,14 @@ void run_benchmark(int signum, siginfo_t *info, void *ucontext) span = strtoul(benchmark_cmd[1], NULL, 10); memflush = atoi(benchmark_cmd[2]); operation = atoi(benchmark_cmd[3]); - sprintf(resctrl_val, "%s", benchmark_cmd[4]); + if (!strcmp(benchmark_cmd[4], "true")) + once = true; + else if (!strcmp(benchmark_cmd[4], "false")) + once = false; + else + PARENT_EXIT("Invalid once parameter"); - if (run_fill_buf(span, memflush, operation, resctrl_val)) + if (run_fill_buf(span, memflush, operation, once)) fprintf(stderr, "Error in running fill buffer\n"); } else { /* Execute specified benchmark */ From patchwork Mon Jul 17 13:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 771E0C001B0 for ; Mon, 17 Jul 2023 13:18:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231250AbjGQNSi (ORCPT ); Mon, 17 Jul 2023 09:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbjGQNR4 (ORCPT ); Mon, 17 Jul 2023 09:17:56 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BBA6270D; Mon, 17 Jul 2023 06:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599832; x=1721135832; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8dyhHZxvUBvgzLfAW2CztItj+tdrTbfblHrZWtgClfw=; b=Uawry1mVlnijETfG+EIefpdDGDnB8XsIFzSMPr9tkBBRxpkRBL56nB52 R+NgWtBxb4tS84QqJPCLn2Qm+NJxdp1YEjiPAsUgydJmfoS4lfU3aXMci QH7rGY7FPmlR7pQ9fFKKwt3JUKq0/wc8wPUDEvu179OBxpKvregHIVZuB JMCdbNLL9nN8kI0E28SCOF6avkHp0YP6nz4CiPMrD6yvQZNeLD/5aA2h7 heGlB6igM/aLHzAJMwIS/QJhkQDIbO5cVSEI5wUWjKszILFC9EpXm23la YI8LnSgr/xCARnMV7/o4DqfNjCQkx/lNMYut8VwXZyNHqR++SIySExzU0 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569256" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569256" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793247301" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793247301" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:51 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 17/19] selftests/resctrl: Move CAT/CMT test global vars to function they are used in Date: Mon, 17 Jul 2023 16:15:05 +0300 Message-Id: <20230717131507.32420-18-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org CAT and CMT tests have count_of_bits, long_mask, cbm_mask, and cache_size global variables that can be moved into the sole using function. Make the global variables local variables of the relevant function to scope them better. While at it, move cache_size initialization into the declaration line. Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cat_test.c | 11 ++++------- tools/testing/selftests/resctrl/cmt_test.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 42e35269d8b6..ed6c8e64ad11 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -17,11 +17,6 @@ #define MAX_DIFF_PERCENT 4 #define MAX_DIFF 1000000 -static int count_of_bits; -static char cbm_mask[256]; -static unsigned long long_mask; -static unsigned long cache_size; - /* * Change schemata. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -96,10 +91,12 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) { unsigned long l_mask, l_mask_1; int ret, pipefd[2], sibling_cpu_no; + unsigned long cache_size = 0; + unsigned long long_mask; + char cbm_mask[256]; + int count_of_bits; char pipe_message; - cache_size = 0; - /* Get default cbm mask for L3/L2 cache */ ret = get_cbm_mask(cache_type, cbm_mask); if (ret) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 7214aefb55ed..0ac9d6bbd13d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -16,11 +16,6 @@ #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 -static int count_of_bits; -static char cbm_mask[256]; -static unsigned long long_mask; -static unsigned long cache_size; - static int cmt_setup(struct resctrl_val_param *p) { /* Run NUM_OF_RUNS times */ @@ -75,10 +70,12 @@ void cmt_test_cleanup(void) int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) { + unsigned long cache_size = 0; + unsigned long long_mask; + char cbm_mask[256]; + int count_of_bits; int ret; - cache_size = 0; - if (!validate_resctrl_feature_request(CMT_STR)) return -1; From patchwork Mon Jul 17 13:15:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 703896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 797BEC0015E for ; Mon, 17 Jul 2023 13:19:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjGQNTM (ORCPT ); Mon, 17 Jul 2023 09:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231563AbjGQNSl (ORCPT ); Mon, 17 Jul 2023 09:18:41 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA6830DF; Mon, 17 Jul 2023 06:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689599855; x=1721135855; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J1TVPhglmPyef33VOHsKcPA5LwHiM2UJevhSWt6TPmY=; b=Fia5R+l4VVNuMUq1PM2EogweFj0VBgPTy7WNgduXg5vBuFqATHoO2h0x ObhPWDQ57uU1yQIuutu8O0mSbQmlf3BmvxUtrH+0sNztEmpZsscN8tJPy 7mvGKGaLmXePGno6PtQLD2W9uKzHKexM0uWm4uh6uUNyuq80X1qE3Zx7y bPP0jmXq/g+ANGM3W2lvksWYpPJcGGHtHFMVIpgSI98bopiq3D0Sxv87E 6TaeEwkDavZ9z8EJNohBduODXyQc4iYwJXVara5aVTufEEqXJTOSP20jc j5ULX9oc97dvDgSz6BK4u49n40RjTGVz1EZuCdSSwfJe/GqM2UcqCSr2p Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="368569293" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="368569293" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:17:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="793247336" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="793247336" Received: from dkravtso-mobl1.ccr.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.252.45.233]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 06:16:58 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v5 19/19] selftests/resctrl: Remove test type checks from cat_val() Date: Mon, 17 Jul 2023 16:15:07 +0300 Message-Id: <20230717131507.32420-20-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> References: <20230717131507.32420-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org cat_val() is only used during CAT test but it checks for test type. Remove test type checks and the unused else branch from cat_val(). Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cache.c | 47 +++++++++++-------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index 18ebd1324cb3..d3cbb829ff6a 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -230,38 +230,31 @@ int cat_val(struct resctrl_val_param *param) if (ret) return ret; - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) - initialize_llc_perf(); + initialize_llc_perf(); /* Test runs until the callback setup() tells the test to stop. */ while (1) { - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) { - ret = param->setup(param); - if (ret == END_OF_TESTS) { - ret = 0; - break; - } - if (ret < 0) - break; - ret = reset_enable_llc_perf(bm_pid, param->cpu_no); - if (ret) - break; - - if (run_fill_buf(param->span, memflush, operation, true)) { - fprintf(stderr, "Error-running fill buffer\n"); - ret = -1; - goto pe_close; - } - - sleep(1); - ret = measure_cache_vals(param, bm_pid); - if (ret) - goto pe_close; - - close(fd_lm); - } else { + ret = param->setup(param); + if (ret == END_OF_TESTS) { + ret = 0; break; } + if (ret < 0) + break; + ret = reset_enable_llc_perf(bm_pid, param->cpu_no); + if (ret) + break; + + if (run_fill_buf(param->span, memflush, operation, true)) { + fprintf(stderr, "Error-running fill buffer\n"); + ret = -1; + goto pe_close; + } + + sleep(1); + ret = measure_cache_vals(param, bm_pid); + if (ret) + goto pe_close; } return ret;