All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <longman@redhat.com>,
	Zhenzhong Duan <zhenzhong.duan@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	SRINIVAS <srinivas.eeda@oracle.com>
Subject: Re: Question about qspinlock nest
Date: Mon, 14 Jan 2019 13:54:49 +0000	[thread overview]
Message-ID: <830db851-d5cb-4081-8d72-e3f3a0a282df@arm.com> (raw)
In-Reply-To: <20190114131613.GB10486@hirez.programming.kicks-ass.net>

Hi Peter,

On 14/01/2019 13:16, Peter Zijlstra wrote:
> On Fri, Jan 11, 2019 at 06:32:58PM +0000, James Morse wrote:
>> On 10/01/2019 20:12, Peter Zijlstra wrote:
>>> On Thu, Jan 10, 2019 at 06:25:57PM +0000, James Morse wrote:
>>> The thing is, everything non-maskable (NMI like) really should not be
>>> using spinlocks at all.
>>>
>>> I otherwise have no clue about wth APEI is, but it sounds like horrible
>>> crap ;-)
>>
>> I think you've called it that before!: its that GHES thing in drivers/acpi/apei.
>>
>> What is the alternative? bit_spin_lock()?

>> These things can happen independently on multiple CPUs. On arm64 these NMIlike
>> things don't affect all CPUs like they seem to on x86.
> 
> It has nothing to do with how many CPUs are affected. It has everything
> to do with not being maskable.

(sorry, I didn't include any of the context, let me back-up a bit here:)

> What avoids the trivial self-recursion:
> 
>   spin_lock(&)
>   <NMI>
>     spin_lock(&x)
>      ... wait forever more ...
>   </NMI>
>   spin_unlock(&x)
> 
> ?

If its trying to take the same lock, I agree its deadlocked.
If the sequence above started with <NMI>, I agree its deadlocked.

APEI/GHES is doing neither of these things. It take a lock that is only ever
taken in_nmi(). nmi_enter()s BUG_ON(in_nmi()) means these never become re-entrant.

What is the lock doing? Protecting the 'NMI' fixmap slot in the unlikely case
that two CPUs end up in here at the same time.

(I though x86's NMI masked NMI until the next iret?)


This is murkier on arm64 as we have multiple things that behave like this, but
there is an order to them, and none of them can interrupt themselves.
e.g. We can't take an SError during the SError handler.

But we can take this SError/NMI on another CPU while the first one is still
running the handler.

These multiple NMIlike notifications mean having multiple locks/fixmap-slots,
one per notification. This is where the qspinlock node limit comes in, as we
could have more than 4 contexts.


Thanks,

James

> Normally for actual maskable interrupts, we use:
> 
>   spin_lock_irq(&x)
>   // our IRQ cannot happen here because: masked
>   spin_unlock_irq(&x)
> 
> But non-maskable, has, per definition, a wee issue there.

> Non-maskable MUST NOT _EVAH_ use any form of spinlocks, they're
> fundamentally incompatible. Non-maskable interrupts must employ
> wait-free atomic constructs.






  reply	other threads:[~2019-01-14 13:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10  8:02 Question about qspinlock nest Zhenzhong Duan
2019-01-10 14:43 ` Waiman Long
2019-01-10 18:25   ` James Morse
2019-01-10 19:23     ` Waiman Long
2019-01-10 20:12     ` Peter Zijlstra
2019-01-11 18:32       ` James Morse
2019-01-14 13:16         ` Peter Zijlstra
2019-01-14 13:54           ` James Morse [this message]
2019-01-14 21:07             ` Waiman Long
2019-01-18 10:02             ` Peter Zijlstra
2019-01-18 10:24               ` Borislav Petkov
2019-01-18 14:50               ` Waiman Long
2019-01-18 20:06                 ` Peter Zijlstra
2019-01-18 21:30                   ` Waiman Long
     [not found]   ` <2eca6f60-3e8b-a389-27cb-8adbd9676607@oracle.com>
2019-01-11  9:16     ` Peter Zijlstra
2019-01-11 17:36       ` Borislav Petkov
2019-01-11 16:59     ` Waiman Long
2019-01-10 20:03 ` Peter Zijlstra
2019-01-14  9:25 Zhenzhong Duan

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=830db851-d5cb-4081-8d72-e3f3a0a282df@arm.com \
    --to=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=peterz@infradead.org \
    --cc=srinivas.eeda@oracle.com \
    --cc=zhenzhong.duan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.