All of lore.kernel.org
 help / color / mirror / Atom feed
* Question on threaded handlers for managed interrupts
@ 2021-04-22 16:10 John Garry
  2021-04-23 10:50 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2021-04-22 16:10 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel

Hi Thomas,

I am finding that I can pretty easily trigger a system hang for certain 
scenarios with my storage controller.

So I'm getting something like this when running moderately heavy data 
throughput:

Starting 6 processes
[70.656622] sched: RT throttling activatedB/s][r=356k,w=0 IOPS][eta
01h:14m:43s]
[  207.632161] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:ta
01h:12m:26s]
[  207.638261] rcu:  0-...!: (1 GPs behind)
idle=312/1/0x4000000000000000 softirq=508/512 fqs=0
[  207.646777] rcu:  1-...!: (1 GPs behind) idle=694/0/0x0

It ends pretty badly - see [0].

The multi-queue storage controller (see [1] for memory refresh, but note 
that I can also trigger on PCI device host controller as well) is using 
managed interrupts and threaded handlers. Since the threaded handler 
uses SCHED_FIFO, aren't we always vulnerable to this situation with the 
managed interrupt and threaded handler combo? Would the advice be to 
just use irq polling here?

I unsuccessfully tried to trigger the same on NVMe PCI - however I have 
only 1x card, so hardly overloading the system.

Thanks,
John

[0] 
https://lore.kernel.org/rcu/412926e8-d3e1-3071-8cb9-098a7f49b64c@huawei.com/T/#mbd60463c543e04f87090d89301e1a5f10de958dd

[1] 
https://lore.kernel.org/linux-scsi/1606905417-183214-1-git-send-email-john.garry@huawei.com/#t

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

* Re: Question on threaded handlers for managed interrupts
  2021-04-22 16:10 Question on threaded handlers for managed interrupts John Garry
@ 2021-04-23 10:50 ` Thomas Gleixner
  2021-04-23 12:02   ` John Garry
  2021-04-23 13:01   ` Thomas Gleixner
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Gleixner @ 2021-04-23 10:50 UTC (permalink / raw)
  To: John Garry
  Cc: linux-kernel, Marc Zyngier, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Ingo Molnar

John,

On Thu, Apr 22 2021 at 17:10, John Garry wrote:
> I am finding that I can pretty easily trigger a system hang for certain 
> scenarios with my storage controller.
>
> So I'm getting something like this when running moderately heavy data 
> throughput:
>
> Starting 6 processes
> [70.656622] sched: RT throttling activatedB/s][r=356k,w=0 IOPS][eta
> 01h:14m:43s]
> [  207.632161] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:ta
> 01h:12m:26s]
> [  207.638261] rcu:  0-...!: (1 GPs behind)
> idle=312/1/0x4000000000000000 softirq=508/512 fqs=0
> [  207.646777] rcu:  1-...!: (1 GPs behind) idle=694/0/0x0
>
> It ends pretty badly - see [0].

Obviously.

> The multi-queue storage controller (see [1] for memory refresh, but
> note that I can also trigger on PCI device host controller as well) is
> using managed interrupts and threaded handlers. Since the threaded
> handler uses SCHED_FIFO, aren't we always vulnerable to this situation
> with the managed interrupt and threaded handler combo? Would the
> advice be to just use irq polling here?

This is a really good question. Most interrupt handlers are not running
exceedingly long or come in with high frequency, but of course this
problem exists.

The network people have solved it with NAPI which disables the interrupt
in the device and polls it from softirq context (which might be then
delegated to ksoftirqd) until it's drained.

I'm not familiar with the block/multiqueue layer to be able to tell
whether such a concept exists there as well.

OTOH, the way how you splitted the handling into hard/thread context
provides already the base for this.

The missing piece is infrastructure at the irq/scheduler core level to
handle this transparently.

I have some horrible ideas how to solve that, but I'm sure the scheduler
wizards can come up with a reasonable and generic solution.

Thanks,

        tglx





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

* Re: Question on threaded handlers for managed interrupts
  2021-04-23 10:50 ` Thomas Gleixner
@ 2021-04-23 12:02   ` John Garry
  2021-04-23 13:01   ` Thomas Gleixner
  1 sibling, 0 replies; 6+ messages in thread
From: John Garry @ 2021-04-23 12:02 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Marc Zyngier, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Ingo Molnar

On 23/04/2021 11:50, Thomas Gleixner wrote:

Hi Thomas,

>> The multi-queue storage controller (see [1] for memory refresh, but
>> note that I can also trigger on PCI device host controller as well) is
>> using managed interrupts and threaded handlers. Since the threaded
>> handler uses SCHED_FIFO, aren't we always vulnerable to this situation
>> with the managed interrupt and threaded handler combo? Would the
>> advice be to just use irq polling here?
> This is a really good question. Most interrupt handlers are not running
> exceedingly long or come in with high frequency, but of course this
> problem exists.
> 
> The network people have solved it with NAPI which disables the interrupt
> in the device and polls it from softirq context (which might be then
> delegated to ksoftirqd) until it's drained.
> 
> I'm not familiar with the block/multiqueue layer to be able to tell
> whether such a concept exists there as well.
> 

Other MQ SCSI drivers have had similar problems. They were handling all 
completion interrupts in hard irq context, the handlers would not exit 
for high throughput scenarios, and they were then getting lockups.

Their solution was to switch over to using irq_poll for when per-queue 
completions got above a certain rate.

> OTOH, the way how you splitted the handling into hard/thread context
> provides already the base for this.
>

Right, so I could switch to a similar scheme, above, but just think that 
what I have in using a threaded handler would already suffice.

> The missing piece is infrastructure at the irq/scheduler core level to
> handle this transparently.
> 
> I have some horrible ideas how to solve that, but I'm sure the scheduler
> wizards can come up with a reasonable and generic solution.

That would be great.

Thanks,
John

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

* Re: Question on threaded handlers for managed interrupts
  2021-04-23 10:50 ` Thomas Gleixner
  2021-04-23 12:02   ` John Garry
@ 2021-04-23 13:01   ` Thomas Gleixner
  2021-04-23 15:00     ` John Garry
  2021-05-21 12:46     ` John Garry
  1 sibling, 2 replies; 6+ messages in thread
From: Thomas Gleixner @ 2021-04-23 13:01 UTC (permalink / raw)
  To: John Garry
  Cc: linux-kernel, Marc Zyngier, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Ingo Molnar

John,

On Fri, Apr 23 2021 at 12:50, Thomas Gleixner wrote:
> On Thu, Apr 22 2021 at 17:10, John Garry wrote:
> OTOH, the way how you splitted the handling into hard/thread context
> provides already the base for this.
>
> The missing piece is infrastructure at the irq/scheduler core level to
> handle this transparently.
>
> I have some horrible ideas how to solve that, but I'm sure the scheduler
> wizards can come up with a reasonable and generic solution.

So one thing I forgot to ask is:

Is the thread simply stuck in the while() loop forever or is
this just an endless hardirq/thread/hardirq/thread stream?

Thanks,

        tglx

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

* Re: Question on threaded handlers for managed interrupts
  2021-04-23 13:01   ` Thomas Gleixner
@ 2021-04-23 15:00     ` John Garry
  2021-05-21 12:46     ` John Garry
  1 sibling, 0 replies; 6+ messages in thread
From: John Garry @ 2021-04-23 15:00 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Marc Zyngier, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Ingo Molnar

Hi Thomas,

On 23/04/2021 14:01, Thomas Gleixner wrote:
> On Fri, Apr 23 2021 at 12:50, Thomas Gleixner wrote:
>> On Thu, Apr 22 2021 at 17:10, John Garry wrote:
>> OTOH, the way how you splitted the handling into hard/thread context
>> provides already the base for this.
>>
>> The missing piece is infrastructure at the irq/scheduler core level to
>> handle this transparently.
>>
>> I have some horrible ideas how to solve that, but I'm sure the scheduler
>> wizards can come up with a reasonable and generic solution.
> So one thing I forgot to ask is:
> 
> Is the thread simply stuck in the while() loop forever or is
> this just an endless hardirq/thread/hardirq/thread stream?

The thread will process all available completions and then return. I 
added some debug there, and at most we handle maybe max 150-300 
completions per thread run.

So I figure that we have the endless hardirq/thread/hardirq/thread stream.

Thanks,
John


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

* Re: Question on threaded handlers for managed interrupts
  2021-04-23 13:01   ` Thomas Gleixner
  2021-04-23 15:00     ` John Garry
@ 2021-05-21 12:46     ` John Garry
  1 sibling, 0 replies; 6+ messages in thread
From: John Garry @ 2021-05-21 12:46 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, Marc Zyngier, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Ingo Molnar, Ming Lei

+

Hi Thomas,

On 23/04/2021 14:01, Thomas Gleixner wrote:
> On Fri, Apr 23 2021 at 12:50, Thomas Gleixner wrote:
>> On Thu, Apr 22 2021 at 17:10, John Garry wrote:
>> OTOH, the way how you splitted the handling into hard/thread context
>> provides already the base for this.
>>
>> The missing piece is infrastructure at the irq/scheduler core level to
>> handle this transparently.
>>
>> I have some horrible ideas how to solve that, but I'm sure the scheduler
>> wizards can come up with a reasonable and generic solution.

JFYI, A performance-related fix was recently added in the block layer, 
and I can no longer reproduce this hang.

But I have no reason to say that it no longer exists.

Thanks,
John

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

end of thread, other threads:[~2021-05-21 12:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 16:10 Question on threaded handlers for managed interrupts John Garry
2021-04-23 10:50 ` Thomas Gleixner
2021-04-23 12:02   ` John Garry
2021-04-23 13:01   ` Thomas Gleixner
2021-04-23 15:00     ` John Garry
2021-05-21 12:46     ` John Garry

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.