selftest: Add test for Soft-Dirty PTE bit
PATCH v2 1/1 selftest: Add test for Soft-Dirty PTE bit
This introduces three tests:
1) Sanity check soft dirty basic semantics: allocate area, clean, dirty, check if the SD bit flipped.
2) Check VMA reuse: validate the VM_SOFTDIRTY usage
3) Check soft-dirty on huge pages
This was motivated by Will Deacon's fix commit 912efa17e512 ("mm: proc:
Invalidate TLB after clearing soft-dirty page state"). I was tracking the same issue that he fixed, and this test would have caught it.
--
Changes since V1:
- Fix last minute build break with page_size
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/soft-dirty/.gitignore | 1 + tools/testing/selftests/soft-dirty/Makefile | 9 + .../testing/selftests/soft-dirty/soft-dirty.c | 254 ++++++++++++++++++ 4 files changed, 265 insertions(+) create mode 100644 tools/testing/selftests/soft-dirty/.gitignore create mode 100644 tools/testing/selftests/soft-dirty/Makefile create mode 100644 tools/testing/selftests/soft-dirty/soft-dirty.c
tools/testing/selftests/Makefile +1 -0
@@ -55,6 +55,7 @@ TARGETS += seccomp TARGETS += sgx TARGETS += sigaltstack TARGETS += size +TARGETS += soft-dirty TARGETS += sparc64 TARGETS += splice TARGETS += static_keys
tools/testing/selftests/soft-dirty/.gitignore new file +1 -0
@@ -0,0 +1 @@ +soft-dirty
tools/testing/selftests/soft-dirty/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +top_srcdir = ../../../.. +INSTALL_HDR_PATH = $(top_srcdir)/usr +LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ + +CFLAGS += -Wall -I$(LINUX_HDR_PATH) -O0 -g3 + +TEST_GEN_PROGS := soft-dirty +include ../lib.mk
tools/testing/selftests/soft-dirty/soft-dirty.c new file +254 -0
254 lines not on this page · raw message
Signature · 1 line
2.31.0
Quoted 19 lines · Gabriel Krisman Bertazi
This introduces three tests:
1) Sanity check soft dirty basic semantics: allocate area, clean, dirty, check if the SD bit flipped.
2) Check VMA reuse: validate the
VM_SOFTDIRTYusage3) Check soft-dirty on huge pages
This was motivated by Will Deacon's fix commit
912efa17e512("mm: proc:
Invalidate TLB after clearing soft-dirty page state"). I was tracking the same issue that he fixed, and this test would have caught it.Cc Will Deacon <[email protected]>Signed-off-by Gabriel Krisman Bertazi <[email protected]>--
Changes since V1:
- Fix last minute build break withpage_size
Quoted 9 lines
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/soft-dirty/.gitignore | 1 + tools/testing/selftests/soft-dirty/Makefile | 9 + .../testing/selftests/soft-dirty/soft-dirty.c | 254 ++++++++++++++++++ 4 files changed, 265 insertions(+) create mode 100644 tools/testing/selftests/soft-dirty/.gitignore create mode 100644 tools/testing/selftests/soft-dirty/Makefile create mode 100644 tools/testing/selftests/soft-dirty/soft-dirty.c
Although I think adding a test for this is great (and I certainly wouldn't want to get in the way of that; quite the opposite), I notice that we already have test_softdirty() in selftests/vm/madv_populate.c. Would we be better off extending that test instead of introducing another one?
Will
Quoted 30 lines · Will Deacon
Quoted 19 lines · Gabriel Krisman Bertazi
This introduces three tests:
1) Sanity check soft dirty basic semantics: allocate area, clean, dirty, check if the SD bit flipped.
2) Check VMA reuse: validate the
VM_SOFTDIRTYusage3) Check soft-dirty on huge pages
This was motivated by Will Deacon's fix commit
912efa17e512("mm: proc:
Invalidate TLB after clearing soft-dirty page state"). I was tracking the same issue that he fixed, and this test would have caught it.Cc Will Deacon <[email protected]>Signed-off-by Gabriel Krisman Bertazi <[email protected]>--
Changes since V1:
- Fix last minute build break withpage_sizeQuoted 9 lines
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/soft-dirty/.gitignore | 1 + tools/testing/selftests/soft-dirty/Makefile | 9 + .../testing/selftests/soft-dirty/soft-dirty.c | 254 ++++++++++++++++++ 4 files changed, 265 insertions(+) create mode 100644 tools/testing/selftests/soft-dirty/.gitignore create mode 100644 tools/testing/selftests/soft-dirty/Makefile create mode 100644 tools/testing/selftests/soft-dirty/soft-dirty.c
Quoted 4 lines
Although I think adding a test for this is great (and I certainly wouldn't want to get in the way of that; quite the opposite), I notice that we already have
test_softdirty()inselftests/vm/madv_populate.c. Would we be better off extending that test instead of introducing another one?
Hi, Will. Thanks for the review.
Looks like selftests/vm/madv_populate.c was merged after I sent this, which explains why I missed it. From a quick look, it also doesn't verify the corner case of I'm checking here. I will look into merging the two tests, or at least moving this to vm/ and remove the overlap.
Thanks,
Signature · 1 line
Gabriel Krisman Bertazi