]> git.baikalelectronics.ru Git - kernel.git/commit
fault-inject: avoid call to random32() if fault injection is disabled
authorAnton Blanchard <anton@samba.org>
Wed, 20 Jun 2012 19:53:03 +0000 (12:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 20 Jun 2012 21:39:36 +0000 (14:39 -0700)
commit6256bdb804e90f243380319ed818b2d0b0938e6d
tree3e6db2d5c97c822591350be26a09097589ef5b8c
parent5c2b0e61299e6f4034d79948b5590f84964f6ee0
fault-inject: avoid call to random32() if fault injection is disabled

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>
Acked-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/fault-inject.c