* [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled
@ 2012-06-01 0:49 Anton Blanchard
2012-06-01 12:38 ` Akinobu Mita
0 siblings, 1 reply; 2+ messages in thread
From: Anton Blanchard @ 2012-06-01 0:49 UTC (permalink / raw)
To: akinobu.mita, akpm; +Cc: linux-kernel
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled
2012-06-01 0:49 [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled Anton Blanchard
@ 2012-06-01 12:38 ` Akinobu Mita
0 siblings, 0 replies; 2+ messages in thread
From: Akinobu Mita @ 2012-06-01 12:38 UTC (permalink / raw)
To: Anton Blanchard; +Cc: akpm, linux-kernel
2012/6/1 Anton Blanchard <anton@samba.org>:
>
> 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;
>
Looks good to me.
Acked-by: Akinobu Mita <akinobu.mita@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-01 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 0:49 [PATCH] fault-inject: Avoid call to random32() if fault injection is disabled Anton Blanchard
2012-06-01 12:38 ` Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).