summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Mullis <dwm@meer.net>2006-12-08 11:39:53 +0100
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 17:29:03 +0100
commitf1729c28a37e4f11ea5d9f468ab26adadb1aadab (patch)
tree0b4e6a6aa6bd44dee5a15269210e0aa5be8b3565
parent[PATCH] fault-injection: Clamp debugfs stacktrace-depth to MAX_STACK_TRACE_DEPTH (diff)
downloadlinux-f1729c28a37e4f11ea5d9f468ab26adadb1aadab.tar.xz
linux-f1729c28a37e4f11ea5d9f468ab26adadb1aadab.zip
[PATCH] fault-injection: optimize and simplify should_fail()
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> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--lib/fault-inject.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 5da665ac2d89..d143c0faf248 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -142,9 +142,6 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
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, ssize_t size)
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)