mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric DeVolder <eric.devolder@oracle.com>
To: Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org, bhe@redhat.com, vgoyal@redhat.com,
	dyoung@redhat.com, ebiederm@xmission.com,
	kexec@lists.infradead.org
Cc: sourabhjain@linux.ibm.com, konrad.wilk@oracle.com,
	boris.ostrovsky@oracle.com,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kexec: change locking mechanism to a mutex
Date: Fri, 22 Sep 2023 12:35:13 -0500	[thread overview]
Message-ID: <0ec5f56e-6b55-627a-39c0-ff0a1680794d@oracle.com> (raw)
In-Reply-To: <xhsmh7coiuq8z.mognet@vschneid.remote.csb>



On 9/22/23 11:28, Valentin Schneider wrote:
> On 21/09/23 17:59, Eric DeVolder wrote:
>> The design decision to use the atomic lock is described in the comment
>> from kexec_internal.h, cited above. However, examining the code of
>> __crash_kexec():
>>
>>          if (kexec_trylock()) {
>>                  if (kexec_crash_image) {
>>                          ...
>>                  }
>>                  kexec_unlock();
>>          }
>>
>> reveals that the use of kexec_trylock() here is actually a "best effort"
>> due to the atomic lock.  This atomic lock, prior to crash hotplug,
>> would almost always be assured (another kexec syscall could hold the lock
>> and prevent this, but that is about it).
>>
>> So at the point where the capture kernel would be invoked, if the lock
>> is not obtained, then kdump doesn't occur.
>>
>> It is possible to instead use a mutex with proper waiting, and utilize
>> mutex_trylock() as the "best effort" in __crash_kexec(). The use of a
>> mutex then avoids all the lock acquisition problems that were revealed
>> by the crash hotplug activity.
>>
> 
> @Dave thanks for the Cc, I'd have missed this otherwise.
> 
> 
> Prior to the atomic thingie, we actually had a mutex and did
> mutex_trylock() in __crash_kexec(). I'm a bit confused as this looks like a
> revert of
>    05c6257433b7 ("panic, kexec: make __crash_kexec() NMI safe")
> with just the helpers kept in - this doesn't seem to address any of the
> original issues regarding NMIs?
> 
> Sebastian raised some good points in [1] regarding these issues.
> The main hurdle pointed out there is, if we end up in the slowpath during
> the unlock, then we can can up acquiring the ->wait_lock which isn't NMI
> safe.
> 
> This is even worse on PREEMPT_RT, as both trylock and the unlock can end up
> acquiring the ->wait_lock.
> 
> [1]: https://lore.kernel.org/all/YqyZ%2FUf14qkYtMDX@linutronix.de/
> 
Having reviewed the references, it would seem that Baoquan's approach of a new
lock to handle the hotplug activity is the way to go?
Eric

  reply	other threads:[~2023-09-22 17:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 21:59 Eric DeVolder
2023-09-22  0:22 ` Andrew Morton
2023-09-22  1:00   ` Eric DeVolder
2023-09-22  0:26 ` Andrew Morton
2023-09-22  1:02   ` Eric DeVolder
2023-09-22  3:36 ` Dave Young
2023-09-22  8:06   ` Baoquan He
2023-09-22 13:39     ` Eric DeVolder
2023-09-22 16:28 ` Valentin Schneider
2023-09-22 17:35   ` Eric DeVolder [this message]
2023-09-23  0:04     ` Baoquan He

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=0ec5f56e-6b55-627a-39c0-ff0a1680794d@oracle.com \
    --to=eric.devolder@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sourabhjain@linux.ibm.com \
    --cc=vgoyal@redhat.com \
    --cc=vschneid@redhat.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

all inboxes | Powered by JetHome®