selftests/resctrl: Add resctrl_tests into kselftest set
Subsystems (2)
v2 cover selftests/resctrl: Add resctrl_tests into kselftest set
Hello,
The aim of this series is to make resctrl_tests run by using kselftest framework.
- I modify Makefile of resctrl_test and Makefile of selftest, to build/run resctrl_tests by using kselftest framework.
- I set the limited time for resctrl_tests to 120 seconds, to ensure the resctrl_tests finish in limited time.
- When resctrl file system is not supported or resctrl_tests is not run as root, return skip code of kselftest.
- If it is not finish in limited time, terminate resctrl_tests same as executing ctrl+c.
Difference from v1:
- I change the order of patches according to Reinette's review.
- "LDLIBS + = -lnuma" has no dependencies on this patch series, delete it from [PATCH v2 2/5].
- I separate the license info of Makefile into a new patch [PATCH v2 3/5].
- I separate "limited time" into a new patch [PATCH v2 4/5]. (There is no change in [PATCH v2 1/5] and [PATCH v2 5/5])
In addition, I think 120s is not a problem since some tests have longer timeout (e.g. net test is 300s), please let me know if this is wrong
Thanks,
Shaopeng Tan (5):
selftests/resctrl: Kill the child process created by fork() when the
SIGTERM signal comes
selftests/resctrl: Make resctrl_tests run using kselftest framework selftests/resctrl: Add license to resctrl_test Makefile selftests/resctrl: Change default limited time to 120 seconds for
resctrl_tests
selftests/resctrl: Return KSFT_SKIP(4) if resctrlfile system is not
supported or resctrl is not run as root
tools/testing/selftests/Makefile | 1 + tools/testing/selftests/resctrl/Makefile | 20 +++++++------------ .../testing/selftests/resctrl/resctrl_tests.c | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 1 + tools/testing/selftests/resctrl/settings | 1 + 5 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 tools/testing/selftests/resctrl/settings
Signature · 1 line
2.27.0
PATCH v2 1/5 selftests/resctrl: Kill the child process created by fork() when the SIGTERM signal comes
In kselftest framework there is a limited time for each sub test, when the time limit comes SIGTEM signal will be sent to sub test by "timeout --foregroup <seconds>" command.
In resctrl_tests, fork() is used to create a child process. This commit ensures child process to be killed before parent process exiting if SIGTERM signal comes.
--- tools/testing/selftests/resctrl/resctrl_val.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/resctrl/resctrl_val.c +1 -0
@@ -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;
Signature · 1 line
2.27.0
Reinette Chatre
maintainerRe: [PATCH v2 1/5] selftests/resctrl: Kill the child process created by fork() when the SIGTERM signal comes
Hi Shaopeng Tan,
Quoted 2 lines · Shaopeng Tan
In kselftest framework there is a limited time for each sub test, when the time limit comes SIGTEM signal will be sent to sub test by
SIGTEM -> SIGTERM ?
Quoted 1 line
"timeout --foregroup <seconds>" command.
foregroup?
This is a bit confusing though since it mentions that the "timeout" utility is called after the test times out. Perhaps you can just describe that, if present, the test is run using the timeout utility and it will send SIGTERM to the test upon timeout.
Quoted 2 lines
In
resctrl_tests,fork()is used to create a child process. This commit ensures child process to be killed before parent process
Especially since I know you are planning more changes in the x86 area where this is enforced more strictly, please do get into the habit of describing your changes in imperative mood. Please search for "This patch" in Documentation/process/submitting-patches.rst (your usage of "This commit" is equivalent to "This patch") for more details.
Please address this in all your patches where "This commit" is frequently used.
Quoted 12 lines
exiting if SIGTERM signal comes.
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/resctrl/resctrl_val.c | 1 + 1 file changed, 1 insertion(+)tools/testing/selftests/resctrl/resctrl_val.c +0
-0
tools/testing/selftests/resctrl/resctrl_val.c int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) · line 684
Quoted 7 lines
tools/testing/selftests/resctrl/resctrl_val.c +1
-0@@ -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;
The change looks good. Since this snippet is preceded with a comment that describes its usage you could also update it with the expanded use of the kselftest framework.
Reinette
PATCH v2 2/5 selftests/resctrl: Make resctrl_tests run using kselftest framework
In reply to Shaopeng TanThis commit enables resctrl_tests to be built/run in kselftest framework. Build/run resctrl_tests by building/running all tests of kselftest, or by using the "TARGETS" variable on the make command line to specify resctrl_tests. This commit modified the Makefile of kernel kselftest set and
the Makefile of resctrl_tests.
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/resctrl/Makefile | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-)
tools/testing/selftests/Makefile +1 -0
@@ -51,6 +51,7 @@ TARGETS += proc TARGETS += pstore TARGETS += ptrace TARGETS += openat2 +TARGETS += resctrl TARGETS += rlimits TARGETS += rseq TARGETS += rtc
tools/testing/selftests/resctrl/Makefile +6 -14
@@ -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 +EXTRA_SOURCES := $(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): $(EXTRA_SOURCES) +include ../lib.mk
Signature · 1 line
2.27.0
Reinette Chatre
maintainerRe: [PATCH v2 2/5] selftests/resctrl: Make resctrl_tests run using kselftest framework
Hi Shaopeng Tan,
Quoted 1 line · Shaopeng Tan
This commit enables
resctrl_teststo be built/run in kselftest framework.
(This commit)
Quoted 2 lines
Build/run
resctrl_testsby building/running all tests of kselftest, or by using the "TARGETS" variable on the make command line to specifyresctrl_tests.
Please review the feedback I provided to your first version. I do not see the changelog improvements that describe how a user may use the kselftest framework to run the resctrl tests nor the requested information on how existing workflows are impacted. Going back through my previous review feedback to ensure that all is addressed is very time consuming and causes considerable delay when needing to review newer versions.
tools/testing/selftests/resctrl/README should be updated also
Quoted 2 lines
This commit modified the
Makefileof kernel kselftest set and theMakefileofresctrl_tests.
This is clear from the diffstat. You could elaborate why the changes were needed instead and do so without the "This commit" usage.
Quoted 24 lines
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/resctrl/Makefile | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-)tools/testing/selftests/Makefile +1
-0@@ -51,6 +51,7 @@ TARGETS += proc TARGETS += pstore TARGETS += ptrace TARGETS += openat2 +TARGETS += resctrl TARGETS += rlimits TARGETS += rseq TARGETS += rtctools/testing/selftests/resctrl/Makefile +0
-0
tools/testing/selftests/resctrl/Makefile line 4
Quoted 9 lines
tools/testing/selftests/resctrl/Makefile +3
-5@@ -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 +EXTRA_SOURCES := $(wildcard *.c)
Why is the meaning of "EXTRA_SOURCES" (i.e. what is "extra"?) and why is "SRCS" no longer sufficient?
Quoted 4 lines
tools/testing/selftests/resctrl/Makefile +1
-2-$(OBJS): $(SRCS) - $(CC) $(CFLAGS) -c $(SRCS) +all: $(TEST_GEN_PROGS)
tools/testing/selftests/resctrl/Makefile line 9
Quoted 10 lines
tools/testing/selftests/resctrl/Makefile +2
-7-resctrl_tests: $(OBJS) - $(CC) $(CFLAGS) -o $@ $^ - -.PHONY: clean - -clean: - $(RM) $(OBJS) resctrl_tests +$(TEST_GEN_PROGS): $(EXTRA_SOURCES) +include ../lib.mk
Reinette
PATCH v2 3/5 selftests/resctrl: Add license to resctrl_test Makefile
In reply to Shaopeng TanAdd Software Package Data Exchange license information to resctrl_test Makefile.
--- tools/testing/selftests/resctrl/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/resctrl/Makefile +2 -0
@@ -1,3 +1,5 @@ +#SPDX-License-Identifier: GPL-2.0 + CFLAGS += -g -Wall -O2 -D_FORTIFY_SOURCE=2 TEST_GEN_PROGS := resctrl_tests
Signature · 1 line
2.27.0
Reinette Chatre
maintainerRe: [PATCH v2 3/5] selftests/resctrl: Add license to resctrl_test Makefile
Hi Shaopeng Tan,
Quoted 2 lines · Shaopeng Tan
Add Software Package Data Exchange license information to
resctrl_testMakefile.
Considering the patch series, why is this change needed to be able to run resctrl tests from within the kselftest framework?
tools/testing/selftests/resctrl/Makefile line 2
Quoted 12 lines
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/resctrl/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/resctrl/Makefile +2
-0@@ -1,3 +1,5 @@ +#SPDX-License-Identifier: GPL-2.0 +
Please see Documentation/process/license-rules.rst and examples from other Makefiles in this area.
tools/testing/selftests/resctrl/Makefile line 5
Quoted 3 lines
tools/testing/selftests/resctrl/Makefile +0
-0CFLAGS += -g -Wall -O2 -D_FORTIFY_SOURCE=2 TEST_GEN_PROGS := resctrl_tests
Reinette
PATCH v2 4/5 selftests/resctrl: Change default limited time to 120 seconds for resctrl_tests
In reply to Shaopeng TanThis commit changed the default limited time(45s) to 120 seconds for resctrl_tests by adding "setting" file. Since 45 seconds may not be enough on some machine environments.
--- tools/testing/selftests/resctrl/settings | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/testing/selftests/resctrl/settings
tools/testing/selftests/resctrl/settings new file +1 -0
@@ -0,0 +1 @@ +timeout=120
Signature · 1 line
2.27.0
Reinette Chatre
maintainerRe: [PATCH v2 4/5] selftests/resctrl: Change default limited time to 120 seconds for resctrl_tests
Hi Shaopeng Tan,
Quoted 1 line · Shaopeng Tan
This commit changed the default limited time(45s) to 120 seconds for
(This commit)
Quoted 2 lines
resctrl_testsby adding "setting" file. Since 45 seconds may not be enough on some machine environments.
This sounds very imprecise when you say "may not be enough". From what I understand you have already encountered systems where this is not enough so you have established that 45 seconds is too short. The next question is, how was 120 seconds determined and how do you know it will be enough?
Quoted 13 lines
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/resctrl/settings | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/testing/selftests/resctrl/settingstools/testing/selftests/resctrl/settings new file +0
-0
tools/testing/selftests/resctrl/settings line 1
Quoted 1 line
tools/testing/selftests/resctrl/settings new file +1
-0@@ -0,0 +1 @@ +timeout=120
Reinette
RE: [PATCH v2 4/5] selftests/resctrl: Change default limited time to 120 seconds for resctrl_tests
Hi Reinette,
Quoted 5 lines · Shaopeng Tan
Quoted 1 line
This commit changed the default limited time(45s) to 120 seconds for
(This commit)
Quoted 7 lines
Quoted 2 lines
resctrl_testsby adding "setting" file. Since 45 seconds may not be enough on some machine environments.This sounds very imprecise when you say "may not be enough". From what I understand you have already encountered systems where this is not enough so you have established that 45 seconds is too short. The next question is, how was 120 seconds determined and how do you know it will be enough?
It took about 68 seconds in my environment (Intel(R) Xeon(R) Gold 6254 CPU @ 3.10GHz). This test accesses a fixed size(250M) memory by default settings
which is used when run in kselftest framework.
I think that the execution time does not change significantly in different environments. So, I roughly doubled the execution time and get 120s, which I set to the limited time. I think it is enough for any environments.
If 120s are also not enough, user can freely set the limited time by "setting" file.
Thanks for your feedback of this patch series,
I will correct them in a few days.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/resctrl/settings | 1 + 1 file changed, 1 insertion(+) create mode 100644 tools/testing/selftests/resctrl/settings
Quoted 8 lines
tools/testing/selftests/resctrl/settings line 1
Quoted 8 lines
tools/testing/selftests/resctrl/settings new file +1
-0@@ -0,0 +1 @@ +timeout=120
Best regards,
Tan Shaopeng
Reinette Chatre
maintainerRe: [PATCH v2 4/5] selftests/resctrl: Change default limited time to 120 seconds for resctrl_tests
Hi Tan Shaopeng,
Quoted 15 lines · On 1/20/2022 11:59 PM, [email protected] wrote:
Hi Reinette,
Quoted 5 lines · Shaopeng Tan
Quoted 1 line
This commit changed the default limited time(45s) to 120 seconds for
(This commit)
Quoted 7 lines
Quoted 2 lines
resctrl_testsby adding "setting" file. Since 45 seconds may not be enough on some machine environments.This sounds very imprecise when you say "may not be enough". From what I understand you have already encountered systems where this is not enough so you have established that 45 seconds is too short. The next question is, how was 120 seconds determined and how do you know it will be enough?
Quoted 8 lines
It took about 68 seconds in my environment (Intel(R) Xeon(R) Gold 6254 CPU @ 3.10GHz). This test accesses a fixed size(250M) memory by default settings
which is used when run in kselftest framework.
I think that the execution time does not change significantly in different environments. So, I roughly doubled the execution time and get 120s, which I set to the limited time. I think it is enough for any environments.
If 120s are also not enough, user can freely set the limited time by "setting" file.
How about something like:
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.
Reinette
RE: [PATCH v2 4/5] selftests/resctrl: Change default limited time to 120 seconds for resctrl_tests
Hi Reinette,
Quoted 32 lines · On 1/20/2022 11:59 PM, [email protected] wrote:
Quoted 14 lines
Hi Reinette,
Quoted 12 lines · Shaopeng Tan
Quoted 1 line
This commit changed the default limited time(45s) to 120 seconds for
(This commit)
Quoted 2 lines
resctrl_testsby adding "setting" file. Since 45 seconds may not be enough on some machine environments.This sounds very imprecise when you say "may not be enough". From what I understand you have already encountered systems where this is not enough so you have established that 45 seconds is too short. The next question is, how was 120 seconds determined and how do you know it
will be enough?
Quoted 2 lines
It took about 68 seconds in my environment (Intel(R) Xeon(R) Gold 6254 CPU
@ 3.10GHz).
Quoted 3 lines
This test accesses a fixed size(250M) memory by default settings which is used when run in kselftest framework.
I think that the execution time does not change significantly in differentenvironments.
Quoted 1 line
So, I roughly doubled the execution time and get 120s, which I set to the
limited time.
Quoted 2 lines
I think it is enough for any environments.
If 120s are also not enough, user can freely set the limited time by "setting"file.
Quoted 1 line
How about something like:
Quoted 11 lines
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.
Thanks for your feedback.
I will use it for commit log in next version.
Best regards,
Tan Shaopeng
PATCH v2 5/5 selftests/resctrl: Return KSFT_SKIP(4) if resctrlfile system is not supported or resctrl is not run as root
In reply to Shaopeng TanTo unify the return code of resctrl_tests with the return code of selftest set, return KSFT_SKIP (4) if resctrl file system is not supported or resctrl is not run as root.
--- tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/resctrl_tests.c +2 -2
@@ -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 ();
Signature · 1 line
2.27.0
Reinette Chatre
maintainerRe: [PATCH v2 5/5] selftests/resctrl: Return KSFT_SKIP(4) if resctrlfile system is not supported or resctrl is not run as root
Hi Shaopeng Tan,
Subject line still with typo. Also, what does "resctrl is not run as root" mean? Do you mean "resctrl_tests"? The subject line can be made more succinct while the details are moved to the commit message.
Quoted 3 lines · Shaopeng Tan
To unify the return code of
resctrl_testswith the return code of selftest set, returnKSFT_SKIP(4) if resctrl file system is not supported or resctrl is not run as root.
Please review the feedback I provided to your first version. I do not see the explanation of how changing ksft_exit_fail_msg() to ksft_exit_skip() accomplishes the goal of unifying the return code. It surely is not a good use of my time to review patches and have the feedback ignored.
Quoted 20 lines
Signed-off-by Shaopeng Tan <[email protected]>--- tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/resctrl/resctrl_tests.c +1
-1@@ -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 ();
tools/testing/selftests/resctrl/resctrl_tests.c int main(int argc, char **argv) · line 241
Quoted 8 lines
tools/testing/selftests/resctrl/resctrl_tests.c +1
-1@@ -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 ();
Reinette
Hi,
Friendly ping for a review.
Quoted 46 lines
Hello,
The aim of this series is to make
resctrl_testsrun by using kselftest framework.
- I modifyMakefileofresctrl_testandMakefileof selftest, to build/runresctrl_testsby using kselftest framework.
- I set the limited time forresctrl_teststo 120 seconds, to ensure theresctrl_testsfinish in limited time.
- When resctrl file system is not supported orresctrl_testsis not run as root, return skip code of kselftest.
- If it is not finish in limited time, terminateresctrl_testssame as executing ctrl+c.Difference from v1:
- I change the order of patches according to Reinette's review.
- "LDLIBS + = -lnuma" has no dependencies on this patch series, delete it from [PATCH v2 2/5].
- I separate the license info ofMakefileinto a new patch [PATCH v2 3/5].
- I separate "limited time" into a new patch [PATCH v2 4/5]. (There is no change in [PATCH v2 1/5] and [PATCH v2 5/5]) In addition, I think 120s is not a problem since some tests have longer timeout (e.g. net test is 300s), please let me know if this is wrongThanks,
Shaopeng Tan (5):
selftests/resctrl: Kill the child process created byfork()when the
SIGTERM signal comes
selftests/resctrl: Makeresctrl_testsrun using kselftest framework selftests/resctrl: Add license toresctrl_testMakefileselftests/resctrl: Change default limited time to 120 seconds for
resctrl_tests
selftests/resctrl: ReturnKSFT_SKIP(4)if resctrlfile system is not
supported or resctrl is not run as roottools/testing/selftests/Makefile | 1 + tools/testing/selftests/resctrl/Makefile | 20 +++++++------------ .../testing/selftests/resctrl/resctrl_tests.c | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 1 + tools/testing/selftests/resctrl/settings | 1 + 5 files changed, 12 insertions(+), 15 deletions(-) create mode 100644
tools/testing/selftests/resctrl/settings--
2.27.0