mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
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 <[email protected]>
Acked-by: Akinobu Mita <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
10d8935f46
commit
f39cdaebb8
1 file changed
+4
@@ -101,6 +101,10 @@ static inline bool fail_stacktrace(struct fault_attr *attr)
|
||||
|
||||
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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user