Hi Linus,
Please pull the following Kselftest update for Linux 5.18-rc2.
This Kselftest fixes update for Linux 5.18-rc2 consists of build,
run-times fixes to tests:
- header dependencies
- missing tear-downs to release allocated resources in assert paths
- missing error messages when build fails
- coccicheck and unused variable warnings
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 3123109284176b1532874591f7c81f3837bbdc17:
Linux 5.18-rc1 (2022-04-03 14:08:21 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-fixes-5.18-rc2
for you to fetch changes up to 79ee8aa31d518c1fd5f3b1b1ac39dd1fb4dc7039:
selftests/harness: Pass variant to teardown (2022-04-04 13:37:48 -0600)
----------------------------------------------------------------
linux-kselftest-fixes-5.18-rc2
This Kselftest fixes update for Linux 5.18-rc2 consists of build,
run-times fixes to tests:
- header dependencies
- missing tear-downs to release allocated resources in assert paths
- missing error messages when build fails
- coccicheck and unused variable warnings
----------------------------------------------------------------
Axel Rasmussen (2):
selftests: fix header dependency for pid_namespace selftests
selftests: fix an unused variable warning in pidfd selftest
Geliang Tang (1):
selftests: x86: add 32bit build warnings for SUSE
Guo Zhengkui (2):
selftests/vDSO: fix array_size.cocci warning
selftests/proc: fix array_size.cocci warning
Kees Cook (1):
selftests/harness: Run TEARDOWN for ASSERT failures
Willem de Bruijn (1):
selftests/harness: Pass variant to teardown
tools/testing/selftests/kselftest_harness.h | 59 +++++++++++++++-------
tools/testing/selftests/pid_namespace/Makefile | 6 +--
tools/testing/selftests/pidfd/pidfd_wait.c | 1 -
tools/testing/selftests/proc/proc-pid-vm.c | 6 ++-
.../testing/selftests/vDSO/vdso_test_correctness.c | 9 ++--
tools/testing/selftests/x86/Makefile | 4 ++
6 files changed, 54 insertions(+), 31 deletions(-)
----------------------------------------------------------------
Before:
> Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0
After:
> Testing complete. Passed: 137, Skipped: 36
Even with our current set of statuses, the output is a bit verbose.
It could get worse in the future if we add more (e.g. timeout, kasan).
Let's only print the relevant ones.
I had previously been sympathetic to the argument that always
printing out all the statuses would make it easier to parse results.
But now we have commit acd8e8407b8f ("kunit: Print test statistics on
failure"), there are test counts printed out in the raw output.
We don't currently print out an overall total across all suites, but it
would be easy to add, if we see a need for that.
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
---
tools/testing/kunit/kunit_parser.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index 807ed2bd6832..957907105429 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -94,11 +94,10 @@ class TestCounts:
def __str__(self) -> str:
"""Returns the string representation of a TestCounts object.
"""
- return ('Passed: ' + str(self.passed) +
- ', Failed: ' + str(self.failed) +
- ', Crashed: ' + str(self.crashed) +
- ', Skipped: ' + str(self.skipped) +
- ', Errors: ' + str(self.errors))
+ statuses = [('Passed', self.passed), ('Failed', self.failed),
+ ('Crashed', self.crashed), ('Skipped', self.skipped),
+ ('Errors', self.errors)]
+ return ', '.join('{}: {}'.format(s, n) for s, n in statuses if n > 0)
def total(self) -> int:
"""Returns the total number of test cases within a test
base-commit: b04d1a8dc7e7ff7ca91a20bef053bcc04265d83a
--
2.35.1.1178.g4f1659d476-goog
Add support for a new kind of kunit_suite registration macro called
kunit_test_init_suite(); this new registration macro allows the
registration of kunit_suites that reference functions marked __init and
data marked __initdata.
Signed-off-by: Brendan Higgins <brendanhiggins(a)google.com>
Tested-by: Martin Fernandez <martin.fernandez(a)eclypsium.com>
Reviewed-by: Kees Cook <keescook(a)chromium.org>
Reviewed-by: David Gow <davidgow(a)google.com>
---
This is a follow-up to the RFC here[1].
This patch is in response to a KUnit user issue[2] in which the user was
attempting to test some init functions; although this is a functional
solution as long as KUnit tests only run during the init phase, we will
need to do more work if we ever allow tests to run after the init phase
is over; it is for this reason that this patch adds a new registration
macro rather than simply modifying the existing macros.
Changes since last version:
- I added more to the kunit_test_init_suites() kernel-doc comment
detailing "how" the modpost warnings are suppressed in addition to
the existing information regarding "why" it is OK for the modpost
warnings to be suppressed.
[1] https://lore.kernel.org/linux-kselftest/20220310210210.2124637-1-brendanhig…
[2] https://groups.google.com/g/kunit-dev/c/XDjieRHEneg/m/D0rFCwVABgAJ
---
include/kunit/test.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/include/kunit/test.h b/include/kunit/test.h
index b26400731c02..7f303a06bc97 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -379,6 +379,32 @@ static inline int kunit_run_all_tests(void)
#define kunit_test_suite(suite) kunit_test_suites(&suite)
+/**
+ * kunit_test_init_suites() - used to register one or more &struct kunit_suite
+ * containing init functions or init data.
+ *
+ * @__suites: a statically allocated list of &struct kunit_suite.
+ *
+ * This functions identically as &kunit_test_suites() except that it suppresses
+ * modpost warnings for referencing functions marked __init or data marked
+ * __initdata; this is OK because currently KUnit only runs tests upon boot
+ * during the init phase or upon loading a module during the init phase.
+ *
+ * NOTE TO KUNIT DEVS: If we ever allow KUnit tests to be run after boot, these
+ * tests must be excluded.
+ *
+ * The only thing this macro does that's different from kunit_test_suites is
+ * that it suffixes the array and suite declarations it makes with _probe;
+ * modpost suppresses warnings about referencing init data for symbols named in
+ * this manner.
+ */
+#define kunit_test_init_suites(__suites...) \
+ __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \
+ CONCATENATE(__UNIQUE_ID(suites), _probe), \
+ ##__suites)
+
+#define kunit_test_init_suite(suite) kunit_test_init_suites(&suite)
+
#define kunit_suite_for_each_test_case(suite, test_case) \
for (test_case = suite->test_cases; test_case->run_case; test_case++)
base-commit: 330f4c53d3c2d8b11d86ec03a964b86dc81452f5
--
2.35.1.723.g4982287a31-goog
Context:
When using a non-UML arch, kunit.py will boot the test kernel with these
options by default:
> mem=1G console=tty kunit_shutdown=halt console=ttyS0 kunit_shutdown=reboot
For QEMU, we need to use 'reboot', and for UML we need to use 'halt'.
If you switch them, kunit.py will hang until the --timeout expires.
So the code currently unconditionally adds 'kunit_shutdown=halt' but
then appends 'reboot' when using QEMU (which overwrites it).
This patch:
Having these duplicate options is a bit noisy.
Switch so we only add 'halt' for UML.
I.e. we now get
UML: 'mem=1G console=tty console=ttyS0 kunit_shutdown=halt'
QEMU: 'mem=1G console=tty console=ttyS0 kunit_shutdown=reboot'
Side effect: you can't overwrite kunit_shutdown on UML w/ --kernel_arg.
But you already couldn't for QEMU, and why would you want to?
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
---
tools/testing/kunit/kunit_kernel.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 483f78e15ce9..9731ceb7ad92 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -158,7 +158,7 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations):
def start(self, params: List[str], build_dir: str) -> subprocess.Popen:
"""Runs the Linux UML binary. Must be named 'linux'."""
linux_bin = os.path.join(build_dir, 'linux')
- return subprocess.Popen([linux_bin] + params,
+ return subprocess.Popen([linux_bin] + params + ['kunit_shutdown=halt'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
@@ -332,7 +332,7 @@ class LinuxSourceTree(object):
def run_kernel(self, args=None, build_dir='', filter_glob='', timeout=None) -> Iterator[str]:
if not args:
args = []
- args.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt'])
+ args.extend(['mem=1G', 'console=tty'])
if filter_glob:
args.append('kunit.filter_glob='+filter_glob)
base-commit: b04d1a8dc7e7ff7ca91a20bef053bcc04265d83a
--
2.35.1.1178.g4f1659d476-goog
The selftest "mqueue/mq_perf_tests.c" use CPU_ALLOC to allocate
CPU set. This cpu set is used further in pthread_attr_setaffinity_np
and by pthread_create in the code. But in current code, allocated
cpu set is not freed.
Fix this issue by adding CPU_FREE in the "shutdown" function which
is called in most of the error/exit path for the cleanup. Also add
CPU_FREE in some of the error paths where shutdown is not called.
Fixes: 7820b0715b6f ("tools/selftests: add mq_perf_tests")
Signed-off-by: Athira Rajeev <atrajeev(a)linux.vnet.ibm.com>
---
Changelog:
From v1 -> v2:
Addressed review comment from Shuah Khan to add
CPU_FREE in other exit paths where it is needed
tools/testing/selftests/mqueue/mq_perf_tests.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c b/tools/testing/selftests/mqueue/mq_perf_tests.c
index b019e0b8221c..182434c7898d 100644
--- a/tools/testing/selftests/mqueue/mq_perf_tests.c
+++ b/tools/testing/selftests/mqueue/mq_perf_tests.c
@@ -180,6 +180,9 @@ void shutdown(int exit_val, char *err_cause, int line_no)
if (in_shutdown++)
return;
+ /* Free the cpu_set allocated using CPU_ALLOC in main function */
+ CPU_FREE(cpu_set);
+
for (i = 0; i < num_cpus_to_pin; i++)
if (cpu_threads[i]) {
pthread_kill(cpu_threads[i], SIGUSR1);
@@ -589,6 +592,7 @@ int main(int argc, char *argv[])
cpu_set)) {
fprintf(stderr, "Any given CPU may "
"only be given once.\n");
+ CPU_FREE(cpu_set);
exit(1);
} else
CPU_SET_S(cpus_to_pin[cpu],
@@ -607,6 +611,7 @@ int main(int argc, char *argv[])
queue_path = malloc(strlen(option) + 2);
if (!queue_path) {
perror("malloc()");
+ CPU_FREE(cpu_set);
exit(1);
}
queue_path[0] = '/';
@@ -619,6 +624,7 @@ int main(int argc, char *argv[])
}
if (continuous_mode && num_cpus_to_pin == 0) {
+ CPU_FREE(cpu_set);
fprintf(stderr, "Must pass at least one CPU to continuous "
"mode.\n");
poptPrintUsage(popt_context, stderr, 0);
@@ -628,10 +634,12 @@ int main(int argc, char *argv[])
cpus_to_pin[0] = cpus_online - 1;
}
- if (getuid() != 0)
+ if (getuid() != 0) {
+ CPU_FREE(cpu_set);
ksft_exit_skip("Not running as root, but almost all tests "
"require root in order to modify\nsystem settings. "
"Exiting.\n");
+ }
max_msgs = fopen(MAX_MSGS, "r+");
max_msgsize = fopen(MAX_MSGSIZE, "r+");
--
2.35.1
This patch series adds a memory.reclaim proactive reclaim interface.
The rationale behind the interface and how it works are in the first
patch.
---
Changes in V2:
- Add the interface to root as well.
- Added a selftest.
- Documented the interface as a nested-keyed interface, which makes
adding optional arguments in the future easier (see doc updates in the
first patch).
- Modified the commit message to reflect changes and add a timeout
argument as a suggested possible extension
- Return -EAGAIN if the kernel fails to reclaim the full requested
amount.
---
Shakeel Butt (1):
memcg: introduce per-memcg reclaim interface
Yosry Ahmed (3):
selftests: cgroup: return the errno of write() in cg_write() on
failure
selftests: cgroup: fix alloc_anon_noexit() instantly freeing memory
selftests: cgroup: add a selftest for memory.reclaim
Documentation/admin-guide/cgroup-v2.rst | 21 +++++
mm/memcontrol.c | 37 ++++++++
tools/testing/selftests/cgroup/cgroup_util.c | 11 ++-
.../selftests/cgroup/test_memcontrol.c | 94 ++++++++++++++++++-
4 files changed, 156 insertions(+), 7 deletions(-)
--
2.35.1.1178.g4f1659d476-goog