linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
@ 2016-07-27  9:20 Bhaktipriya Shridhar
  2016-07-27  9:29 ` Oliver Neukum
  0 siblings, 1 reply; 20+ messages in thread
From: Bhaktipriya Shridhar @ 2016-07-27  9:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, GeyslanG.Bem@Karyakshetra, Michal Hocko,
	Vlastimil Babka, Geliang Tang, Saurabh Karajgaonkar, Mel Gorman,
	Masanari Iida
  Cc: linux-usb, linux-kernel, Tejun Heo

alloc_ordered_workqueue replaces the deprecated
create_singlethread_workqueue.

The workqueue "workqueue" has multiple workitems which may require
ordering. Hence, a dedicated ordered workqueue has been used.
Since the workqueue is not being used on a memory reclaim path,
WQ_MEM_RECLAIM has not been set.

Can the workitems run concurrently? Is the ordering among work items
necessary?

Thanks.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
 drivers/usb/host/u132-hcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 43d5293..cbde189 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3206,7 +3206,7 @@ static int __init u132_hcd_init(void)
 	if (usb_disabled())
 		return -ENODEV;
 	printk(KERN_INFO "driver %s\n", hcd_name);
-	workqueue = create_singlethread_workqueue("u132");
+	workqueue = alloc_ordered_workqueue("u132", 0);
 	retval = platform_driver_register(&u132_platform_driver);
 	return retval;
 }
--
2.1.4

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27  9:20 [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue Bhaktipriya Shridhar
@ 2016-07-27  9:29 ` Oliver Neukum
  2016-07-27 18:00   ` Tejun Heo
  0 siblings, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2016-07-27  9:29 UTC (permalink / raw)
  To: Bhaktipriya Shridhar
  Cc: Geliang Tang, GeyslanG.Bem@Karyakshetra, Masanari Iida,
	Greg Kroah-Hartman, Michal Hocko, Vlastimil Babka, Mel Gorman,
	Saurabh Karajgaonkar, Tejun Heo, linux-kernel, linux-usb

On Wed, 2016-07-27 at 14:50 +0530, Bhaktipriya Shridhar wrote:
> The workqueue "workqueue" has multiple workitems which may require
> ordering. Hence, a dedicated ordered workqueue has been used.
> Since the workqueue is not being used on a memory reclaim path,
> WQ_MEM_RECLAIM has not been set.

That is incorrect. The work queue is used by the HCD to handle
TDs, which are parts of basic IO. The HCD in turn is used by
usb-storage and uas, which are block drivers and those are obviously
used on the memory reclaim path.

	HTH
		Oliver

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27  9:29 ` Oliver Neukum
@ 2016-07-27 18:00   ` Tejun Heo
  2016-07-27 18:54     ` Alan Stern
  0 siblings, 1 reply; 20+ messages in thread
From: Tejun Heo @ 2016-07-27 18:00 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Bhaktipriya Shridhar, Geliang Tang, GeyslanG.Bem@Karyakshetra,
	Masanari Iida, Greg Kroah-Hartman, Michal Hocko, Vlastimil Babka,
	Mel Gorman, Saurabh Karajgaonkar, linux-kernel, linux-usb

Hello, Oliver.

On Wed, Jul 27, 2016 at 11:29:56AM +0200, Oliver Neukum wrote:
> On Wed, 2016-07-27 at 14:50 +0530, Bhaktipriya Shridhar wrote:
> > The workqueue "workqueue" has multiple workitems which may require
> > ordering. Hence, a dedicated ordered workqueue has been used.
> > Since the workqueue is not being used on a memory reclaim path,
> > WQ_MEM_RECLAIM has not been set.
> 
> That is incorrect. The work queue is used by the HCD to handle
> TDs, which are parts of basic IO. The HCD in turn is used by
> usb-storage and uas, which are block drivers and those are obviously
> used on the memory reclaim path.

Hmm... I didn't know the whole USB stack could operate without
allocating memory.  Does usb stack have mempools and stuff all the way
through?

Thanks.

-- 
tejun

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27 18:00   ` Tejun Heo
@ 2016-07-27 18:54     ` Alan Stern
  2016-07-27 19:23       ` Tejun Heo
  0 siblings, 1 reply; 20+ messages in thread
From: Alan Stern @ 2016-07-27 18:54 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Michal Hocko, Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar,
	linux-kernel, linux-usb

On Wed, 27 Jul 2016, Tejun Heo wrote:

> Hello, Oliver.
> 
> On Wed, Jul 27, 2016 at 11:29:56AM +0200, Oliver Neukum wrote:
> > On Wed, 2016-07-27 at 14:50 +0530, Bhaktipriya Shridhar wrote:
> > > The workqueue "workqueue" has multiple workitems which may require
> > > ordering. Hence, a dedicated ordered workqueue has been used.
> > > Since the workqueue is not being used on a memory reclaim path,
> > > WQ_MEM_RECLAIM has not been set.
> > 
> > That is incorrect. The work queue is used by the HCD to handle
> > TDs, which are parts of basic IO. The HCD in turn is used by
> > usb-storage and uas, which are block drivers and those are obviously
> > used on the memory reclaim path.
> 
> Hmm... I didn't know the whole USB stack could operate without
> allocating memory.  Does usb stack have mempools and stuff all the way
> through?

No -- the USB stack does need to allocate memory in order to operate.  
But it is careful to use GFP_NOIO or GFP_ATOMIC for allocations that
might be on the block-device path.

Alan Stern

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27 18:54     ` Alan Stern
@ 2016-07-27 19:23       ` Tejun Heo
  2016-07-27 20:45         ` Alan Stern
  0 siblings, 1 reply; 20+ messages in thread
From: Tejun Heo @ 2016-07-27 19:23 UTC (permalink / raw)
  To: Alan Stern
  Cc: Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Michal Hocko, Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar,
	linux-kernel, linux-usb

Hello, Alan.

On Wed, Jul 27, 2016 at 02:54:51PM -0400, Alan Stern wrote:
> > Hmm... I didn't know the whole USB stack could operate without
> > allocating memory.  Does usb stack have mempools and stuff all the way
> > through?
> 
> No -- the USB stack does need to allocate memory in order to operate.  
> But it is careful to use GFP_NOIO or GFP_ATOMIC for allocations that
> might be on the block-device path.

Hmm... That doesn't really make them dependable during memory reclaim.
What happens when those allocations fail?

Thanks.

-- 
tejun

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27 19:23       ` Tejun Heo
@ 2016-07-27 20:45         ` Alan Stern
  2016-07-29 13:11           ` Tejun Heo
  0 siblings, 1 reply; 20+ messages in thread
From: Alan Stern @ 2016-07-27 20:45 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Michal Hocko, Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar,
	linux-kernel, linux-usb

On Wed, 27 Jul 2016, Tejun Heo wrote:

> Hello, Alan.
> 
> On Wed, Jul 27, 2016 at 02:54:51PM -0400, Alan Stern wrote:
> > > Hmm... I didn't know the whole USB stack could operate without
> > > allocating memory.  Does usb stack have mempools and stuff all the way
> > > through?
> > 
> > No -- the USB stack does need to allocate memory in order to operate.  
> > But it is careful to use GFP_NOIO or GFP_ATOMIC for allocations that
> > might be on the block-device path.
> 
> Hmm... That doesn't really make them dependable during memory reclaim.

True.  But it does mean that they can't cause a deadlock by waiting
indefinitely for some other memory to be paged out to the very device
they are on the access pathway for.

> What happens when those allocations fail?

The same thing that happens when any allocation fails -- the original
I/O request fails with -ENOMEM or the equivalent.  In the case of 
usb-storage, this is likely to trigger error recovery, which will need 
to allocate memory of its own...  A bad situation to get into.

Alan Stern

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-27 20:45         ` Alan Stern
@ 2016-07-29 13:11           ` Tejun Heo
  2016-08-01 13:50             ` Michal Hocko
  0 siblings, 1 reply; 20+ messages in thread
From: Tejun Heo @ 2016-07-29 13:11 UTC (permalink / raw)
  To: Alan Stern
  Cc: Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Michal Hocko, Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar,
	linux-kernel, linux-usb, Johannes Weiner

Hello, Alan.

On Wed, Jul 27, 2016 at 04:45:19PM -0400, Alan Stern wrote:
> > Hmm... That doesn't really make them dependable during memory reclaim.
> 
> True.  But it does mean that they can't cause a deadlock by waiting
> indefinitely for some other memory to be paged out to the very device
> they are on the access pathway for.
> 
> > What happens when those allocations fail?
> 
> The same thing that happens when any allocation fails -- the original
> I/O request fails with -ENOMEM or the equivalent.  In the case of 
> usb-storage, this is likely to trigger error recovery, which will need 
> to allocate memory of its own...  A bad situation to get into.

All that would do is deferring the deadlock, right?  I'm not sure it
makes a lot of sense to protect an IO path against memory pressure
half-way.  It either can be depended during memory reclaim or it
can't.  The use of GFP_NOIO / ATOMIC is probably increases the chance
of IO errors under moderate memory pressure too when there are
dependable memory backing devices (and there better be) which can push
things forward if called upon.

Can MM people please chime in?  The question is about USB stoage
devices and memory reclaim.  USB doesn't guarantee forward progress
under memory pressure but tries a best-effort attempt with GFP_NOIO
and ATOMIC.  Is this the right thing to do?

Thanks.

-- 
tejun

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-07-29 13:11           ` Tejun Heo
@ 2016-08-01 13:50             ` Michal Hocko
  2016-08-01 14:20               ` Tejun Heo
  0 siblings, 1 reply; 20+ messages in thread
From: Michal Hocko @ 2016-08-01 13:50 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Alan Stern, Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar, linux-kernel,
	linux-usb, Johannes Weiner

On Fri 29-07-16 09:11:47, Tejun Heo wrote:
> Hello, Alan.
> 
> On Wed, Jul 27, 2016 at 04:45:19PM -0400, Alan Stern wrote:
> > > Hmm... That doesn't really make them dependable during memory reclaim.
> > 
> > True.  But it does mean that they can't cause a deadlock by waiting
> > indefinitely for some other memory to be paged out to the very device
> > they are on the access pathway for.
> > 
> > > What happens when those allocations fail?
> > 
> > The same thing that happens when any allocation fails -- the original
> > I/O request fails with -ENOMEM or the equivalent.  In the case of 
> > usb-storage, this is likely to trigger error recovery, which will need 
> > to allocate memory of its own...  A bad situation to get into.
> 
> All that would do is deferring the deadlock, right?  I'm not sure it
> makes a lot of sense to protect an IO path against memory pressure
> half-way.  It either can be depended during memory reclaim or it
> can't. 

Completely agreed! If the rescuer thread can block on a memory
allocation be it GFP_NOIO or others it is basically useless.

> The use of GFP_NOIO / ATOMIC is probably increases the chance
> of IO errors under moderate memory pressure too when there are
> dependable memory backing devices (and there better be) which can push
> things forward if called upon.
> 
> Can MM people please chime in?  The question is about USB stoage
> devices and memory reclaim.  USB doesn't guarantee forward progress
> under memory pressure but tries a best-effort attempt with GFP_NOIO
> and ATOMIC.  Is this the right thing to do?

If any real IO depends on those devices then this is not sufficient and
they need some form of guarantee for progress (aka mempool).
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-01 13:50             ` Michal Hocko
@ 2016-08-01 14:20               ` Tejun Heo
  2016-08-01 18:00                 ` Alan Stern
  2016-08-02  8:06                 ` Oliver Neukum
  0 siblings, 2 replies; 20+ messages in thread
From: Tejun Heo @ 2016-08-01 14:20 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Alan Stern, Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar, linux-kernel,
	linux-usb, Johannes Weiner

Hello,

On Mon, Aug 01, 2016 at 03:50:36PM +0200, Michal Hocko wrote:
> > All that would do is deferring the deadlock, right?  I'm not sure it
> > makes a lot of sense to protect an IO path against memory pressure
> > half-way.  It either can be depended during memory reclaim or it
> > can't. 
> 
> Completely agreed! If the rescuer thread can block on a memory
> allocation be it GFP_NOIO or others it is basically useless.
...
> > Can MM people please chime in?  The question is about USB stoage
> > devices and memory reclaim.  USB doesn't guarantee forward progress
> > under memory pressure but tries a best-effort attempt with GFP_NOIO
> > and ATOMIC.  Is this the right thing to do?
> 
> If any real IO depends on those devices then this is not sufficient and
> they need some form of guarantee for progress (aka mempool).

Oliver, Alan, what do you think?  If USB itself can't operate without
allocating memory during transactions, whatever USB storage drivers
are doing isn't all that meaningful.  Can we proceed with the
workqueue patches?  Also, it could be that the only thing GFP_NOIO and
GFP_ATOMIC are doing is increasing the chance of IO failures under
memory pressure.  Maybe it'd be a good idea to reconsider the
approach?

Thanks.

-- 
tejun

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-01 14:20               ` Tejun Heo
@ 2016-08-01 18:00                 ` Alan Stern
  2016-08-01 18:28                   ` Michal Hocko
  2016-08-02  8:06                 ` Oliver Neukum
  1 sibling, 1 reply; 20+ messages in thread
From: Alan Stern @ 2016-08-01 18:00 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Michal Hocko, Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar, linux-kernel,
	linux-usb, Johannes Weiner

On Mon, 1 Aug 2016, Tejun Heo wrote:

> Hello,
> 
> On Mon, Aug 01, 2016 at 03:50:36PM +0200, Michal Hocko wrote:
> > > All that would do is deferring the deadlock, right?  I'm not sure it
> > > makes a lot of sense to protect an IO path against memory pressure
> > > half-way.  It either can be depended during memory reclaim or it
> > > can't. 
> > 
> > Completely agreed! If the rescuer thread can block on a memory
> > allocation be it GFP_NOIO or others it is basically useless.
> ...
> > > Can MM people please chime in?  The question is about USB stoage
> > > devices and memory reclaim.  USB doesn't guarantee forward progress
> > > under memory pressure but tries a best-effort attempt with GFP_NOIO
> > > and ATOMIC.  Is this the right thing to do?
> > 
> > If any real IO depends on those devices then this is not sufficient and
> > they need some form of guarantee for progress (aka mempool).
> 
> Oliver, Alan, what do you think?  If USB itself can't operate without
> allocating memory during transactions, whatever USB storage drivers
> are doing isn't all that meaningful.  Can we proceed with the
> workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> GFP_ATOMIC are doing is increasing the chance of IO failures under
> memory pressure.  Maybe it'd be a good idea to reconsider the
> approach?

I agree that USB's approach to memory allocation won't prevent failures 
when there is severe pressure.

However, is it possible that the _type_ of failure might be more 
transparent?  With GFP_NOIO, you end up with a cascading series of 
allocation errors and it's obvious that something has gone very wrong.  
If we were to switch to GFP_KERNEL, page-out could lead to deadlock 
with no diagnostics (except perhaps for a watchdog warning).

Regardless, I would like to hear Oliver's thoughts.

Alan Stern

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-01 18:00                 ` Alan Stern
@ 2016-08-01 18:28                   ` Michal Hocko
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Hocko @ 2016-08-01 18:28 UTC (permalink / raw)
  To: Alan Stern
  Cc: Tejun Heo, Oliver Neukum, Bhaktipriya Shridhar, Geliang Tang,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Vlastimil Babka, Mel Gorman, Saurabh Karajgaonkar, linux-kernel,
	linux-usb, Johannes Weiner

On Mon 01-08-16 14:00:57, Alan Stern wrote:
> On Mon, 1 Aug 2016, Tejun Heo wrote:
> 
> > Hello,
> > 
> > On Mon, Aug 01, 2016 at 03:50:36PM +0200, Michal Hocko wrote:
> > > > All that would do is deferring the deadlock, right?  I'm not sure it
> > > > makes a lot of sense to protect an IO path against memory pressure
> > > > half-way.  It either can be depended during memory reclaim or it
> > > > can't. 
> > > 
> > > Completely agreed! If the rescuer thread can block on a memory
> > > allocation be it GFP_NOIO or others it is basically useless.
> > ...
> > > > Can MM people please chime in?  The question is about USB stoage
> > > > devices and memory reclaim.  USB doesn't guarantee forward progress
> > > > under memory pressure but tries a best-effort attempt with GFP_NOIO
> > > > and ATOMIC.  Is this the right thing to do?
> > > 
> > > If any real IO depends on those devices then this is not sufficient and
> > > they need some form of guarantee for progress (aka mempool).
> > 
> > Oliver, Alan, what do you think?  If USB itself can't operate without
> > allocating memory during transactions, whatever USB storage drivers
> > are doing isn't all that meaningful.  Can we proceed with the
> > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > memory pressure.  Maybe it'd be a good idea to reconsider the
> > approach?
> 
> I agree that USB's approach to memory allocation won't prevent failures 
> when there is severe pressure.

Or even worse, silent hangs for GFP_NOIO requests. If the allocation
size that is issued from that context is not large (basically < order-4)
then the allocation would be retried basically for ever without invoking
the OOM killer. Now, this is rather unlikely to become a real problem
unless there is a serious flood of these GFP_NOIO allocation requests.
But the main point remains. GFP_NOIO doesn't guanratee a forward
progress. Success of such an allocation depends on on a different
context with the full reclaim capabilities (including the OOM killer).

-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-01 14:20               ` Tejun Heo
  2016-08-01 18:00                 ` Alan Stern
@ 2016-08-02  8:06                 ` Oliver Neukum
  2016-08-02  8:18                   ` Michal Hocko
  1 sibling, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2016-08-02  8:06 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Michal Hocko, Geliang Tang, Johannes Weiner,
	Bhaktipriya Shridhar, GeyslanG.Bem@Karyakshetra, Masanari Iida,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> Hello,

> > If any real IO depends on those devices then this is not sufficient and
> > they need some form of guarantee for progress (aka mempool).
> 
> Oliver, Alan, what do you think?  If USB itself can't operate without
> allocating memory during transactions, whatever USB storage drivers

It cannot. The IO must be described to the hardware with a data
structure in memory.

> are doing isn't all that meaningful.  Can we proceed with the
> workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> GFP_ATOMIC are doing is increasing the chance of IO failures under
> memory pressure.  Maybe it'd be a good idea to reconsider the
> approach?

We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
layer can deal with IO that cannot be completed due to a lack of memory
at least somewhat, but a deadlock within a driver would obviously be
deadly. So I don't think that mempools would remove the need for
GFP_NOIO as there are places in usbcore we cannot enter the page
laundering path from. They are an additional need.

	Regards
		Oliver

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02  8:06                 ` Oliver Neukum
@ 2016-08-02  8:18                   ` Michal Hocko
  2016-08-02 10:03                     ` Oliver Neukum
  0 siblings, 1 reply; 20+ messages in thread
From: Michal Hocko @ 2016-08-02  8:18 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Tejun Heo, Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Greg Kroah-Hartman,
	Alan Stern, Vlastimil Babka, Mel Gorman, linux-kernel, linux-usb,
	Saurabh Karajgaonkar

On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > Hello,
> 
> > > If any real IO depends on those devices then this is not sufficient and
> > > they need some form of guarantee for progress (aka mempool).
> > 
> > Oliver, Alan, what do you think?  If USB itself can't operate without
> > allocating memory during transactions, whatever USB storage drivers
> 
> It cannot. The IO must be described to the hardware with a data
> structure in memory.
> 
> > are doing isn't all that meaningful.  Can we proceed with the
> > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > memory pressure.  Maybe it'd be a good idea to reconsider the
> > approach?
> 
> We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> layer can deal with IO that cannot be completed due to a lack of memory
> at least somewhat, but a deadlock within a driver would obviously be
> deadly. So I don't think that mempools would remove the need for
> GFP_NOIO as there are places in usbcore we cannot enter the page
> laundering path from. They are an additional need.

OK, I guess there is some misunderstanding here. I believe that Tejun
wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
lock avoidance. No question about that. The whole point is that
WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
much if the work item would do GFP_NOIO and get stuck in the page
allocator.
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02  8:18                   ` Michal Hocko
@ 2016-08-02 10:03                     ` Oliver Neukum
  2016-08-02 11:34                       ` Michal Hocko
  0 siblings, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2016-08-02 10:03 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Tejun Heo,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue, 2016-08-02 at 10:18 +0200, Michal Hocko wrote:
> On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> > On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > > Hello,
> > 
> > > > If any real IO depends on those devices then this is not sufficient and
> > > > they need some form of guarantee for progress (aka mempool).
> > > 
> > > Oliver, Alan, what do you think?  If USB itself can't operate without
> > > allocating memory during transactions, whatever USB storage drivers
> > 
> > It cannot. The IO must be described to the hardware with a data
> > structure in memory.
> > 
> > > are doing isn't all that meaningful.  Can we proceed with the
> > > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > > memory pressure.  Maybe it'd be a good idea to reconsider the
> > > approach?
> > 
> > We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> > layer can deal with IO that cannot be completed due to a lack of memory
> > at least somewhat, but a deadlock within a driver would obviously be
> > deadly. So I don't think that mempools would remove the need for
> > GFP_NOIO as there are places in usbcore we cannot enter the page
> > laundering path from. They are an additional need.
> 
> OK, I guess there is some misunderstanding here. I believe that Tejun
> wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
> lock avoidance. No question about that. The whole point is that
> WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
> much if the work item would do GFP_NOIO and get stuck in the page
> allocator.

But that can be a problem only if the items on the work queue are
actually run and without WQ_MEM_RECLAIM that guarantee cannot be made.
We can deal with failures of memory allocation. But the requests
must actually terminate.

	Regards
		Oliver

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 10:03                     ` Oliver Neukum
@ 2016-08-02 11:34                       ` Michal Hocko
  2016-08-02 11:44                         ` Oliver Neukum
  0 siblings, 1 reply; 20+ messages in thread
From: Michal Hocko @ 2016-08-02 11:34 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Tejun Heo,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue 02-08-16 12:03:23, Oliver Neukum wrote:
> On Tue, 2016-08-02 at 10:18 +0200, Michal Hocko wrote:
> > On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> > > On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > > > Hello,
> > > 
> > > > > If any real IO depends on those devices then this is not sufficient and
> > > > > they need some form of guarantee for progress (aka mempool).
> > > > 
> > > > Oliver, Alan, what do you think?  If USB itself can't operate without
> > > > allocating memory during transactions, whatever USB storage drivers
> > > 
> > > It cannot. The IO must be described to the hardware with a data
> > > structure in memory.
> > > 
> > > > are doing isn't all that meaningful.  Can we proceed with the
> > > > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > > > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > > > memory pressure.  Maybe it'd be a good idea to reconsider the
> > > > approach?
> > > 
> > > We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> > > layer can deal with IO that cannot be completed due to a lack of memory
> > > at least somewhat, but a deadlock within a driver would obviously be
> > > deadly. So I don't think that mempools would remove the need for
> > > GFP_NOIO as there are places in usbcore we cannot enter the page
> > > laundering path from. They are an additional need.
> > 
> > OK, I guess there is some misunderstanding here. I believe that Tejun
> > wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
> > lock avoidance. No question about that. The whole point is that
> > WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
> > much if the work item would do GFP_NOIO and get stuck in the page
> > allocator.
> 
> But that can be a problem only if the items on the work queue are
> actually run and without WQ_MEM_RECLAIM that guarantee cannot be made.
> We can deal with failures of memory allocation. But the requests
> must actually terminate.

I think you have missed my point. So let me ask differently. What is the
difference between your work item not running at all or looping
endlessly with GFP_NOIO inside the page allocator? If that particular
work item is necessary for the further progress then the system is
screwed one way or another.
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 11:34                       ` Michal Hocko
@ 2016-08-02 11:44                         ` Oliver Neukum
  2016-08-02 12:48                           ` Michal Hocko
  0 siblings, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2016-08-02 11:44 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Tejun Heo,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue, 2016-08-02 at 13:34 +0200, Michal Hocko wrote:
> On Tue 02-08-16 12:03:23, Oliver Neukum wrote:
> > On Tue, 2016-08-02 at 10:18 +0200, Michal Hocko wrote:
> > > On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> > > > On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > > > > Hello,
> > > > 
> > > > > > If any real IO depends on those devices then this is not sufficient and
> > > > > > they need some form of guarantee for progress (aka mempool).
> > > > > 
> > > > > Oliver, Alan, what do you think?  If USB itself can't operate without
> > > > > allocating memory during transactions, whatever USB storage drivers
> > > > 
> > > > It cannot. The IO must be described to the hardware with a data
> > > > structure in memory.
> > > > 
> > > > > are doing isn't all that meaningful.  Can we proceed with the
> > > > > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > > > > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > > > > memory pressure.  Maybe it'd be a good idea to reconsider the
> > > > > approach?
> > > > 
> > > > We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> > > > layer can deal with IO that cannot be completed due to a lack of memory
> > > > at least somewhat, but a deadlock within a driver would obviously be
> > > > deadly. So I don't think that mempools would remove the need for
> > > > GFP_NOIO as there are places in usbcore we cannot enter the page
> > > > laundering path from. They are an additional need.
> > > 
> > > OK, I guess there is some misunderstanding here. I believe that Tejun
> > > wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
> > > lock avoidance. No question about that. The whole point is that
> > > WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
> > > much if the work item would do GFP_NOIO and get stuck in the page
> > > allocator.
> > 
> > But that can be a problem only if the items on the work queue are
> > actually run and without WQ_MEM_RECLAIM that guarantee cannot be made.
> > We can deal with failures of memory allocation. But the requests
> > must actually terminate.
> 
> I think you have missed my point. So let me ask differently. What is the
> difference between your work item not running at all or looping
> endlessly with GFP_NOIO inside the page allocator? If that particular
> work item is necessary for the further progress then the system is
> screwed one way or another.

The key difference is that I could give the right parameters to the
kmalloc() call. If it doesn't run, I am surely screwed. Thus I conclude
that WQ_RECLAIM needs to be set.

	Regards
		Oliver

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 11:44                         ` Oliver Neukum
@ 2016-08-02 12:48                           ` Michal Hocko
  2016-08-02 13:29                             ` Oliver Neukum
  0 siblings, 1 reply; 20+ messages in thread
From: Michal Hocko @ 2016-08-02 12:48 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Tejun Heo,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue 02-08-16 13:44:48, Oliver Neukum wrote:
> On Tue, 2016-08-02 at 13:34 +0200, Michal Hocko wrote:
> > On Tue 02-08-16 12:03:23, Oliver Neukum wrote:
> > > On Tue, 2016-08-02 at 10:18 +0200, Michal Hocko wrote:
> > > > On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> > > > > On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > > > > > Hello,
> > > > > 
> > > > > > > If any real IO depends on those devices then this is not sufficient and
> > > > > > > they need some form of guarantee for progress (aka mempool).
> > > > > > 
> > > > > > Oliver, Alan, what do you think?  If USB itself can't operate without
> > > > > > allocating memory during transactions, whatever USB storage drivers
> > > > > 
> > > > > It cannot. The IO must be described to the hardware with a data
> > > > > structure in memory.
> > > > > 
> > > > > > are doing isn't all that meaningful.  Can we proceed with the
> > > > > > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > > > > > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > > > > > memory pressure.  Maybe it'd be a good idea to reconsider the
> > > > > > approach?
> > > > > 
> > > > > We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> > > > > layer can deal with IO that cannot be completed due to a lack of memory
> > > > > at least somewhat, but a deadlock within a driver would obviously be
> > > > > deadly. So I don't think that mempools would remove the need for
> > > > > GFP_NOIO as there are places in usbcore we cannot enter the page
> > > > > laundering path from. They are an additional need.
> > > > 
> > > > OK, I guess there is some misunderstanding here. I believe that Tejun
> > > > wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
> > > > lock avoidance. No question about that. The whole point is that
> > > > WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
> > > > much if the work item would do GFP_NOIO and get stuck in the page
> > > > allocator.
> > > 
> > > But that can be a problem only if the items on the work queue are
> > > actually run and without WQ_MEM_RECLAIM that guarantee cannot be made.
> > > We can deal with failures of memory allocation. But the requests
> > > must actually terminate.
> > 
> > I think you have missed my point. So let me ask differently. What is the
> > difference between your work item not running at all or looping
> > endlessly with GFP_NOIO inside the page allocator? If that particular
> > work item is necessary for the further progress then the system is
> > screwed one way or another.
> 
> The key difference is that I could give the right parameters to the
> kmalloc() call. If it doesn't run, I am surely screwed. Thus I conclude
> that WQ_RECLAIM needs to be set.

Just to make sure I understand. So you will never call kmalloc with
__GFP_DIRECT_RECLAIM from the rescuer context, right?
-- 
Michal Hocko
SUSE Labs

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 12:48                           ` Michal Hocko
@ 2016-08-02 13:29                             ` Oliver Neukum
  2016-08-02 19:02                               ` Tejun Heo
  0 siblings, 1 reply; 20+ messages in thread
From: Oliver Neukum @ 2016-08-02 13:29 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Geliang Tang, Johannes Weiner, Bhaktipriya Shridhar,
	GeyslanG.Bem@Karyakshetra, Masanari Iida, Tejun Heo,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue, 2016-08-02 at 14:48 +0200, Michal Hocko wrote:
> On Tue 02-08-16 13:44:48, Oliver Neukum wrote:
> > On Tue, 2016-08-02 at 13:34 +0200, Michal Hocko wrote:
> > > On Tue 02-08-16 12:03:23, Oliver Neukum wrote:
> > > > On Tue, 2016-08-02 at 10:18 +0200, Michal Hocko wrote:
> > > > > On Tue 02-08-16 10:06:12, Oliver Neukum wrote:
> > > > > > On Mon, 2016-08-01 at 10:20 -0400, Tejun Heo wrote:
> > > > > > > Hello,
> > > > > > 
> > > > > > > > If any real IO depends on those devices then this is not sufficient and
> > > > > > > > they need some form of guarantee for progress (aka mempool).
> > > > > > > 
> > > > > > > Oliver, Alan, what do you think?  If USB itself can't operate without
> > > > > > > allocating memory during transactions, whatever USB storage drivers
> > > > > > 
> > > > > > It cannot. The IO must be described to the hardware with a data
> > > > > > structure in memory.
> > > > > > 
> > > > > > > are doing isn't all that meaningful.  Can we proceed with the
> > > > > > > workqueue patches?  Also, it could be that the only thing GFP_NOIO and
> > > > > > > GFP_ATOMIC are doing is increasing the chance of IO failures under
> > > > > > > memory pressure.  Maybe it'd be a good idea to reconsider the
> > > > > > > approach?
> > > > > > 
> > > > > > We had actual deadlocks with GFP_KERNEL. It seems to me that the SCSI
> > > > > > layer can deal with IO that cannot be completed due to a lack of memory
> > > > > > at least somewhat, but a deadlock within a driver would obviously be
> > > > > > deadly. So I don't think that mempools would remove the need for
> > > > > > GFP_NOIO as there are places in usbcore we cannot enter the page
> > > > > > laundering path from. They are an additional need.
> > > > > 
> > > > > OK, I guess there is some misunderstanding here. I believe that Tejun
> > > > > wasn't arguing to drop GFP_NOIO. It might be really needed for the dead
> > > > > lock avoidance. No question about that. The whole point is that
> > > > > WQ_RECLAIM might be completely pointless because a rescuer wouldn't help
> > > > > much if the work item would do GFP_NOIO and get stuck in the page
> > > > > allocator.
> > > > 
> > > > But that can be a problem only if the items on the work queue are
> > > > actually run and without WQ_MEM_RECLAIM that guarantee cannot be made.
> > > > We can deal with failures of memory allocation. But the requests
> > > > must actually terminate.
> > > 
> > > I think you have missed my point. So let me ask differently. What is the
> > > difference between your work item not running at all or looping
> > > endlessly with GFP_NOIO inside the page allocator? If that particular
> > > work item is necessary for the further progress then the system is
> > > screwed one way or another.
> > 
> > The key difference is that I could give the right parameters to the
> > kmalloc() call. If it doesn't run, I am surely screwed. Thus I conclude
> > that WQ_RECLAIM needs to be set.
> 
> Just to make sure I understand. So you will never call kmalloc with
> __GFP_DIRECT_RECLAIM from the rescuer context, right?

Apparently if that is the requirement USB will have to define its own
set of flags to use in such contexts. But still the calls as currently
executed work. Taking away WQ_MEM_RECLAIM would create danger of
introducing a regression. The issue with __GFP_DIRECT_RECLAIM already
exists and can be fixed.

	Regards
		Oliver

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 13:29                             ` Oliver Neukum
@ 2016-08-02 19:02                               ` Tejun Heo
  2016-08-02 21:26                                 ` Michal Hocko
  0 siblings, 1 reply; 20+ messages in thread
From: Tejun Heo @ 2016-08-02 19:02 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Michal Hocko, Geliang Tang, Johannes Weiner,
	Bhaktipriya Shridhar, GeyslanG.Bem@Karyakshetra, Masanari Iida,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

Hello,

On Tue, Aug 02, 2016 at 03:29:48PM +0200, Oliver Neukum wrote:
> Apparently if that is the requirement USB will have to define its own
> set of flags to use in such contexts. But still the calls as currently
> executed work. Taking away WQ_MEM_RECLAIM would create danger of
> introducing a regression. The issue with __GFP_DIRECT_RECLAIM already
> exists and can be fixed.

Alright, let's go with WQ_MEM_RECLAIM then.

Thanks.

-- 
tejun

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

* Re: [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue
  2016-08-02 19:02                               ` Tejun Heo
@ 2016-08-02 21:26                                 ` Michal Hocko
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Hocko @ 2016-08-02 21:26 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Oliver Neukum, Geliang Tang, Johannes Weiner,
	Bhaktipriya Shridhar, GeyslanG.Bem@Karyakshetra, Masanari Iida,
	Greg Kroah-Hartman, Alan Stern, Vlastimil Babka, Mel Gorman,
	linux-kernel, linux-usb, Saurabh Karajgaonkar

On Tue 02-08-16 15:02:44, Tejun Heo wrote:
> Hello,
> 
> On Tue, Aug 02, 2016 at 03:29:48PM +0200, Oliver Neukum wrote:
> > Apparently if that is the requirement USB will have to define its own
> > set of flags to use in such contexts. But still the calls as currently
> > executed work. Taking away WQ_MEM_RECLAIM would create danger of
> > introducing a regression. The issue with __GFP_DIRECT_RECLAIM already
> > exists and can be fixed.
> 
> Alright, let's go with WQ_MEM_RECLAIM then.

Agreed, I would just add
/*
 * TODO: make sure that no work item in the rescuer can block on an
 * allocation (so no __GF_DIRECT_RECLAIM)
 */
to all work item functions.
-- 
Michal Hocko
SUSE Labs

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

end of thread, other threads:[~2016-08-02 21:35 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27  9:20 [RFC] usb: host: u132-hcd: Remove deprecated create_singlethread_workqueue Bhaktipriya Shridhar
2016-07-27  9:29 ` Oliver Neukum
2016-07-27 18:00   ` Tejun Heo
2016-07-27 18:54     ` Alan Stern
2016-07-27 19:23       ` Tejun Heo
2016-07-27 20:45         ` Alan Stern
2016-07-29 13:11           ` Tejun Heo
2016-08-01 13:50             ` Michal Hocko
2016-08-01 14:20               ` Tejun Heo
2016-08-01 18:00                 ` Alan Stern
2016-08-01 18:28                   ` Michal Hocko
2016-08-02  8:06                 ` Oliver Neukum
2016-08-02  8:18                   ` Michal Hocko
2016-08-02 10:03                     ` Oliver Neukum
2016-08-02 11:34                       ` Michal Hocko
2016-08-02 11:44                         ` Oliver Neukum
2016-08-02 12:48                           ` Michal Hocko
2016-08-02 13:29                             ` Oliver Neukum
2016-08-02 19:02                               ` Tejun Heo
2016-08-02 21:26                                 ` Michal Hocko

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