Messages in this thread Patch in this message |  | | From | Wang Yufen <> | Subject | [PATCH -next v2 4/4] fault-injection: make stacktrace filter works as expected | Date | Mon, 12 Dec 2022 10:11:16 +0800 |
| |
From: Wei Yongjun <weiyongjun1@huawei.com>
stacktrace filter is checked after others, such as fail-nth, interval and probability. This make it doesn't work well as expected.
Fix to running stacktrace filter before other filters. It will speed up fault inject testing for driver modules.
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> --- lib/fault-inject.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index d7819ca..6cff320 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -102,10 +102,16 @@ static inline bool fail_stacktrace(struct fault_attr *attr) bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) { + bool stack_checked = false; + if (in_task()) { unsigned int fail_nth = READ_ONCE(current->fail_nth); if (fail_nth) { + if (!fail_stacktrace(attr)) + return false; + + stack_checked = true; fail_nth--; WRITE_ONCE(current->fail_nth, fail_nth); if (!fail_nth) @@ -125,6 +131,9 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) if (atomic_read(&attr->times) == 0) return false; + if (!stack_checked && !fail_stacktrace(attr)) + return false; + if (atomic_read(&attr->space) > size) { atomic_sub(size, &attr->space); return false; @@ -139,9 +148,6 @@ bool should_fail_ex(struct fault_attr *attr, ssize_t size, int flags) if (attr->probability <= get_random_u32_below(100)) return false; - if (!fail_stacktrace(attr)) - return false; - fail: if (!(flags & FAULT_NOWARN)) fail_dump(attr); -- 1.8.3.1
|  |