linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@gmail.com>
To: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH 04/10] fault injection: prevent recursive fault injection
Date: Sat, 8 Oct 2016 00:09:33 +0200	[thread overview]
Message-ID: <CAOMGZ=E0U980xbHbCkms89rR3ykQmum0d+E=XEGG_xw0+=CwNg@mail.gmail.com> (raw)
In-Reply-To: <001f01d1ee06$00b484e0$021d8ea0$@alibaba-inc.com>

On 4 August 2016 at 06:09, Hillf Danton <hillf.zj@alibaba-inc.com> wrote:
>>
>> 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 <vegard.nossum@oracle.com>
>> ---
>>  lib/fault-inject.c | 34 ++++++++++++++++++++++++++++------
>>  1 file changed, 28 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/fault-inject.c b/lib/fault-inject.c
>> index 6a823a5..adba7c9 100644
>> --- a/lib/fault-inject.c
>> +++ b/lib/fault-inject.c
>> @@ -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:
>> +     __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 majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2016-10-07 22:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <001e01d1ee04$c7f77be0$57e673a0$@alibaba-inc.com>
2016-08-04  4:09 ` Hillf Danton
2016-10-07 22:09   ` Vegard Nossum [this message]

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='CAOMGZ=E0U980xbHbCkms89rR3ykQmum0d+E=XEGG_xw0+=CwNg@mail.gmail.com' \
    --to=vegard.nossum@gmail.com \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=linux-mm@kvack.org \
    --cc=vegard.nossum@oracle.com \
    /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