[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220817080332.1052710-5-weiyongjun1@huawei.com>
Date: Wed, 17 Aug 2022 08:03:32 +0000
From: Wei Yongjun <weiyongjun1@...wei.com>
To: Akinobu Mita <akinobu.mita@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Nathan Chancellor <nathan@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Kees Cook <keescook@...omium.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Dan Williams <dan.j.williams@...el.com>,
Miguel Ojeda <ojeda@...nel.org>,
Isabella Basso <isabbasso@...eup.net>,
Vlastimil Babka <vbabka@...e.cz>,
Rasmus Villemoes <linux@...musvillemoes.dk>
CC: Wei Yongjun <weiyongjun1@...wei.com>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH 4/4 -next] fault-injection: make stacktrace filter works as expected
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@...wei.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 deca05e7c9b3..9dd1dd1d2610 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -105,10 +105,16 @@ static inline bool fail_stacktrace(struct fault_attr *attr)
bool should_fail(struct fault_attr *attr, ssize_t size)
{
+ 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)
@@ -128,6 +134,9 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
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;
@@ -142,9 +151,6 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
if (attr->probability <= prandom_u32() % 100)
return false;
- if (!fail_stacktrace(attr))
- return false;
-
fail:
fail_dump(attr);
--
2.34.1
Powered by blists - more mailing lists