fault injection: prevent recursive fault injection
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 35 lines
If something we call in the
fail_dump()code path tries to acquire a resource that might fail (due to fault injection), then we should not try to recurse back into the fault injection code.I've seen this happen with the console semaphore in the upcoming semaphore trylock fault injection code.
Signed-off-by Vegard Nossum <[email protected]>--- lib/fault-inject.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)lib/fault-inject.c +14
-0@@ -100,6 +100,33 @@ static inline bool fail_stacktrace(struct fault_attr *attr)#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ +static DEFINE_PER_CPU(int, fault_active); + +static bool __fail (struct fault_attr *attr) +{ +bool ret = false; + +/* +* Prevent recursive fault injection (this could happen if for +* example printing the fault would itself run some code that +* could fail) +*/ +preempt_disable (); +if (unlikely (__this_cpu_inc_return (fault_active) !=1 )) + goto out;
lib/fault-inject.c static inline bool fail_stacktrace(struct fault_attr *attr) · line 126
Quoted 10 lines
lib/fault-inject.c +10
-0+ + ret = true; +fail_dump (attr); + +if (atomic_read (&attr->times) !=-1 ) +atomic_dec_not_zero (&attr->times); + +out: +__this_cpu_dec (fault_active); +preempt_enable ();
Well schedule entry point is add in paths like
rt_mutex_trylock
__alloc_pages_nodemask
and please add one or two sentences in log
message for it.
thanks
Hillf
Quoted 21 lines
lib/fault-inject.c +4
-7+return ret; +} +/* * This code is stolen from failmalloc-1.0 * http://www.nongnu.org/failmalloc/ @@ -134,12 +161,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size)if (!fail_stacktrace (attr))return false; -fail_dump (attr); - -if (atomic_read (&attr->times) !=-1 ) -atomic_dec_not_zero (&attr->times); - -return true; +return __fail (attr); }EXPORT_SYMBOL_GPL (should_fail); --
Quoted 3 lines
1.9.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 43 lines · Hillf Danton
Quoted 43 lines
If something we call in the
fail_dump()code path tries to acquire a resource that might fail (due to fault injection), then we should not try to recurse back into the fault injection code.I've seen this happen with the console semaphore in the upcoming semaphore trylock fault injection code.
Signed-off-by Vegard Nossum <[email protected]>--- lib/fault-inject.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)lib/fault-inject.c +22
-0@@ -100,6 +100,33 @@ static inline bool fail_stacktrace(struct fault_attr *attr)#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ +static DEFINE_PER_CPU(int, fault_active); + +static bool __fail (struct fault_attr *attr) +{ +bool ret = false; + +/* +* Prevent recursive fault injection (this could happen if for +* example printing the fault would itself run some code that +* could fail) +*/ +preempt_disable (); +if (unlikely (__this_cpu_inc_return (fault_active) !=1 )) + goto out; + + ret = true; +fail_dump (attr); + +if (atomic_read (&attr->times) !=-1 ) +atomic_dec_not_zero (&attr->times); + +out:
Quoted 8 lines
lib/fault-inject.c static inline bool fail_stacktrace(struct fault_attr *attr) · line 126
Quoted 2 lines
lib/fault-inject.c +2
-0+__this_cpu_dec (fault_active); +preempt_enable ();Well schedule entry point is add in paths like
rt_mutex_trylock
__alloc_pages_nodemask
and please add one or two sentences in log
message for it.
I'm sorry, but I don't really get what you are saying or what you want me to add.
Are you saying that because I'm adding a fail_dump() call to mutex_trylock() that we can now end up calling schedule() from a weird context?
This patch is just to prevent __fail() from looping on itself, I don't see what the connection is to rt_mutex_trylock(), __alloc_pages_nodemask(), or schedule().
Could you please clarify? Thanks,
Vegard
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>