Currently we don't have full automated tests for the vector length
configuation ABIs offered for SVE, we have a helper binary for setting
the vector length which can be used for manual tests and we use the
prctl() interface to enumerate the vector lengths but don't actually
verify that the vector lengths enumerated were set.
This patch series provides a small helper which allows us to get the
currently configured vector length using the RDVL instruction via either
a library call or stdout of a process and then uses this to both add
verification of enumerated vector lengths to our existing tests and also
add a new test program which exercises both the prctl() and sysfs
interfaces.
In preparation for the forthcomng support for the Scalable Matrix
Extension (SME) [1] which introduces a new vector length managed via a
very similar hardware interface the helper and new test program are
parameterised with the goal of allowing reuse for SME.
[1] https://community.arm.com/developer/ip-products/processors/b/processors-ip-…
v2:
- Tweak log message on failure in sve-probe-vls.
- Stylistic changes in vec-syscfg.
- Flush stdout before forking in vec-syscfg.
- Use EXIT_FAILURE.
- Use fdopen() to get child output.
- Replace a bunch of UNIX API usage with stdio.
- Add a TODO list.
- Verify that we're root before testing writes to /proc.
Mark Brown (4):
kselftest/arm64: Provide a helper binary and "library" for SVE RDVL
kselftest/arm64: Validate vector lengths are set in sve-probe-vls
kselftest/arm64: Add tests for SVE vector configuration
kselftest/arm64: Add a TODO list for floating point tests
tools/testing/selftests/arm64/fp/.gitignore | 2 +
tools/testing/selftests/arm64/fp/Makefile | 11 +-
tools/testing/selftests/arm64/fp/TODO | 3 +
tools/testing/selftests/arm64/fp/rdvl-sve.c | 14 +
tools/testing/selftests/arm64/fp/rdvl.S | 9 +
tools/testing/selftests/arm64/fp/rdvl.h | 8 +
.../selftests/arm64/fp/sve-probe-vls.c | 5 +
tools/testing/selftests/arm64/fp/vec-syscfg.c | 580 ++++++++++++++++++
8 files changed, 629 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/arm64/fp/TODO
create mode 100644 tools/testing/selftests/arm64/fp/rdvl-sve.c
create mode 100644 tools/testing/selftests/arm64/fp/rdvl.S
create mode 100644 tools/testing/selftests/arm64/fp/rdvl.h
create mode 100644 tools/testing/selftests/arm64/fp/vec-syscfg.c
base-commit: ff1176468d368232b684f75e82563369208bc371
--
2.20.1
On Fri, Jul 23, 2021 at 2:24 PM Bart Van Assche <bvanassche(a)acm.org> wrote:
>
> Cc: Brendan Higgins <brendanhiggins(a)google.com>
> Cc: Bodo Stroesser <bostroesser(a)gmail.com>
> Cc: Martin K. Petersen <martin.petersen(a)oracle.com>
> Cc: Yanko Kaneti <yaneti(a)declera.com>
Please also CC davidgow(a)google.com, skhan(a)linuxfoundation.org,
kunit-dev(a)googlegroups.com, and linux-kselftest(a)vger.kernel.org for
KUnit changes in the future.
> Signed-off-by: Bart Van Assche <bvanassche(a)acm.org>
This seems pretty sensible.
Reviewed-by: Brendan Higgins <brendanhiggins(a)google.com>
> ---
> include/kunit/test.h | 4 ++++
> lib/kunit/test.c | 14 ++++++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index 24b40e5c160b..a6eef96a409c 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -215,6 +215,8 @@ static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
> * struct kunit_suite - describes a related collection of &struct kunit_case
> *
> * @name: the name of the test. Purely informational.
> + * @init_suite: called once per test suite before the test cases.
> + * @exit_suite: called once per test suite after all test cases.
> * @init: called before every test case.
> * @exit: called after every test case.
> * @test_cases: a null terminated array of test cases.
> @@ -229,6 +231,8 @@ static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
> */
> struct kunit_suite {
> const char name[256];
> + int (*init_suite)(void);
> + void (*exit_suite)(void);
I like this idea. Many other unit testing libraries in other languages
have something similar.
I think it probably makes sense to not use any kind of context object
here (as you have done); nevertheless, I still think it is an
appropriate question for the list.
> int (*init)(struct kunit *test);
> void (*exit)(struct kunit *test);
> struct kunit_case *test_cases;
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index d79ecb86ea57..c271692ced93 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -397,9 +397,19 @@ int kunit_run_tests(struct kunit_suite *suite)
> {
> char param_desc[KUNIT_PARAM_DESC_SIZE];
> struct kunit_case *test_case;
> + int res = 0;
>
> kunit_print_subtest_start(suite);
>
> + if (suite->init_suite)
> + res = suite->init_suite();
> +
> + if (res < 0) {
> + kunit_log(KERN_INFO, suite, KUNIT_SUBTEST_INDENT
> + "# Suite initialization failed (%d)\n", res);
> + goto end;
> + }
> +
> kunit_suite_for_each_test_case(suite, test_case) {
> struct kunit test = { .param_value = NULL, .param_index = 0 };
> test_case->status = KUNIT_SKIPPED;
> @@ -439,6 +449,10 @@ int kunit_run_tests(struct kunit_suite *suite)
> test.status_comment);
> }
>
> + if (suite->exit_suite)
> + suite->exit_suite();
> +
> +end:
> kunit_print_subtest_end(suite);
>
> return 0;
Currently we don't have full automated tests for the vector length
configuation ABIs offered for SVE, we have a helper binary for setting
the vector length which can be used for manual tests and we use the
prctl() interface to enumerate the vector lengths but don't actually
verify that the vector lengths enumerated were set.
This patch series provides a small helper which allows us to get the
currently configured vector length using the RDVL instruction via either
a library call or stdout of a process and then uses this to both add
verification of enumerated vector lengths to our existing tests and also
add a new test program which exercises both the prctl() and sysfs
interfaces.
In preparation for the forthcomng support for the Scalable Matrix
Extension (SME) [1] which introduces a new vector length managed via a
very similar hardware interface the helper and new test program are
parameterised with the goal of allowing reuse for SME.
[1] https://community.arm.com/developer/ip-products/processors/b/processors-ip-…
Mark Brown (3):
kselftest/arm64: Provide a helper binary and "library" for SVE RDVL
kselftest/arm64: Validate vector lengths are set in sve-probe-vls
kselftest/arm64: Add tests for SVE vector configuration
tools/testing/selftests/arm64/fp/.gitignore | 2 +
tools/testing/selftests/arm64/fp/Makefile | 11 +-
tools/testing/selftests/arm64/fp/rdvl-sve.c | 14 +
tools/testing/selftests/arm64/fp/rdvl.S | 9 +
tools/testing/selftests/arm64/fp/rdvl.h | 8 +
.../selftests/arm64/fp/sve-probe-vls.c | 5 +
tools/testing/selftests/arm64/fp/vec-syscfg.c | 578 ++++++++++++++++++
7 files changed, 624 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/arm64/fp/rdvl-sve.c
create mode 100644 tools/testing/selftests/arm64/fp/rdvl.S
create mode 100644 tools/testing/selftests/arm64/fp/rdvl.h
create mode 100644 tools/testing/selftests/arm64/fp/vec-syscfg.c
base-commit: ff1176468d368232b684f75e82563369208bc371
--
2.20.1
There is quite a bit of tribal knowledge around proper use of
try_module_get() and that it must be used only in a context which
can ensure the module won't be gone during the operation. Document
this little bit of tribal knowledge.
Signed-off-by: Luis Chamberlain <mcgrof(a)kernel.org>
---
kernel/module.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/kernel/module.c b/kernel/module.c
index ed13917ea5f3..0d609647a54d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1066,6 +1066,28 @@ void __module_get(struct module *module)
}
EXPORT_SYMBOL(__module_get);
+/**
+ * try_module_get - yields to module removal and bumps reference count otherwise
+ * @module: the module we should check for
+ *
+ * This can be used to check if userspace has requested to remove a module,
+ * and if so let the caller give up. Otherwise it takes a reference count to
+ * ensure a request from userspace to remove the module cannot happen.
+ *
+ * Care must be taken to ensure the module cannot be removed during
+ * try_module_get(). This can be done by having another entity other than the
+ * module itself increment the module reference count, or through some other
+ * means which gaurantees the module could not be removed during an operation.
+ * An example of this later case is using this call in a sysfs file which the
+ * module created. The sysfs store / read file operation is ensured to exist
+ * and still be present by kernfs's active reference. If a sysfs file operation
+ * is being run, the module which created it must still exist as the module is
+ * in charge of removal of the sysfs file.
+ *
+ * The real value to try_module_get() is the module_is_live() check which
+ * ensures this the caller of try_module_get() can yields to userspace module
+ * removal requests and fail whatever it was about to process.
+ */
bool try_module_get(struct module *module)
{
bool ret = true;
--
2.30.2
The XSAVE feature set supports the saving and restoring of state components
such as FPU, which is used for process context switching.
In order to ensure that XSAVE works correctly, add XSAVE basic test for
XSAVE architecture functionality.
This patch set tests XSAVE/XRSTOR instructions on x86 platforms and verify if
the XSAVE/XRSTOR works correctly during signal handling.
Cases such as signal handling, process creation, other xstate(except FPU)
tests for XSAVE check, etc. will be added to the Linux kernel self-test.
If appropriate, it is even planned to add the [1] mentioned XSAVE issues
reproduce and some XSAVE anomaly tests to the kernel self-test.
[1]: https://lore.kernel.org/lkml/0000000000004c453905c30f8334@google.com/
Pengfei Xu (2):
selftests/xsave: test basic XSAVE architecture functionality
selftests/xsave: add xsave test during signal handling
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/xsave/.gitignore | 3 +
tools/testing/selftests/xsave/Makefile | 6 +
tools/testing/selftests/xsave/xsave_common.h | 246 ++++++++++++++++++
.../selftests/xsave/xsave_instruction.c | 83 ++++++
.../selftests/xsave/xsave_signal_handle.c | 184 +++++++++++++
6 files changed, 523 insertions(+)
create mode 100644 tools/testing/selftests/xsave/.gitignore
create mode 100644 tools/testing/selftests/xsave/Makefile
create mode 100644 tools/testing/selftests/xsave/xsave_common.h
create mode 100644 tools/testing/selftests/xsave/xsave_instruction.c
create mode 100644 tools/testing/selftests/xsave/xsave_signal_handle.c
--
2.20.1
This v2 rebases onto the latest linux-next tag, next-20210701. A few
changes were needed, namely:
1) changes kernfs_init_failure_injection() to return int instead
of void. On the latest linux-next we have a new static build
check for this, so this mistake was captured when building.
2) I made kernfs_init_failure_injection static
3) lib/test_sysfs.c moved to the new blk_alloc_disk() added by
Christoph as direct queue allocation is no longer supported,
ie, blk_alloc_queue() is no longer exported. This work was
done by Christoph in preparation to help make add_disk*()
callers eventually return an error code and make the error
handling much saner. Because of this same change
blk_cleanup_queue() is no longer needed so we embrace
the shiny new blk_cleanup_disk().
I've put this up on my linux-next git tree [0] under the branch
named 20210701-sysfs-fix-races-v2.
[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?…
Luis Chamberlain (4):
selftests: add tests_sysfs module
kernfs: add initial failure injection support
test_sysfs: add support to use kernfs failure injection
test_sysfs: demonstrate deadlock fix
.../fault-injection/fault-injection.rst | 22 +
MAINTAINERS | 9 +-
fs/kernfs/Makefile | 1 +
fs/kernfs/failure-injection.c | 83 +
fs/kernfs/file.c | 13 +
fs/kernfs/kernfs-internal.h | 72 +
include/linux/kernfs.h | 5 +
lib/Kconfig.debug | 23 +
lib/Makefile | 1 +
lib/test_sysfs.c | 1027 ++++++++++++
tools/testing/selftests/sysfs/Makefile | 12 +
tools/testing/selftests/sysfs/config | 5 +
tools/testing/selftests/sysfs/sysfs.sh | 1376 +++++++++++++++++
13 files changed, 2648 insertions(+), 1 deletion(-)
create mode 100644 fs/kernfs/failure-injection.c
create mode 100644 lib/test_sysfs.c
create mode 100644 tools/testing/selftests/sysfs/Makefile
create mode 100644 tools/testing/selftests/sysfs/config
create mode 100755 tools/testing/selftests/sysfs/sysfs.sh
--
2.27.0