From: Anton Blanchard <anton@samba.org>
To: akinobu.mita@gmail.com, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled
Date: Fri, 1 Jun 2012 10:49:25 +1000 [thread overview]
Message-ID: <20120601104925.5135263c@kryten> (raw)
After enabling CONFIG_FAILSLAB I noticed random32 in profiles even
if slub fault injection wasn't enabled at runtime.
should_fail forces a comparison against random32() even if
probability is 0:
if (attr->probability <= random32() % 100)
return false;
Add a check up front for probability == 0 and avoid all of the more
complicated checks.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
Index: linux-build/lib/fault-inject.c
===================================================================
--- linux-build.orig/lib/fault-inject.c 2012-02-11 21:22:32.303459860 +1100
+++ linux-build/lib/fault-inject.c 2012-02-11 22:38:10.470977505 +1100
@@ -101,6 +101,10 @@ static inline bool fail_stacktrace(struc
bool should_fail(struct fault_attr *attr, ssize_t size)
{
+ /* No need to check any other properties if the probability is 0 */
+ if (attr->probability == 0)
+ return false;
+
if (attr->task_filter && !fail_task(attr, current))
return false;
next reply other threads:[~2012-06-01 0:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 0:49 Anton Blanchard [this message]
2012-06-01 12:38 ` [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled Akinobu Mita
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=20120601104925.5135263c@kryten \
--to=anton@samba.org \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.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