From patchwork Wed Feb 16 02:26:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747863 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 B0028C433F5 for ; Wed, 16 Feb 2022 02:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343694AbiBPC3h (ORCPT ); Tue, 15 Feb 2022 21:29:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiBPC3g (ORCPT ); Tue, 15 Feb 2022 21:29:36 -0500 Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83CCF5426; Tue, 15 Feb 2022 18:29:24 -0800 (PST) IronPort-SDR: kAYv95AfXj1TF0NFiwp/qvO2X2XGZ0rJ99qXo0mUOPKBPJfHi+ybfLTGIjDZ/7s2p2fkjkzOhV xjjWOB4onWgSirX3txJ8sG+8N0lQYy93Na+X+Nqd2m1Ia3p2J0kGiSuiXV4f2ooDNA3WNVZ+3x DpF+ajXYdCI4aged/w64pmc2O3/kYuI/Az1LQjk9jBFk+IWONctLpHMGkMqXSTSr2Tm3QIhRAg dO/NP0sw6/kWZjdacUvF+2Zzlz4naGM8gKeFuYl4Wz15ilAfRZS2jTNpV6YRBa92T2nm+a/65g 9NvwW3hQtd6QzOKHEoAvFYGi X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="62683563" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="62683563" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:28:20 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 6041FD689C; Wed, 16 Feb 2022 11:28:18 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 9DB34E6747; Wed, 16 Feb 2022 11:28:16 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id 767A24007E8D3; Wed, 16 Feb 2022 11:28:16 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 1/5] selftests/resctrl: Kill child process before parent process terminates if SIGTERM is received Date: Wed, 16 Feb 2022 11:26:37 +0900 Message-Id: <20220216022641.2998318-2-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In kselftest framework, a sub test is run using the timeout utility and it will send SIGTERM to the test upon timeout. In resctrl_tests, a child process is created by fork() to run benchmark but SIGTERM is not set in sigaction(). If SIGTERM signal is received, the parent process will be killed, but the child process still exists. kill child process before parent process terminates if SIGTERM signal is received. Signed-off-by: Shaopeng Tan Reviewed-by: Shuah Khan --- Some important feedbacks from v1&v2 are addressed as follows: - Change the order so that current patch 3/3 becomes 1/3. Since without the SIGTERM fix, the test would hang if run from the kselftest framework. => I changed the order and the SIGTERM fix now becomes patch [1/5]. - Describe that the test is run using the timeout utility and it will send SIGTERM to the test upon timeout. => I updated the changelog to include this information. - Describe changes in imperative mood, and address this in all patches. See Documentation/process/submitting-patches.rst for more details. => I described all my patches' changelog in imperative mood and deleted "This commit". - + sigaction(SIGTERM, &sigact, NULL) || This snippet is preceded with a comment that describes its usage you could also update it with the expanded use of the kselftest framework. => I don't think it is necessary to add other comments. Since the current comment already states "Register CTRL-C handler for parent, as it has to kill benchmark before exiting", So, when SIGTERM comes, the benchmark(child process) should be killed before parent process terminates, but it was missing. tools/testing/selftests/resctrl/resctrl_val.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 95224345c78e..b32b96356ec7 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -678,6 +678,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_SIGINFO; if (sigaction(SIGINT, &sigact, NULL) || + sigaction(SIGTERM, &sigact, NULL) || sigaction(SIGHUP, &sigact, NULL)) { perror("# sigaction"); ret = errno; From patchwork Wed Feb 16 02:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747864 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 E5782C433F5 for ; Wed, 16 Feb 2022 02:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343719AbiBPC3w (ORCPT ); Tue, 15 Feb 2022 21:29:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiBPC3w (ORCPT ); Tue, 15 Feb 2022 21:29:52 -0500 Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6AC2F5426; Tue, 15 Feb 2022 18:29:39 -0800 (PST) IronPort-SDR: 3qn+0Ks3jcTk0FvJSLbZBENPd8+dSBt7hBT+gYRdDUX4ggXHMMLIBoZPlmvJiSHuKmYDxzwvbP olgCGWngWCxq8CsotpyXciYP10wQdlvfFaT1PMjHnmmsKrd1goqjwq7D4CO9+uPzuKxgcBKCnO 1FUf+nuxHo8JNIQkqL8tF2DkrnPbo/dbMFkSiUkwcafGbBzYq3L2252GWMswtcPT/pQ8laVcHO uIxKGmkeCpEJViM+po2Ml5mvWd9Xyse56XAHqQRzx5c3bI2mEG4EKvlVJcTwNK9un746hgKAb8 lk7Hh7hkUXN11Qu8w79+CXI6 X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="62683600" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="62683600" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:28:34 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id BB199E5B2D; Wed, 16 Feb 2022 11:28:32 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 0AE04141A2; Wed, 16 Feb 2022 11:28:32 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id DAB0C4007EB18; Wed, 16 Feb 2022 11:28:31 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 2/5] selftests/resctrl: Make resctrl_tests run using kselftest framework Date: Wed, 16 Feb 2022 11:26:38 +0900 Message-Id: <20220216022641.2998318-3-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In kselftest framework, all tests can be build/run at a time, and a sub test also can be build/run individually. As follows: $ make -C tools/testing/selftests run_tests $ make -C tools/testing/selftests TARGETS=ptrace run_tests However, resctrl_tests cannot be run using kselftest framework, users have to change directory to tools/testing/selftests/resctrl/, run "make" to build executable file "resctrl_tests", and run "sudo ./resctrl_tests" to execute the test. To build/run resctrl_tests using kselftest framework. Modify tools/testing/selftests/Makefile and tools/testing/selftests/resctrl/Makefile. Even after this change, users can still build/run resctrl_tests without using framework as before. Signed-off-by: Shaopeng Tan --- Some important feedbacks from v1&v2 are addressed as follows: - The changelog mentions that changes were made to the resctrl selftest Makefile but it does not describe what the change accomplish or why they are needed. => By changing the Makefile, resctrl_tests can use kselftest framework like other sub tests. I described this in changelog. - The changelog did not describe how a user may use the kselftest framework to run the resctrl tests nor the requested information on how existing workflows are impacted. => I described how to build/run resctrl_tests with kselftest framework, and described the existing workflows are not impacted that users can build/run resctrl_tests without using kselftest framework as before. - tools/testing/selftests/resctrl/README should be updated. => I separate the update of README to a new patch.[patch v3 3/5] - Why is the meaning of "EXTRA_SOURCES" (i.e. what is "extra"?) and why is "SRCS" no longer sufficient? => I referred to other Makefiles, and found "SRCS" is better than "EXTRA_SOURCES". So, I updated it to use "SRCS". tools/testing/selftests/Makefile | 1 + tools/testing/selftests/resctrl/Makefile | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index c852eb40c4f7..7df397c6893c 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -51,6 +51,7 @@ TARGETS += proc TARGETS += pstore TARGETS += ptrace TARGETS += openat2 +TARGETS += resctrl TARGETS += rlimits TARGETS += rseq TARGETS += rtc diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile index 6bcee2ec91a9..de26638540ba 100644 --- a/tools/testing/selftests/resctrl/Makefile +++ b/tools/testing/selftests/resctrl/Makefile @@ -1,17 +1,9 @@ -CC = $(CROSS_COMPILE)gcc -CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -SRCS=$(wildcard *.c) -OBJS=$(SRCS:.c=.o) +CFLAGS += -g -Wall -O2 -D_FORTIFY_SOURCE=2 -all: resctrl_tests +TEST_GEN_PROGS := resctrl_tests +SRCS := $(wildcard *.c) -$(OBJS): $(SRCS) - $(CC) $(CFLAGS) -c $(SRCS) +all: $(TEST_GEN_PROGS) -resctrl_tests: $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ - -.PHONY: clean - -clean: - $(RM) $(OBJS) resctrl_tests +$(TEST_GEN_PROGS): $(SRCS) +include ../lib.mk From patchwork Wed Feb 16 02:26:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747865 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 E0833C433EF for ; Wed, 16 Feb 2022 02:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343730AbiBPCaC (ORCPT ); Tue, 15 Feb 2022 21:30:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiBPCaB (ORCPT ); Tue, 15 Feb 2022 21:30:01 -0500 X-Greylist: delayed 64 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 15 Feb 2022 18:29:50 PST Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E066F5437; Tue, 15 Feb 2022 18:29:50 -0800 (PST) IronPort-SDR: 57nfTPdI84U20D21PecGXc83Y9mI9d7w9oCCr6K4Geh5Eah3T+d1o5emFfxlCJrb3u+rwYbmM5 XPWHeIa2xEe2BY+LzYtxEZ0xDTWvb+YVE9SML/iHrWEjCvMSWEzV+FRCiiHawRZrA8vfqMpGws 5AAYOGsm2tkZMo0o19+d5uTGOaNBlnIpfVDh8eEEJtQS+MuiFmAr2PBcrUDbxlq4MXpbre6L7S Pa+ZLhqPyLBeuu9bvbDIpCQLbeFBE3qMqnWB01GnUXSM0Ph/fVQNzsQ2n+mYWKg1vmv/tQokhd Gw0dihpB8ebcy+suG4dgn9Ww X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="42653835" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="42653835" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:28:44 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 63097F030A; Wed, 16 Feb 2022 11:28:43 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C7F0D69CC; Wed, 16 Feb 2022 11:28:42 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id E942E40078D9D; Wed, 16 Feb 2022 11:28:41 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 3/5] selftests/resctrl: Update README about using kselftest framework to build/run resctrl_tests Date: Wed, 16 Feb 2022 11:26:39 +0900 Message-Id: <20220216022641.2998318-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In this patch series, I make restrl_tests build/run using kselftest framework, but some users do not known how to build/run resctrl_tests using kseltest framework. Add manual of how to make resctrl_tests build/run using kselftest framework into README. Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/README | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/resctrl/README b/tools/testing/selftests/resctrl/README index 3d2bbd4fa3aa..a0dd459049b7 100644 --- a/tools/testing/selftests/resctrl/README +++ b/tools/testing/selftests/resctrl/README @@ -12,9 +12,43 @@ Allocation test on Intel RDT hardware. More tests will be added in the future. And the test suit can be extended to cover AMD QoS and ARM MPAM hardware as well. +resctrl_tests can be run with or without kselftest framework. + +USE KSELFTEST FRAMEWORK +----------------------- + +BUILD +----- + +Execute the following command in top level directory of the kernel source. + +Build resctrl: + $ make -C tools/testing/selftests TARGETS=resctrl + +Build all self tests: + $ make -C tools/testing/selftests + +RUN +--- + +Run resctrl: + $ make -C tools/testing/selftests TARGETS=resctrl run_tests + +Run all self tests: + $ make -C tools/testing/selftests run_tests + +Using kselftest framework, the ./resctrl_tests will be run without any parameters. + +More details about kselftest framework as follow. +Documentation/dev-tools/kselftest.rst + +NOT USE KSELFTEST FRAMEWORK +--------------------------- + BUILD ----- +Execute the following command in this directory(tools/testing/selftests/resctrl/). Run "make" to build executable file "resctrl_tests". RUN From patchwork Wed Feb 16 02:26:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747866 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 63750C433EF for ; Wed, 16 Feb 2022 02:30:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiBPCaK (ORCPT ); Tue, 15 Feb 2022 21:30:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241563AbiBPCaK (ORCPT ); Tue, 15 Feb 2022 21:30:10 -0500 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A9EF5426; Tue, 15 Feb 2022 18:29:58 -0800 (PST) IronPort-SDR: 6gBjHwVCpkApe48hHj/iFMfucg9Pth6iyV9NCeLdL0MdgnuZbmfm9jgXS2ds+V6YZCbaZ4N8mu SlljFNCModLk/J2smHjqWmIlgIJSpDnPNBWg2wOKhS/LgsZH7YHKbplFg/XX1cotLXCNOqiLxJ 52KpWTzMh7bIB9fgNak+IeutUj06ofoamdxdLAQyql2T3fgld5aJOAnFoDwavSxqB2Ot5LMbeB wqcgY+lC37fDP+xFoA5fBDjeapRNw45M8BbXp6fR7zFrJm6kglKm+o1xSc7NXxRDVtScqEqyCW 8UuNmQRwN80u4/NmVjEgNfjG X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="62933532" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="62933532" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:28:53 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 7EEADF030C; Wed, 16 Feb 2022 11:28:51 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id C03FCBDB33; Wed, 16 Feb 2022 11:28:50 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id 82B0A4007E8D1; Wed, 16 Feb 2022 11:28:50 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 4/5] selftests/resctrl: Change the default limited time to 120 seconds Date: Wed, 16 Feb 2022 11:26:40 +0900 Message-Id: <20220216022641.2998318-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When testing on a Intel(R) Xeon(R) Gold 6254 CPU @ 3.10GHz the resctrl selftests fail due to timeout after exceeding the default time limit of 45 seconds. On this system the test takes about 68 seconds. Since the failing test by default accesses a fixed size of memory, the execution time should not vary significantly between different environment. A new default of 120 seconds should be sufficient yet easy to customize with the introduction of the "settings" file for reference. Signed-off-by: Shaopeng Tan Reviewed-by: Shuah Khan --- From the perspective of the kselftest framework, a rule of "Don't take too long" is a concern. To get some better informed opinions from kselftest audience, I highlighted this change in the cover letter. I adopted most of Reinette's phrase from the discussion in patch v2 to explain why 120s is appropriate for this test. tools/testing/selftests/resctrl/settings | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/testing/selftests/resctrl/settings diff --git a/tools/testing/selftests/resctrl/settings b/tools/testing/selftests/resctrl/settings new file mode 100644 index 000000000000..6091b45d226b --- /dev/null +++ b/tools/testing/selftests/resctrl/settings @@ -0,0 +1 @@ +timeout=120 From patchwork Wed Feb 16 02:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747861 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 22B52C433FE for ; Wed, 16 Feb 2022 02:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245668AbiBPC3P (ORCPT ); Tue, 15 Feb 2022 21:29:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiBPC3O (ORCPT ); Tue, 15 Feb 2022 21:29:14 -0500 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 15 Feb 2022 18:29:02 PST Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D32F4D30; Tue, 15 Feb 2022 18:29:02 -0800 (PST) IronPort-SDR: O71LzE2HZ2rK+V6H6KRTZDKR9c+9VzwtLs5r4eBl/lqnFWnyp/dJaNtvVF8zOMlsbHYoWfaup2 gn2IZiHkPQJU7ArbXDb3JJJMm9+blEVR5Vd23o7jqAcxn44cs6zih0w/9pxbDfeX8BFqsmpVqL bDKG9qNO5FXf4nD4VJkJwF0MCS4IvUelKOSzqkCS5T6rWeaPeu8DdYWuwJ4T87Ro3CcPN404Fu vkFoTx1fKGJHuqhYabIsXfPDX0Fe7EEOa5OWNOwD7CrnClPh35BbHluF4qQs3uI6o8HT4E8G1D C6DO5/RhVwW2r9vJiKPfErcl X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="63437440" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="63437440" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:29:00 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id BDADE97F0C; Wed, 16 Feb 2022 11:28:58 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 0431FD9973; Wed, 16 Feb 2022 11:28:58 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id C42B94007E8D1; Wed, 16 Feb 2022 11:28:57 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 5/5] selftests/resctrl: Fix resctrl_tests' return code to work with selftest framework Date: Wed, 16 Feb 2022 11:26:41 +0900 Message-Id: <20220216022641.2998318-6-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In kselftest framework, if a sub test can not run by some reasons, the test result should be marked as SKIP rather than FAIL. Return KSFT_SKIP(4) instead of KSFT_FAIL(1) if resctrl_tests is not run as root or it is run on a test environment which does not support resctrl. - ksft_exit_fail_msg(): returns KSFT_FAIL(1) - ksft_exit_skip(): returns KSFT_SKIP(4) Signed-off-by: Shaopeng Tan Reviewed-by: Shuah Khan --- Some important feedbacks from v1&v2 are addressed as follows: - It is important to highlight that a skipped test is marked as successful to not unnecessarily report a feature failure when there actually is a failure in the test environment. => I highligted this content in changelog as follows. "In kselftest framework, if a test is not run by some reason, the test result is marked as SKIP rather than FAIL." - The subject line can be made more succinct while the details are moved to the commit message. => I made subject line succinct and moved the details to changelog. - How changing ksft_exit_fail_msg() to ksft_exit_skip() accomplishes the goal of unifying the return code. => In changelog, I explained why return code KSFT_SKIP(4) is needed in kselftest framework and the return code of each function. 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 973f09a66e1e..3be0895c492b 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) * 2. We execute perf commands */ if (geteuid() != 0) - return ksft_exit_fail_msg("Not running as root, abort testing.\n"); + return ksft_exit_skip("Not running as root, abort testing.\n"); /* Detect AMD vendor */ detect_amd(); @@ -235,7 +235,7 @@ int main(int argc, char **argv) sprintf(bm_type, "fill_buf"); if (!check_resctrlfs_support()) - return ksft_exit_fail_msg("resctrl FS does not exist\n"); + return ksft_exit_skip("resctrl FS does not exist\n"); filter_dmesg();