Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1130424rwp; Thu, 13 Jul 2023 06:38:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlE38z86SbiLfPvkPuO19ooeYlwnqVvAqBJFIBB1eTFute/kECABTbx98X7RTRyRCDB7mgZW X-Received: by 2002:a05:6358:52c1:b0:133:e286:9259 with SMTP id z1-20020a05635852c100b00133e2869259mr2742089rwz.17.1689255499176; Thu, 13 Jul 2023 06:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689255499; cv=none; d=google.com; s=arc-20160816; b=XxYffRWzkGa2FuyFxRPUywVWq36IGhtiSjvXDYfQfjxWpyNJOT+7kj4qOxyRrYpp6U /f6CCed3QCmwqxi9q6CaWf+0FoBYhLQZBr1DjdVGvk73Xtcl879dyFM5VooYyf6AfDJF duN6i+TxTyc5a6VC5O8a9xxbR/aETcdSCWDeXumCesQecCR4HfNXwLZPYA2rtdqvnAjt lN9NJXGky/KQ/giOK1QqzLVhQGYu6WftvV8vGyPfbpT68bCGd5VO+KsJQLFlNdiVKB7P ETHB1/Xm2cQZO7SuHn96Jn+n4ysCTqIQzm49c9cW7cw3y8K5MHlJhETKb4Ox1ZPp2Eeq aVZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2OOj3dKzNSx9YiVeGlODY1kyFPn/FVZRzoN+hWJWNi8=; fh=yQZVCT9uasVczKlazciVDh1mdZVasudsfBJLxIYHjUw=; b=Uv5pWnevmib2BdHDuZtFerdlw+a485QT7zgZy/FdNnrIIXeoaACnU9DujG5rZNOVIP eDAocx69QwVK4kaquZvFebipS7HNVZFFxvSAmcINJuChxlaGRMZrvowo7geWVJxDV0Fa CKJblvNpWNmPIREFkS7pQMp91N6g4hMhzuiQK+tv4OAa1FCFZGssEi0LNKqRQLtX4pA4 4b3oA/PjU+bcqDXgokIj3RkLc4xy/FBw+KiPYTvsTxMBtOTX0ckCp/wX91mNWYub2PUn djbbwRg/OHfaogVehq8pShuXNHLI4cg6XAuyT224pBraiXf0uARkPfC6Dwkff/qsgKa1 393g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KD9pu+h2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j71-20020a63804a000000b005579d6bdf85si5070156pgd.882.2023.07.13.06.38.06; Thu, 13 Jul 2023 06:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KD9pu+h2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235220AbjGMNVa (ORCPT + 99 others); Thu, 13 Jul 2023 09:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234513AbjGMNUy (ORCPT ); Thu, 13 Jul 2023 09:20:54 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B712D48; Thu, 13 Jul 2023 06:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689254447; x=1720790447; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e4ibwDjlAb+ZjhQ1AfFhannM0naGZnGDFIvVBzF6V0E=; b=KD9pu+h2bBpgF0TToczU3XXHfFRGVQKK0J0iB+rTAqX+mR2KqxcPJoxL /ycCGEeD/ubM4slf4jQ2v7OtdspoCoavc19CZ/YAHo6m2iLTnEnv7Z3hh /Yk7nBo6Env7irD1SDC81iNrPpEaczn8kHYW9QGso37igcmiQE6vkbVRn /rjoRNUT8tiI+C0kiJU5RDqVryzvQGc1ouOGFzPtsditXRcycXHMWV7+H zfDK0ZnZTe2sFaQ4T3MZTOM4wIstEoUE8EZI1Wf0qRjKTZd3EmgDb4sVk OVSO1kmc/DpCMw+GOEg+55XsmO89H+ohChyGG5SrTuytaHXzE87mhhdee w==; X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="345496707" X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="345496707" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 06:20:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="968615827" X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="968615827" Received: from ijarvine-mobl2.ger.corp.intel.com ([10.251.222.39]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 06:20:38 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v4 07/19] selftests/resctrl: Refactor remount_resctrl(bool mum_resctrlfs) to mount_resctrl() Date: Thu, 13 Jul 2023 16:19:20 +0300 Message-Id: <20230713131932.133258-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230713131932.133258-1-ilpo.jarvinen@linux.intel.com> References: <20230713131932.133258-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 20 +++++-------------- 3 files changed, 10 insertions(+), 20 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 a421d045de08..3f26d2279f75 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 b3a05488d360..f622245adafe 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -48,29 +48,19 @@ 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 * * 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) + return -1; ksft_print_msg("Mounting resctrl to \"%s\"\n", RESCTRL_PATH); ret = mount("resctrl", RESCTRL_PATH, "resctrl", 0, NULL); -- 2.30.2