Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2500671ybd; Mon, 24 Jun 2019 07:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyE71JSEB2toJqwWSxCYcG0l69W2hbHkxpF8EK8k5y6/RUCqg1QTc6MpeKEs8U2tOZOh1C2 X-Received: by 2002:a17:902:684:: with SMTP id 4mr22613910plh.138.1561386645878; Mon, 24 Jun 2019 07:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561386645; cv=none; d=google.com; s=arc-20160816; b=mfQS6jCbCQWF1NqzK8rtNuVrTgU7W96EtbsAI1WX2/oItxHg0jMSllWczXYpiUDEYU Gwf2UZijS07bcOMGhyrfRfm9Uo95yn5+2W6XYCjxdiirmV+EAspDrgSnEeaX07NAzE14 HobIym889YQh/wtL9oEArSK/7Qvw75fwRuuunyAMCldUwIH7NJV7gQ8mxLGrRsmlO+Xp SPfaOeeAkvUp+HEMa4obhB5WQt9N/oyaQycqJaR1hUJGv41KlH57G3h3Si8ks1ILS098 JVYdAwfaHEdMfE7Xaz6Vhg1xW/t2O5Vs5DTmyAJco+jirU3u/gLo0wbuuc3uEk8ho/73 5x3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=ek75y8/aRJgXsVcbLFJoiVT85QaqhOgl5RccdWDhw4A=; b=GSC9QgPELSKSeQO7csfEPRrVRVRQNiTFmiaR2bWnLoN5BfVifPXJUMFN2qwPcOXTgK 3y0J7SFNc94gnJNYsSzysklY87X1AvMheDXHRnDzWjX0sjsrRawceMWosf9YLIjRvOVs /CmOW/4HXP1kdMOjkf0/LX/eTuoTe4DNk9Cd4q2DjcIzoYtyrKCbBSu47D991pACY7oQ +4DzSlDFggQodk1nqsLy6sr6PvLyTO1HCgYk3+cBu6+bxJBJZdHUI+08xtaFxU00Rd5H 1HvtKUNh6/eZRIJxVXHFqgnESp+Be/ary0vm5LAaSl3tLUxON2GdEbyTTS6QJD1yNezH x+PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g145si10548629pfb.173.2019.06.24.07.30.29; Mon, 24 Jun 2019 07:30:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727660AbfFXOWM (ORCPT + 99 others); Mon, 24 Jun 2019 10:22:12 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:56826 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727451AbfFXOWL (ORCPT ); Mon, 24 Jun 2019 10:22:11 -0400 Received: (qmail 1735 invoked by uid 2102); 24 Jun 2019 10:22:10 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 Jun 2019 10:22:10 -0400 Date: Mon, 24 Jun 2019 10:22:10 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Oliver Neukum cc: Tejun Heo , Kernel development list , USB list Subject: Re: [RFC] deadlock with flush_work() in UAS In-Reply-To: <1561366612.2846.10.camel@suse.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jun 2019, Oliver Neukum wrote: > Am Donnerstag, den 20.06.2019, 07:10 -0700 schrieb Tejun Heo: > > Hello, > > > > On Tue, Jun 18, 2019 at 11:59:39AM -0400, Alan Stern wrote: > > > > > Even if you disagree, perhaps we should have a global workqueue with a > > > > > permanently set noio flag. It could be shared among multiple drivers > > > > > such as uas and the hub driver for purposes like this. (In fact, the > > > > > hub driver already has its own dedicated workqueue.) > > > > > > > > That is a good idea. But does UAS need WQ_MEM_RECLAIM? > > > > > > These are good questions, and I don't have the answers. Perhaps Tejun > > > or someone else on LKML can help. > > > > Any device which may host a filesystem or swap needs to use > > WQ_MEM_RECLAIM workqueues on anything which may be used during normal > > IOs including e.g. error handling which may be invoked. One > > WQ_MEM_RECLAIM workqueue guarantees one level of concurrency for all > > its tasks regardless of memory situation, so as long as there's no > > interdependence between work items, the workqueue can be shared. > > Ouch. > > Alan, in that case anything doing a reset, suspend or resume needs > to use WQ_MEM_RECLAIM, it looks to me. What do we do? I'm not sure this is really a problem. For example, the reset issue arises only when a driver does the following: Locks the device. Queues a work routine to reset the device. Waits for the reset to finish. Unlocks the device. But that pattern makes no sense; a driver would never use it. The driver would just do the reset itself. There's no problem if the locking is done in the work routine; in that case the usb-storage or uas driver would be able to carry out any necessary resets if the work routine was unable to start for lack of memory. Similarly, while async wakeups might get blocked by lack of memory, the normal USB driver paths use synchronous wakeup. Alan Stern