The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavoars(a)kernel.org>
---
tools/testing/selftests/nsfs/pidns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nsfs/pidns.c b/tools/testing/selftests/nsfs/pidns.c
index e0d86e1668c0..e3c772c6a7c7 100644
--- a/tools/testing/selftests/nsfs/pidns.c
+++ b/tools/testing/selftests/nsfs/pidns.c
@@ -27,7 +27,7 @@
#define __stack_aligned__ __attribute__((aligned(16)))
struct cr_clone_arg {
char stack[128] __stack_aligned__;
- char stack_ptr[0];
+ char stack_ptr[];
};
static int child(void *args)
Hi Linus,
Please pull the following Kselftest update for Linux 5.7-rc5.
This Kselftest update for Linux 5.7-rc5 consists of ftrace test
fixes and fix to kvm Makefile for relocatable native/cross builds
and installs.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit f0c0d0cf590f71b2213b29a7ded2cde3d0a1a0ba:
selftests/ftrace: Check the first record for kprobe_args_type.tc
(2020-04-24 09:39:26 -0600)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-5.7-rc5
for you to fetch changes up to 66d69e081b526b6a6031f0d3ca8ddff71e5707a5:
selftests: fix kvm relocatable native/cross builds and installs
(2020-05-01 09:47:55 -0600)
----------------------------------------------------------------
linux-kselftest-5.7-rc5
This Kselftest update for Linux 5.7-rc5 consists of ftrace test fixes
and fix to kvm Makefile for relocatable native/cross builds and installs.
----------------------------------------------------------------
Alan Maguire (2):
ftrace/selftests: workaround cgroup RT scheduling issues
ftrace/selftest: make unresolved cases cause failure if
--fail-unresolved set
Masami Hiramatsu (1):
selftests/ftrace: Make XFAIL green color
Shuah Khan (1):
selftests: fix kvm relocatable native/cross builds and installs
tools/testing/selftests/ftrace/ftracetest | 32
+++++++++++++++++++++++++++++--
tools/testing/selftests/kvm/Makefile | 29
+++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 3 deletions(-)
----------------------------------------------------------------
Hello Sai Praneeth Prakhya,
The patch 7f4d257e3a2a: "selftests/resctrl: Add callback to start a
benchmark" from Jan 16, 2020, leads to the following static checker
warning:
tools/testing/selftests/resctrl/resctrl_val.c:545 measure_vals()
warn: 'bw_imc' unsigned <= 0
tools/testing/selftests/resctrl/resctrl_val.c:549 measure_vals()
warn: 'bw_resc_end' unsigned <= 0
tools/testing/selftests/resctrl/resctrl_val.c
531 static int
532 measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start)
533 {
534 unsigned long bw_imc, bw_resc, bw_resc_end;
535 int ret;
536
537 /*
538 * Measure memory bandwidth from resctrl and from
539 * another source which is perf imc value or could
540 * be something else if perf imc event is not available.
541 * Compare the two values to validate resctrl value.
542 * It takes 1sec to measure the data.
543 */
544 bw_imc = get_mem_bw_imc(param->cpu_no, param->bw_report);
545 if (bw_imc <= 0)
^^^^^^^^^^^
Unsigned. Also the comments for get_mem_bw_imc() says that zero is
success.
546 return bw_imc;
547
548 bw_resc_end = get_mem_bw_resctrl();
549 if (bw_resc_end <= 0)
^^^^^^^^^^^^^^^^
Unsigned
550 return bw_resc_end;
551
552 bw_resc = (bw_resc_end - *bw_resc_start) / MB;
553 ret = print_results_bw(param->filename, bm_pid, bw_imc, bw_resc);
554 if (ret)
555 return ret;
556
557 *bw_resc_start = bw_resc_end;
558
559 return 0;
560 }
regards,
dan carpenter
From: Xiao Yang <yangx.jy(a)cn.fujitsu.com>
[ Upstream commit f0c0d0cf590f71b2213b29a7ded2cde3d0a1a0ba ]
It is possible to get multiple records from trace during test and then more
than 4 arguments are assigned to ARGS. This situation results in the failure
of kprobe_args_type.tc. For example:
-----------------------------------------------------------
grep testprobe trace
ftracetest-5902 [001] d... 111195.682227: testprobe: (_do_fork+0x0/0x460) arg1=334823024 arg2=334823024 arg3=0x13f4fe70 arg4=7
pmlogger-5949 [000] d... 111195.709898: testprobe: (_do_fork+0x0/0x460) arg1=345308784 arg2=345308784 arg3=0x1494fe70 arg4=7
grep testprobe trace
sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'
ARGS='334823024 334823024 0x13f4fe70 7
345308784 345308784 0x1494fe70 7'
-----------------------------------------------------------
We don't care which process calls do_fork so just check the first record to
fix the issue.
Signed-off-by: Xiao Yang <yangx.jy(a)cn.fujitsu.com>
Acked-by: Masami Hiramatsu <mhiramat(a)kernel.org>
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
.../testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
index 1bcb67dcae267..81490ecaaa927 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
@@ -38,7 +38,7 @@ for width in 64 32 16 8; do
echo 0 > events/kprobes/testprobe/enable
: "Confirm the arguments is recorded in given types correctly"
- ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
+ ARGS=`grep "testprobe" trace | head -n 1 | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
check_types $ARGS $width
: "Clear event for next loop"
--
2.20.1
From: Xiao Yang <yangx.jy(a)cn.fujitsu.com>
[ Upstream commit f0c0d0cf590f71b2213b29a7ded2cde3d0a1a0ba ]
It is possible to get multiple records from trace during test and then more
than 4 arguments are assigned to ARGS. This situation results in the failure
of kprobe_args_type.tc. For example:
-----------------------------------------------------------
grep testprobe trace
ftracetest-5902 [001] d... 111195.682227: testprobe: (_do_fork+0x0/0x460) arg1=334823024 arg2=334823024 arg3=0x13f4fe70 arg4=7
pmlogger-5949 [000] d... 111195.709898: testprobe: (_do_fork+0x0/0x460) arg1=345308784 arg2=345308784 arg3=0x1494fe70 arg4=7
grep testprobe trace
sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'
ARGS='334823024 334823024 0x13f4fe70 7
345308784 345308784 0x1494fe70 7'
-----------------------------------------------------------
We don't care which process calls do_fork so just check the first record to
fix the issue.
Signed-off-by: Xiao Yang <yangx.jy(a)cn.fujitsu.com>
Acked-by: Masami Hiramatsu <mhiramat(a)kernel.org>
Signed-off-by: Shuah Khan <skhan(a)linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
.../testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
index 1bcb67dcae267..81490ecaaa927 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
@@ -38,7 +38,7 @@ for width in 64 32 16 8; do
echo 0 > events/kprobes/testprobe/enable
: "Confirm the arguments is recorded in given types correctly"
- ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
+ ARGS=`grep "testprobe" trace | head -n 1 | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
check_types $ARGS $width
: "Clear event for next loop"
--
2.20.1
The UNRESOLVED state is much more apporiate than the UNSUPPORTED state
for the absence of the test module, as it matches "test was set up
incorrectly" situation in the README file.
A possible scenario is that the function was enabled (supported by the
kernel) but the module was not installed properly, in this case we
cannot call this as UNSUPPORTED.
This change also make it consistent with other module-related tests
in ftrace.
Signed-off-by: Po-Hsu Lin <po-hsu.lin(a)canonical.com>
---
.../testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
index cbd1743..2b82c80e 100644
--- a/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
+++ b/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc
@@ -17,7 +17,14 @@ unsup() { #msg
exit_unsupported
}
-modprobe $MOD || unsup "$MOD module not available"
+unres() { #msg
+ reset_tracer
+ rmmod $MOD || true
+ echo $1
+ exit_unresolved
+}
+
+modprobe $MOD || unres "$MOD module not available"
rmmod $MOD
grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled"
--
2.7.4
This makes it easier to enable all KUnit fragments.
Adding 'if !KUNIT_RUN_ALL' so individual test can be turned of if
someone wants that even though KUNIT_RUN_ALL is enabled.
Signed-off-by: Anders Roxell <anders.roxell(a)linaro.org>
---
lib/kunit/Kconfig | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index 537f37bc8400..e6a60391fa6b 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -15,7 +15,8 @@ menuconfig KUNIT
if KUNIT
config KUNIT_DEBUGFS
- bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation"
+ bool "KUnit - Enable /sys/kernel/debug/kunit debugfs representation" if !KUNIT_RUN_ALL
+ default KUNIT_RUN_ALL
help
Enable debugfs representation for kunit. Currently this consists
of /sys/kernel/debug/kunit/<test_suite>/results files for each
@@ -23,7 +24,8 @@ config KUNIT_DEBUGFS
run that occurred.
config KUNIT_TEST
- tristate "KUnit test for KUnit"
+ tristate "KUnit test for KUnit" if !KUNIT_RUN_ALL
+ default KUNIT_RUN_ALL
help
Enables the unit tests for the KUnit test framework. These tests test
the KUnit test framework itself; the tests are both written using
@@ -32,7 +34,8 @@ config KUNIT_TEST
expected.
config KUNIT_EXAMPLE_TEST
- tristate "Example test for KUnit"
+ tristate "Example test for KUnit" if !KUNIT_RUN_ALL
+ default KUNIT_RUN_ALL
help
Enables an example unit test that illustrates some of the basic
features of KUnit. This test only exists to help new users understand
--
2.20.1
Make it easier to enable all KUnit fragments. This is needed for kernel
test-systems, so its easy to get all KUnit tests enabled and if new gets
added they will be enabled as well. Fragments that has to be builtin
will be missed if CONFIG_KUNIT_RUN_ALL is set as a module.
Signed-off-by: Anders Roxell <anders.roxell(a)linaro.org>
---
lib/kunit/Kconfig | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index 95d12e3d6d95..537f37bc8400 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -41,4 +41,10 @@ config KUNIT_EXAMPLE_TEST
is intended for curious hackers who would like to understand how to
use KUnit for kernel development.
+config KUNIT_RUN_ALL
+ tristate "KUnit run all test"
+ help
+ Enables all KUnit tests, if they can be enabled.
+ That depends on if KUnit is enabled as a module or builtin.
+
endif # KUNIT
--
2.20.1
This series adds basic self tests for HMM and are intended for Jason
Gunthorpe's rdma tree since he is making some HMM related changes that
this can help test.
Changes v9 -> v10:
Patches 1 & 2 include Jason's changes from his cover letter:
https://lkml.org/lkml/2020/4/21/1320
Patch 3 now adds the files alphbetically and removed the outdated
reference to include/uapi/linux.
Changes v8 -> v9:
Rebased to linux-5.7.0-rc1.
Moved include/uapi/linux/test_hmm.h to lib/test_hmm_uapi.h
Added calls to release_mem_region() to free device private addresses
Applied Jason's suggested changes for v8.
Added a check for no VMA read access before migrating to device private
memory.
Changes v7 -> v8:
Rebased to Jason's rdma/hmm tree, plus Jason's 6 patch series
"Small hmm_range_fault() cleanups".
Applied a number of changes from Jason's comments.
Changes v6 -> v7:
Rebased to linux-5.6.0-rc6
Reverted back to just using mmu_interval_notifier_insert() and making
this series only introduce HMM self tests.
Changes v5 -> v6:
Rebased to linux-5.5.0-rc6
Refactored mmu interval notifier patches
Converted nouveau to use the new mmu interval notifier API
Changes v4 -> v5:
Added mmu interval notifier insert/remove/update callable from the
invalidate() callback
Updated HMM tests to use the new core interval notifier API
Changes v1 -> v4:
https://lore.kernel.org/linux-mm/20191104222141.5173-1-rcampbell@nvidia.com
Ralph Campbell (3):
mm/hmm/test: add selftest driver for HMM
mm/hmm/test: add selftests for HMM
MAINTAINERS: add HMM selftests
MAINTAINERS | 2 +
lib/Kconfig.debug | 13 +
lib/Makefile | 1 +
lib/test_hmm.c | 1149 ++++++++++++++++++++
lib/test_hmm_uapi.h | 59 +
tools/testing/selftests/vm/.gitignore | 1 +
tools/testing/selftests/vm/Makefile | 3 +
tools/testing/selftests/vm/config | 2 +
tools/testing/selftests/vm/hmm-tests.c | 1359 ++++++++++++++++++++++++
tools/testing/selftests/vm/run_vmtests | 16 +
tools/testing/selftests/vm/test_hmm.sh | 97 ++
11 files changed, 2702 insertions(+)
create mode 100644 lib/test_hmm.c
create mode 100644 lib/test_hmm_uapi.h
create mode 100644 tools/testing/selftests/vm/hmm-tests.c
create mode 100755 tools/testing/selftests/vm/test_hmm.sh
--
2.25.2
This series extends the kselftests for the vDSO library making sure: that
they compile correctly on non x86 platforms, that they can be cross
compiled and introducing new tests that verify the correctness of the
library.
The so extended vDSO kselftests have been verified on all the platforms
supported by the unified vDSO library [1].
The only new patch that this series introduces is the first one, patch 2 and
patch 3 have already been reviewed in past as part of other series [2] [3].
[1] https://lore.kernel.org/lkml/20190621095252.32307-1-vincenzo.frascino@arm.c…
[2] https://lore.kernel.org/lkml/20190621095252.32307-26-vincenzo.frascino@arm.…
[3] https://lore.kernel.org/lkml/20190523112116.19233-4-vincenzo.frascino@arm.c…
Changes:
--------
v3:
- Added correctness test for clock_gettime64.
- Rebased on 5.7-rc4.
v2:
- Addressed review comments from Andy.
- Rebased on 5.7-rc3.
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Andy Lutomirski <luto(a)kernel.org>
Cc: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino(a)arm.com>
Vincenzo Frascino (5):
kselftest: Enable vDSO test on non x86 platforms
kselftest: Extend vDSO selftest
kselftest: Extend vDSO selftest to clock_getres
kselftest: Move test_vdso to the vDSO test suite
kselftest: Extend vdso correctness test to clock_gettime64
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/vDSO/Makefile | 16 +-
.../selftests/vDSO/vdso_clock_getres.c | 124 +++++++++
tools/testing/selftests/vDSO/vdso_config.h | 92 +++++++
.../vdso_correctness_test.c} | 115 ++++++++-
tools/testing/selftests/vDSO/vdso_full_test.c | 244 ++++++++++++++++++
tools/testing/selftests/x86/Makefile | 2 +-
7 files changed, 586 insertions(+), 8 deletions(-)
create mode 100644 tools/testing/selftests/vDSO/vdso_clock_getres.c
create mode 100644 tools/testing/selftests/vDSO/vdso_config.h
rename tools/testing/selftests/{x86/test_vdso.c => vDSO/vdso_correctness_test.c} (73%)
create mode 100644 tools/testing/selftests/vDSO/vdso_full_test.c
--
2.26.2