linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about qspinlock nest
@ 2019-01-10  8:02 Zhenzhong Duan
  2019-01-10 14:43 ` Waiman Long
  2019-01-10 20:03 ` Peter Zijlstra
  0 siblings, 2 replies; 19+ messages in thread
From: Zhenzhong Duan @ 2019-01-10  8:02 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, longman, SRINIVAS

Hi Maintainer,


There is a question confused me for days. Appreciate an answer.

In below code, the comment says we never have more than 4 nested contexts.

What happen if debug and mce exceptions nest with the four, or we ensure 
it never happen?


/*
  * Per-CPU queue node structures; we can never have more than 4 nested
  * contexts: task, softirq, hardirq, nmi.
  *
  * Exactly fits one 64-byte cacheline on a 64-bit architecture.
  *
  * PV doubles the storage and uses the second cacheline for PV state.
  */
static DEFINE_PER_CPU_ALIGNED(struct qnode, qnodes[MAX_NODES]);

-- 
Thanks
Zhenzhong


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: Question about qspinlock nest
@ 2019-01-14  9:25 Zhenzhong Duan
  0 siblings, 0 replies; 19+ messages in thread
From: Zhenzhong Duan @ 2019-01-14  9:25 UTC (permalink / raw)
  To: longman; +Cc: srinivas.eeda, linux-kernel, peterz


----- longman@redhat.com wrote:

> On 01/11/2019 12:06 AM, Zhenzhong Duan wrote:
> >
> >
> > On 2019/1/10 22:43, Waiman Long wrote:
> >> On 01/10/2019 03:02 AM, Zhenzhong Duan wrote:
> >>> Hi Maintainer,
> >>>
> >>>
> >>> There is a question confused me for days. Appreciate an answer.
> >>>
> >>> In below code, the comment says we never have more than 4 nested
> >>> contexts.
> >>>
> >>> What happen if debug and mce exceptions nest with the four, or we
> >>> ensure it never happen?
> >>>
> >>>
> >>> /*
> >>>  * Per-CPU queue node structures; we can never have more than 4
> nested
> >>>  * contexts: task, softirq, hardirq, nmi.
> >>>  *
> >>>  * Exactly fits one 64-byte cacheline on a 64-bit architecture.
> >>>  *
> >>>  * PV doubles the storage and uses the second cacheline for PV
> state.
> >>>  */
> >>> static DEFINE_PER_CPU_ALIGNED(struct qnode, qnodes[MAX_NODES]);
> >>>
> >> Yes, both debug and mce exceptions are some kind of NMIs. So
> >> theoretically, it is possible to have more than four. Are you aware
> of
> >> any debug and MCE exception handlers that need to take a spinlock
> for
> >> synchronization?
> > Not for debug exception, for MCE exception handler I found below
> two:
> >
> > do_machine_check->mce_report_event->schedule_work
> > do_machine_check->force_sig->force_sig_info
> >
> > schedule_work() and force_sig_info() take spinlocks.
> > -- 
> > Thanks
> > Zhenzhong
> 
> The comment for do_machine_scheck() has already state that:
> 
>  * This is executed in NMI context not subject to normal locking
> rules. This
>  * implies that most kernel services cannot be safely used. Don't
> even
>  * think about putting a printk in there!
> 
> So even if it doesn't exceed the MAX_NODES limit, it could hit
> deadlock
> and other kind of locking hazards. So supporting MCE is not a reason
> strong enough to extend MAX_NODES.

Agree.

> 
> In hindsight, we should have added a "BUG_ON(idx >= MAX_NODES);"
> check
> to avoid silent corruption because of that issue.

Looks a good idea if it's hard to avoid using spinlock in MCE handler.

Thanks
Zhenzhong

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-01-18 21:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).