提交 f1729c28 编写于 作者: D Don Mullis 提交者: 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: NDon Mullis <dwm@meer.net>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册