From: Wei Yongjun <weiyongjun1@huawei.com>
To: Akinobu Mita <akinobu.mita@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Nathan Chancellor <nathan@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <keescook@chromium.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Miguel Ojeda <ojeda@kernel.org>,
Isabella Basso <isabbasso@riseup.net>,
Vlastimil Babka <vbabka@suse.cz>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Wei Yongjun <weiyongjun1@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4 -next] fault-injection: make stacktrace filter works as expected
Date: Wed, 17 Aug 2022 08:03:32 +0000 [thread overview]
Message-ID: <20220817080332.1052710-5-weiyongjun1@huawei.com> (raw)
In-Reply-To: <20220817080332.1052710-1-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 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
prev parent reply other threads:[~2022-08-17 7:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 8:03 [PATCH 0/4 -next] fault-injection: make stacktrace filter works with others Wei Yongjun
2022-08-17 8:03 ` [PATCH 1/4 -next] fault-injection: allow stacktrace filter for x86-64 Wei Yongjun
2022-08-17 8:03 ` [PATCH 2/4 -next] fault-injection: skip stacktrace filtering by default Wei Yongjun
2022-08-17 8:03 ` [PATCH 3/4 -next] fault-injection: make some stack filter attrs more readable Wei Yongjun
2022-08-19 13:24 ` Akinobu Mita
2022-10-03 21:17 ` Andrew Morton
2022-08-17 8:03 ` Wei Yongjun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220817080332.1052710-5-weiyongjun1@huawei.com \
--to=weiyongjun1@huawei.com \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=isabbasso@riseup.net \
--cc=jpoimboe@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®