Skip to contentSkip to conversation

fstests: add stress truncation + writeback + compaction split test

RFC New Luis Chamberlain 1 participant 1 message Apr 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 fstests: add stress truncation + writeback + compaction split test

Stress test folio splits by using the debugfs interface to a target a new smaller folio order while running compaction at the same time. This is dangerous at the moment as its using a debugfs API which requires two out of tree fixes [0] [1] which have already been posted but not yet merged.

With these debugfs patches applied this test can now be used to reproduce an issue which was only possible to reproduce by running generic/447 twice with min order:

https://gist.github.com/mcgrof/d12f586ec6ebe32b2472b5d634c397df

This is designed to try to exacerbate races with folio splits incurred by truncation and race that with compaction and writeback. This only creates a crash with min order enabled, so for example with a 16k block sized XFS test profile.

This also begs the question if something like MADV_NOHUGEPAGE might be desirable from userspace, so to enable userspace to request splits when possible.

If inspecting more closely, you'll want to enable on your kernel boot:

dyndbg='file mm/huge_memory.c +p'

Since we want to race large folio splits we also augment the full test output log $seqres.full with the test specific number of successful splits from vmstat thp_split_page and thp_split_page_failed.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/commit/?h=20240424-lbs&id=80f6df5037fd0ad560526af45bd7f4d779fe03f6
[1] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/commit/?h=20240424-lbs&id=38f6fac5b4283ea48b1876fc56728f062168f8c3

---

For now at laest to allow people to more easily reproduce the crash we're discussing here:

https://lkml.kernel.org/r/[email protected]

I can clean this up based on Zorro's feedback after this. Posting this RFCv2 so to enable folks to more easily reproduce the issue and also the debugfs issue that this uses.

 common/rc             |  20 ++++++++
 tests/generic/745     | 115 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/745.out |   2 +
 3 files changed, 137 insertions(+)
 create mode 100755 tests/generic/745
 create mode 100644 tests/generic/745.out
common/rc +20 -0
index d4432f5ce259..1eefb53aa84b 100644
@@ -127,6 +127,26 @@ _require_compaction()
 	    _notrun "Need compaction enabled CONFIG_COMPACTION=y"
 	fi
 }
+
+# Requires CONFIG_DEBUGFS and truncation knobs
+SPLIT_DEBUGFS="/sys/kernel/debug/split_huge_pages"
+_require_split_debugfs()
+{
+       if [ ! -f $SPLIT_DEBUGFS ]; then
+           _notrun "Needs CONFIG_DEBUGFS and split_huge_pages"
+       fi
+}
+
+_split_huge_pages_file_full()
+{
+	local file=$1
+	local offset="0x0"
+	local len=$(printf "%x" $(stat --format='%s' $file))
+	local order="0"
+	local split_cmd="$file,$offset,0x${len},$order"
+	echo $split_cmd > $SPLIT_DEBUGFS
+}
+
 # Get hugepagesize in bytes
 _get_hugepagesize()
 {
tests/generic/745 new file +115 -0

115 lines not on this page · raw message

tests/generic/745.out new file +2 -0
new file mode 100644
index 000000000000..fce6b7f5489d
@@ -0,0 +1,2 @@
+QA output created by 745
+Silence is golden
Signature · 1 line
2.43.0