diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-07 06:02:11 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-07 06:02:11 -0500 |
commit | c608f90ade5d3375db8bbb9fd7b5a8ea452529c8 (patch) | |
tree | b14fd1f7b946f157e534ee4c85989df9190110f6 | |
parent | f53d7cd3314e0820f38f9d99d25b67c198b0eab9 (diff) |
tests/bcachefs: Improvements for counter checking
- check_counters now supports an optional ratio, for tests that just
inherently see more slowpath events
- when we fail a test due to too many slowpath events, dump a sample of
those events from the trace buffer
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | tests/bcachefs/bcachefs-test-libs.sh | 37 | ||||
-rwxr-xr-x | tests/bcachefs/replication.ktest | 1 | ||||
-rw-r--r-- | tests/test-libs.sh | 23 |
3 files changed, 41 insertions, 20 deletions
diff --git a/tests/bcachefs/bcachefs-test-libs.sh b/tests/bcachefs/bcachefs-test-libs.sh index 22f7b19..e9662c7 100644 --- a/tests/bcachefs/bcachefs-test-libs.sh +++ b/tests/bcachefs/bcachefs-test-libs.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Library with some functions for writing bcachefs tests using the # ktest framework. @@ -115,11 +116,15 @@ antagonist_cat_sysfs_debugfs() bcachefs_antagonist() { - #setup_tracing - #setup_tracing 'bcachefs:*' + # Enable all bcachefs tracepoints - good for test coverage + setup_tracing 'bcachefs:*' + + # Or alternately, only enable events check_counters will want to dump: + #local ev=/sys/kernel/tracing/events/bcachefs/ + #echo 1|tee "$ev"/*fail*/enable "$ev"/*restart*/enable "$ev"/*blocked*/enable + #echo 1 > /sys/module/bcachefs/parameters/expensive_debug_checks #echo 1 > /sys/module/bcachefs/parameters/debug_check_iterators - #echo 1 > /sys/module/bcachefs/parameters/debug_check_bkeys #echo 1 > /sys/module/bcachefs/parameters/debug_check_btree_accounting #echo 1 > /sys/module/bcachefs/parameters/test_alloc_startup #echo 1 > /sys/module/bcachefs/parameters/test_restart_gc @@ -143,7 +148,7 @@ bcachefs_antagonist() check_counters() { local dev=$1 - local nr_commits=$(bcachefs show-super -f counters $dev|awk '/transaction_commit/ {print $2}') + local nr_commits=$(bcachefs show-super -f counters "$dev"|awk '/transaction_commit/ {print $2}') local ratio=10 local ret=0 @@ -151,7 +156,7 @@ check_counters() local max_fail=$((nr_commits / ratio)) - counters=$(bcachefs show-super -f counters $dev|grep -E '(fail|restart|blocked)'|grep -v path_relock_fail) + local counters=$(bcachefs show-super -f counters "$dev"|grep -E '(fail|restart|blocked)'|grep -v path_relock_fail) while IFS= read -r line; do linea=($line) @@ -161,6 +166,7 @@ check_counters() if (( nr > max_fail )); then echo "Too many $event: $nr" + grep "$event" /sys/kernel/tracing/trace|head -n50 ret=1 fi done <<< "$counters" @@ -178,7 +184,7 @@ fill_device() local filename=$1 fio \ - --filename=$filename \ + --filename="$filename" \ --ioengine=sync \ --name=write \ --rw=write \ @@ -197,7 +203,6 @@ run_fio_base() --iodepth_batch=16 \ --direct=1 \ --numjobs=1 \ - --verify=crc32c \ --verify_fatal=1 \ --filename=/mnt/fiotest \ "$@" @@ -205,7 +210,7 @@ run_fio_base() run_fio() { - local loops=$((($ktest_priority + 1) * 4)) + local loops=$(((ktest_priority + 1) * 4)) fio --eta=always \ --exitall_on_error=1 \ @@ -214,7 +219,7 @@ run_fio() --iodepth_batch=16 \ --direct=1 \ --numjobs=1 \ - --verify=crc32c \ + --verify=meta \ --verify_fatal=1 \ --buffer_compress_percentage=30 \ --filename=/mnt/fiotest \ @@ -233,11 +238,14 @@ run_fio_randrw() "$@" } -run_basic_fio_test() +run_basic_fio_test_counter_threshold() { set_watchdog 1200 local devs=() + local ratio=$1 + shift + for i in "$@"; do [[ ${i:0:1} != - ]] && devs+=($i) done @@ -246,7 +254,7 @@ run_basic_fio_test() run_quiet "" bcachefs format -f --discard --no_initialize "$@" - mount -t bcachefs -o fsck $(join_by : "${devs[@]}") /mnt + mount -t bcachefs -o fsck "$(join_by : "${devs[@]}")" /mnt #enable_memory_faults run_fio_randrw @@ -261,7 +269,12 @@ run_basic_fio_test() bcachefs fsck -n "${devs[@]}" - check_counters ${devs[0]} + check_counters "${devs[0]}" "$ratio" +} + +run_basic_fio_test() +{ + run_basic_fio_test_counter_threshold 10 "$@" } require-kernel-config DEBUG_FS diff --git a/tests/bcachefs/replication.ktest b/tests/bcachefs/replication.ktest index fa55037..8c54580 100755 --- a/tests/bcachefs/replication.ktest +++ b/tests/bcachefs/replication.ktest @@ -135,6 +135,7 @@ d_test_copygc_torture() for i in $(seq 1 $loops); do run_fio_base \ + --verify=meta \ --buffer_compress_percentage=50 \ \ --name=randwrite \ diff --git a/tests/test-libs.sh b/tests/test-libs.sh index 8bc069c..146c27d 100644 --- a/tests/test-libs.sh +++ b/tests/test-libs.sh @@ -1,3 +1,4 @@ +#!/bin/bash # # Library with some functions for writing block layer tests using the # ktest framework. @@ -12,13 +13,17 @@ config-mem 2G # setup_tracing tracepoint_glob setup_tracing() { - echo > /sys/kernel/debug/tracing/trace - echo 8 > /sys/kernel/debug/tracing/buffer_size_kb - echo $@ > /sys/kernel/debug/tracing/set_event - echo trace_printk > /sys/kernel/debug/tracing/trace_options - echo 1 > /proc/sys/kernel/ftrace_dump_on_oops - echo 1 > /sys/kernel/debug/tracing/options/overwrite - echo 1 > /sys/kernel/debug/tracing/tracing_on + local t=/sys/kernel/tracing + + echo > "$t"/trace + echo 8192 > "$t"/buffer_size_kb + echo $@ > "$t"/set_event + echo trace_printk > "$t"/trace_options + #echo stacktrace > "$t"/trace_options + echo 1 > "$t"/options/overwrite + echo 1 > "$t"/tracing_on + + echo 1 > /proc/sys/kernel/ftrace_dump_on_oops } # Fault injection @@ -27,7 +32,9 @@ set_faults() { f=/sys/kernel/debug/dynamic_fault/control - [[ -f $f ]] && echo "$@" > $f + if [[ -f $f ]]; then + echo "$@" > $f + fi } enable_memory_faults() |