From: Don Mullis <dwm@meer.net>
To: akpm <akpm@osdl.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Akinobu Mita <akinobu.mita@gmail.com>
Subject: [PATCH 4/5 -mm] fault-injection: optimize and simplify should_fail()
Date: Thu, 07 Dec 2006 00:21:06 -0800 [thread overview]
Message-ID: <1165479666.2706.22.camel@localhost.localdomain> (raw)
In-Reply-To: <1165478812.2706.8.camel@localhost.localdomain>
Trivial optimization and simplification of should_fail().
Do cheaper disqualification tests first (performance gain not quantified).
Simplify logic; eliminate goto.
Signed-off-by: Don Mullis <dwm@meer.net>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
---
lib/fault-inject.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Index: linux-2.6.18/lib/fault-inject.c
===================================================================
--- linux-2.6.18.orig/lib/fault-inject.c
+++ linux-2.6.18/lib/fault-inject.c
@@ -142,9 +142,6 @@ bool should_fail(struct fault_attr *attr
if (attr->task_filter && !fail_task(attr, current))
return false;
- if (!fail_stacktrace(attr))
- return false;
-
if (atomic_read(&attr->times) == 0)
return false;
@@ -159,12 +156,12 @@ bool should_fail(struct fault_attr *attr
return false;
}
- if (attr->probability > random32() % 100)
- goto fail;
+ if (attr->probability <= random32() % 100)
+ return false;
- return false;
+ if (!fail_stacktrace(attr))
+ return false;
-fail:
fail_dump(attr);
if (atomic_read(&attr->times) != -1)
next prev parent reply other threads:[~2006-12-07 8:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-07 8:06 [PATCH 1/5 -mm] fault-injection: Correct, disambiguate, and reformat documentation Don Mullis
2006-12-07 8:10 ` [PATCH 2/5 -mm] fault-injection: Use bool-true-false throughout Don Mullis
2006-12-07 8:14 ` [PATCH 3/5 -mm] fault-injection: Clamp debugfs stacktrace-depth to MAX_STACK_TRACE_DEPTH Don Mullis
2006-12-07 8:21 ` Don Mullis [this message]
2006-12-07 8:25 ` [PATCH 5/5 -mm] fault-injection: defaults likely to please a new user Don Mullis
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=1165479666.2706.22.camel@localhost.localdomain \
--to=dwm@meer.net \
--cc=akinobu.mita@gmail.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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