linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* smp_call_function() friends and irq/bottom_half context
@ 2018-05-10  4:58 류호은
  2018-05-10 10:16 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: 류호은 @ 2018-05-10  4:58 UTC (permalink / raw)
  To: mingo, peterz, aaron.lu, adobriyan, frederic, ying.huang; +Cc: linux-kernel

Hi, all.

I'm reading kernel/smp.c code and I found comments on smp_call_function()
and smp_call_function_[single/many]
saying that these functions are cannot be called in interrupt disabled
context or irq/bottom half handlers.

I understand that there is a potential deadlock issue when caller CPU of
the functions is waiting for the completion of the callback of other CPUs.
But I was wondering if this is the case even when the caller CPU doesn't
wait for the completion (wait == 0).

Thank you.

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

* Re: smp_call_function() friends and irq/bottom_half context
  2018-05-10  4:58 smp_call_function() friends and irq/bottom_half context 류호은
@ 2018-05-10 10:16 ` Peter Zijlstra
  2018-05-11  6:24   ` Hoeun Ryu
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2018-05-10 10:16 UTC (permalink / raw)
  To: ��ȣ��
  Cc: mingo, aaron.lu, adobriyan, frederic, ying.huang, linux-kernel

On Thu, May 10, 2018 at 01:58:29PM +0900, ��ȣ�� wrote:
> Hi, all.
> 
> I'm reading kernel/smp.c code and I found comments on smp_call_function()
> and smp_call_function_[single/many]
> saying that these functions are cannot be called in interrupt disabled
> context or irq/bottom half handlers.
> 
> I understand that there is a potential deadlock issue when caller CPU of
> the functions is waiting for the completion of the callback of other CPUs.
> But I was wondering if this is the case even when the caller CPU doesn't
> wait for the completion (wait == 0).

IIRC yes, because csd_lock(). You can however use
smp_call_function_single_async() with your own csd. Be very careful
though, it is very easy to construct deadlocks.

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

* RE: smp_call_function() friends and irq/bottom_half context
  2018-05-10 10:16 ` Peter Zijlstra
@ 2018-05-11  6:24   ` Hoeun Ryu
  0 siblings, 0 replies; 3+ messages in thread
From: Hoeun Ryu @ 2018-05-11  6:24 UTC (permalink / raw)
  To: 'Peter Zijlstra', 'Hoeun Ryu'
  Cc: mingo, aaron.lu, adobriyan, frederic, ying.huang, linux-kernel


> -----Original Message-----
> From: Peter Zijlstra [mailto:peterz@infradead.org]
> Sent: Thursday, May 10, 2018 7:17 PM
> To: ��ȣ�� <hoeun.ryu@lge.com>
> Cc: mingo@kernel.org; aaron.lu@intel.com; adobriyan@gmail.com;
> frederic@kernel.org; ying.huang@intel.com; linux-kernel@vger.kernel.org
> Subject: Re: smp_call_function() friends and irq/bottom_half context
> 
> On Thu, May 10, 2018 at 01:58:29PM +0900, ��ȣ�� wrote:
> > Hi, all.
> >
> > I'm reading kernel/smp.c code and I found comments on smp_call_function()
> > and smp_call_function_[single/many]
> > saying that these functions are cannot be called in interrupt disabled
> > context or irq/bottom half handlers.
> >
> > I understand that there is a potential deadlock issue when caller CPU of
> > the functions is waiting for the completion of the callback of other
> CPUs.
> > But I was wondering if this is the case even when the caller CPU doesn't
> > wait for the completion (wait == 0).
> 
> IIRC yes, because csd_lock(). You can however use
> smp_call_function_single_async() with your own csd. Be very careful
> though, it is very easy to construct deadlocks.

Thank you for the explanation and the suggestion.

Would you please explain more on csd lock and irq disabled or irq/bh context ?
How can deadlocks happen when calling smp_call_function(wait=0) with irq disabled ?
How can deadlocks happen when calling smp_call_function(wait=0) from irq or bottom half context ?

I think it as 2d array like call_single_data[caller cpu][target cpu].flags.
csd_lock(csd[caller][target]) spins on the flag only when LOCKED is already set
which means that the caller CPU already called smp_call_function(wait=0)
and at the second calling of the function, the caller CPU spins on
csd_lock(csd[caller][target]) but the target CPU is still processing its callback list
(maybe processing other csd[other cpu][target]) and it does not yet process
csd[caller][target]. But the callback list will be finally flushed and LOCKED flags
is cleared of csd[caller][target] eventually ?

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

end of thread, other threads:[~2018-05-11  6:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10  4:58 smp_call_function() friends and irq/bottom_half context 류호은
2018-05-10 10:16 ` Peter Zijlstra
2018-05-11  6:24   ` Hoeun Ryu

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).