selftests: vm: add process_mrelease tests
Subsystems (2)
PATCH v3 1/1 selftests: vm: add process_mrelease tests
Introduce process_mrelease syscall sanity tests which include tests which expect to fail:
- process_mrelease with invalid pidfd and flags inputs
- process_mrelease on a live process with no pending signals and valid process_mrelease usage which is expected to succeed. Because process_mrelease has to be used against a process with a pending SIGKILL, it's possible that the process exits before process_mrelease gets called. In such cases we retry the test with a victim that allocates twice more memory up to 1GB. This would require the victim process to spend more time during exit and process_mrelease has a better chance of catching the process before it exits and succeeding.
On success the test reports the amount of memory the child had to allocate for reaping to succeed. Sample output:
$ mrelease_test Success reaping a child with 1MB of memory allocations
On failure the test reports the failure. Sample outputs:
$ mrelease_test All process_mrelease attempts failed!
$ mrelease_test process_mrelease: Invalid argument
---
Changes in v3:
- Applied on git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-stable, per Andrew
- Fixed formatting for sample outputs in the description, per Shuah
- Removed pidfd_open, process_mrelease, write_fault_pages functions, per Shuah
- Moved child main routine into its own function, per Shuah
- Followed tools/testing/selftests/pidfd/pidfd.h as a model to deal with undefined syscall numbers, per Shuah
tools/testing/selftests/vm/.gitignore | 1 + tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/mrelease_test.c | 200 +++++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 2 + 4 files changed, 204 insertions(+) create mode 100644 tools/testing/selftests/vm/mrelease_test.c
tools/testing/selftests/vm/.gitignore +1 -0
@@ -10,6 +10,7 @@ map_populate thuge-gen compaction_test mlock2-tests +mrelease_test mremap_dontunmap mremap_test on-fault-limit
tools/testing/selftests/vm/Makefile +1 -0
@@ -44,6 +44,7 @@ TEST_GEN_FILES += memfd_secret TEST_GEN_FILES += migration TEST_GEN_FILES += mlock-random-test TEST_GEN_FILES += mlock2-tests +TEST_GEN_FILES += mrelease_test TEST_GEN_FILES += mremap_dontunmap TEST_GEN_FILES += mremap_test TEST_GEN_FILES += on-fault-limit
tools/testing/selftests/vm/mrelease_test.c new file +200 -0
200 lines not on this page · raw message
tools/testing/selftests/vm/run_vmtests.sh +2 -0
@@ -141,6 +141,8 @@ run_test ./mlock-random-test run_test ./mlock2-tests +run_test ./mrelease_test + run_test ./mremap_test run_test ./thuge-gen
Signature · 1 line
2.36.1.124.g0e6072fb45-goog
Quoted 27 lines · Suren Baghdasaryan
Introduce
process_mreleasesyscall sanity tests which include tests which expect to fail:
-process_mreleasewith invalid pidfd and flags inputs
-process_mreleaseon a live process with no pending signals and validprocess_mreleaseusage which is expected to succeed. Becauseprocess_mreleasehas to be used against a process with a pending SIGKILL, it's possible that the process exits beforeprocess_mreleasegets called. In such cases we retry the test with a victim that allocates twice more memory up to 1GB. This would require the victim process to spend more time during exit andprocess_mreleasehas a better chance of catching the process before it exits and succeeding.On success the test reports the amount of memory the child had to allocate for reaping to succeed. Sample output:
$ mrelease_test Success reaping a child with 1MB of memory allocationsOn failure the test reports the failure. Sample outputs:
$ mrelease_test All process_mrelease attempts failed!$ mrelease_test process_mrelease: Invalid argumentSigned-off-by Suren Baghdasaryan <[email protected]>
Quoted 10 lines
---
Changes in v3:
- Applied ongit://git.kernel.org/pub/scm/linux/kernel/git/akpm/mmmm-stable, per Andrew
- Fixed formatting for sample outputs in the description, per Shuah
- Removedpidfd_open,process_mrelease,write_fault_pagesfunctions, per Shuah
- Moved child main routine into its own function, per Shuah
- Followedtools/testing/selftests/pidfd/pidfd.has a model to deal with undefined syscall numbers, per Shuah
Looks good to me Suren. Thank you.
thanks,
-- Shuah
Quoted 20 lines · Suren Baghdasaryan
Introduce
process_mreleasesyscall sanity tests which include tests which expect to fail:
-process_mreleasewith invalid pidfd and flags inputs
-process_mreleaseon a live process with no pending signals and validprocess_mreleaseusage which is expected to succeed. Becauseprocess_mreleasehas to be used against a process with a pending SIGKILL, it's possible that the process exits beforeprocess_mreleasegets called. In such cases we retry the test with a victim that allocates twice more memory up to 1GB. This would require the victim process to spend more time during exit andprocess_mreleasehas a better chance of catching the process before it exits and succeeding.On success the test reports the amount of memory the child had to allocate for reaping to succeed. Sample output:
$ mrelease_test Success reaping a child with 1MB of memory allocationsOn failure the test reports the failure. Sample outputs:
Quoted 8 lines
$ mrelease_test All process_mrelease attempts failed!$ mrelease_test process_mrelease: Invalid argumentSigned-off-by Suren Baghdasaryan <[email protected]>---
Thanks your adding selftests, Suren!
Quoted 20 lines · Suren Baghdasaryan
Introduce
process_mreleasesyscall sanity tests which include tests which expect to fail:
-process_mreleasewith invalid pidfd and flags inputs
-process_mreleaseon a live process with no pending signals and validprocess_mreleaseusage which is expected to succeed. Becauseprocess_mreleasehas to be used against a process with a pending SIGKILL, it's possible that the process exits beforeprocess_mreleasegets called. In such cases we retry the test with a victim that allocates twice more memory up to 1GB. This would require the victim process to spend more time during exit andprocess_mreleasehas a better chance of catching the process before it exits and succeeding.On success the test reports the amount of memory the child had to allocate for reaping to succeed. Sample output:
$ mrelease_test Success reaping a child with 1MB of memory allocationsOn failure the test reports the failure. Sample outputs:
Quoted 7 lines
$ mrelease_test All process_mrelease attempts failed!$ mrelease_test process_mrelease: Invalid argumentSigned-off-by Suren Baghdasaryan <[email protected]>
Signature · 1 line
Muhammad Usama Anjum