selftests: futex: Expand futex testing
cover selftests: futex: Expand futex testing
This patchset expands test coverage for futex, implementing two new
selftests: one for testing different types of futexes and one for the requeue operation.
André Almeida (2):
selftests: futex: Add futex wait test
selftests: futex: Add futex compare requeue test
.../selftests/futex/functional/.gitignore | 2 + .../selftests/futex/functional/Makefile | 4 +- .../futex/functional/futex_requeue.c | 145 ++++++++++++++ .../selftests/futex/functional/futex_wait.c | 180 ++++++++++++++++++ .../testing/selftests/futex/functional/run.sh | 6 + 5 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/futex/functional/futex_requeue.c create mode 100644 tools/testing/selftests/futex/functional/futex_wait.c
Signature · 1 line
2.31.1
PATCH 1/2 selftests: futex: Add futex wait test
There are three different strategies to uniquely identify a futex in the kernel:
- Private futexes: uses the pointer to mm_struct and the page address
- Shared futexes: checks if the page containing the address is a PageAnon:
- If it is, uses the same data as a private futexes
- If it isn't, uses an inode sequence number from struct inode and the page's index
Create a selftest to check those three paths and basic wait/wake mechanism.
--- .../selftests/futex/functional/.gitignore | 1 + .../selftests/futex/functional/Makefile | 3 +- .../selftests/futex/functional/futex_wait.c | 171 ++++++++++++++++++ .../testing/selftests/futex/functional/run.sh | 3 + 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/futex/functional/futex_wait.c
tools/testing/selftests/futex/functional/.gitignore +1 -0
@@ -6,3 +6,4 @@ futex_wait_private_mapped_file futex_wait_timeout futex_wait_uninitialized_heap futex_wait_wouldblock +futex_wait
tools/testing/selftests/futex/functional/Makefile +2 -1
@@ -15,7 +15,8 @@ TEST_GEN_FILES := \ futex_requeue_pi_signal_restart \ futex_requeue_pi_mismatched_ops \ futex_wait_uninitialized_heap \ - futex_wait_private_mapped_file + futex_wait_private_mapped_file \ + futex_wait TEST_PROGS := run.sh
tools/testing/selftests/futex/functional/futex_wait.c new file +171 -0
171 lines not on this page · raw message
tools/testing/selftests/futex/functional/run.sh +3 -0
@@ -73,3 +73,6 @@ echo echo ./futex_wait_uninitialized_heap $COLOR ./futex_wait_private_mapped_file $COLOR + +echo +./futex_wait $COLOR
Signature · 1 line
2.31.1
[tip: locking/core] selftests: futex: Add futex wait test
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: c3d128581f64a9b3729e697a63760ff0a2c4a8fe Gitweb: https://git.kernel.org/tip/c3d128581f64a9b3729e697a63760ff0a2c4a8fe Author: André Almeida <[email protected]> AuthorDate: Mon, 31 May 2021 13:50:35 -03:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 22 Jun 2021 11:20:15 +02:00
selftests: futex: Add futex wait test
There are three different strategies to uniquely identify a futex in the kernel:
- Private futexes: uses the pointer to mm_struct and the page address
- Shared futexes: checks if the page containing the address is a PageAnon:
- If it is, uses the same data as a private futexes
- If it isn't, uses an inode sequence number from struct inode and the page's index
Create a selftest to check those three paths and basic wait/wake mechanism.
--- tools/testing/selftests/futex/functional/.gitignore | 1 +- tools/testing/selftests/futex/functional/Makefile | 3 +- tools/testing/selftests/futex/functional/futex_wait.c | 171 +++++++++- tools/testing/selftests/futex/functional/run.sh | 3 +- 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/futex/functional/futex_wait.c
tools/testing/selftests/futex/functional/.gitignore +1 -0
@@ -6,3 +6,4 @@ futex_wait_private_mapped_file futex_wait_timeout futex_wait_uninitialized_heap futex_wait_wouldblock +futex_wait
tools/testing/selftests/futex/functional/Makefile +2 -1
@@ -15,7 +15,8 @@ TEST_GEN_FILES := \ futex_requeue_pi_signal_restart \ futex_requeue_pi_mismatched_ops \ futex_wait_uninitialized_heap \ - futex_wait_private_mapped_file + futex_wait_private_mapped_file \ + futex_wait TEST_PROGS := run.sh
tools/testing/selftests/futex/functional/futex_wait.c new file +171 -0
171 lines not on this page · raw message
tools/testing/selftests/futex/functional/run.sh +3 -0
@@ -73,3 +73,6 @@ echo echo ./futex_wait_uninitialized_heap $COLOR ./futex_wait_private_mapped_file $COLOR + +echo +./futex_wait $COLOR
PATCH 2/2 selftests: futex: Add futex compare requeue test
In reply to André AlmeidaAdd testing for futex_cmp_requeue(). The first test just requeue from one waiter to another one, and wake it. The second performs both wake and requeue, and we check return values to see if the operation woke/requeued the expected number of waiters.
--- .../selftests/futex/functional/.gitignore | 1 + .../selftests/futex/functional/Makefile | 3 +- .../futex/functional/futex_requeue.c | 136 ++++++++++++++++++ .../testing/selftests/futex/functional/run.sh | 3 + 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/futex/functional/futex_requeue.c
tools/testing/selftests/futex/functional/.gitignore +1 -0
@@ -7,3 +7,4 @@ futex_wait_timeout futex_wait_uninitialized_heap futex_wait_wouldblock futex_wait +futex_requeue
tools/testing/selftests/futex/functional/Makefile +2 -1
@@ -16,7 +16,8 @@ TEST_GEN_FILES := \ futex_requeue_pi_mismatched_ops \ futex_wait_uninitialized_heap \ futex_wait_private_mapped_file \ - futex_wait + futex_wait \ + futex_requeue TEST_PROGS := run.sh
tools/testing/selftests/futex/functional/futex_requeue.c new file +136 -0
136 lines not on this page · raw message
tools/testing/selftests/futex/functional/run.sh +3 -0
@@ -76,3 +76,6 @@ echo echo ./futex_wait $COLOR + +echo +./futex_requeue $COLOR
Signature · 1 line
2.31.1
[tip: locking/core] selftests: futex: Add futex compare requeue test
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 7cb5dd8e2c8ce2b8f778f37cfd8bb955d663d16d Gitweb: https://git.kernel.org/tip/7cb5dd8e2c8ce2b8f778f37cfd8bb955d663d16d Author: André Almeida <[email protected]> AuthorDate: Mon, 31 May 2021 13:50:36 -03:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 22 Jun 2021 11:20:16 +02:00
selftests: futex: Add futex compare requeue test
Add testing for futex_cmp_requeue(). The first test just requeues from one waiter to another one, and wakes it. The second performs both wake and requeue, and checks the return values to see if the operation woke/requeued the expected number of waiters.
--- tools/testing/selftests/futex/functional/.gitignore | 1 +- tools/testing/selftests/futex/functional/Makefile | 3 +- tools/testing/selftests/futex/functional/futex_requeue.c | 136 +++++++- tools/testing/selftests/futex/functional/run.sh | 3 +- 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/futex/functional/futex_requeue.c
tools/testing/selftests/futex/functional/.gitignore +1 -0
@@ -7,3 +7,4 @@ futex_wait_timeout futex_wait_uninitialized_heap futex_wait_wouldblock futex_wait +futex_requeue
tools/testing/selftests/futex/functional/Makefile +2 -1
@@ -16,7 +16,8 @@ TEST_GEN_FILES := \ futex_requeue_pi_mismatched_ops \ futex_wait_uninitialized_heap \ futex_wait_private_mapped_file \ - futex_wait + futex_wait \ + futex_requeue TEST_PROGS := run.sh
tools/testing/selftests/futex/functional/futex_requeue.c new file +136 -0
136 lines not on this page · raw message
tools/testing/selftests/futex/functional/run.sh +3 -0
@@ -76,3 +76,6 @@ echo echo ./futex_wait $COLOR + +echo +./futex_requeue $COLOR
Quoted 3 lines · Andr� Almeida
This patchset expands test coverage for futex, implementing two new
selftests: one for testing different types of futexes and one for the requeue operation.
So these cases are covered by LTP, but I have no objection for also having them in the kernel selftests too.