Commit f1729c28 authored by Don Mullis's avatar Don Mullis Committed by Linus Torvalds

[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: default avatarDon Mullis <dwm@meer.net>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a124c28e
...@@ -142,9 +142,6 @@ bool should_fail(struct fault_attr *attr, ssize_t size) ...@@ -142,9 +142,6 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
if (attr->task_filter && !fail_task(attr, current)) if (attr->task_filter && !fail_task(attr, current))
return false; return false;
if (!fail_stacktrace(attr))
return false;
if (atomic_read(&attr->times) == 0) if (atomic_read(&attr->times) == 0)
return false; return false;
...@@ -159,12 +156,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size) ...@@ -159,12 +156,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
return false; return false;
} }
if (attr->probability > random32() % 100) if (attr->probability <= random32() % 100)
goto fail; return false;
if (!fail_stacktrace(attr))
return false; return false;
fail:
fail_dump(attr); fail_dump(attr);
if (atomic_read(&attr->times) != -1) if (atomic_read(&attr->times) != -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment