Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp988915ybm; Tue, 21 May 2019 07:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb53MyvepczeHil2XvrGFueH5VnKYeWkoujBzjCh25/O31qCVYmrZNz4lfpG/C+eQ2TPgj X-Received: by 2002:a17:902:6ac6:: with SMTP id i6mr82923533plt.336.1558447387826; Tue, 21 May 2019 07:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558447387; cv=none; d=google.com; s=arc-20160816; b=0XbCcDi7YLb9u3p/oGF+m6ZwhkRifVMZdrmZ+UnLcBqKOrvl6Sj8NnErKdrdoSLrK0 cI5+WCvsymwsvPpOG8evU4FCbCIPKVjTTYY3zNVO3wPsFB0FaYMnfLQr8EdpMsGO2aCy IrRo3TqlINz2ubBE2Tn++CYVukRM9K8Sm2XmypauCChqCdj+SogmvXrrcN3JMrHhhJdz FuOTXPto7R0UKzm+iwDBQgu3M85DrX4yiGu9cjYGME0C+XNKoO1SNJVjFQm7kbZOScH/ iMiXttqluyCXGeOm0D6tjzheuwBgW+bPX5TpEuHCvqAcaDjbl6cDrgS41XZrqnXkZT1k FVOQ== 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=fnDAJf2ya1MMBX7glzPZ25P8Fu5IoQyt4BQ1lJ1VaMw=; b=bcqGxvu/9QpezhMvv+vNwxnt7mo629imo/rqVna99xxpa2sRkyp9KNwTS8fsvppcSp 1uIOeiE9N2JOhGygNzykq1UBJnFwqlAeJKVU99lN8lTXTztVySK9biy891sO+LgT9k3h itaLxyOwSCiSJ98MdHUMtE8oXaBEFPiaIPH+Ms2boEb+Di1qkOd2KLVmqRfkuLyM/zbN uJbw8/w6f16xW5s03HFAmyDb5pFEzqtwLQqR7FgllKHhk1F8h0UYxrRsxfnOzYa6yMdV y4Fp4U18xI+QXGCmfiwvVOdhIbfe3l1e+88bZK80gpo71oaeT7OWqG2QoQMOwrw34mrH G0mw== 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 s59si21525409plb.241.2019.05.21.07.02.44; Tue, 21 May 2019 07:03:07 -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 S1728369AbfEUOAL (ORCPT + 99 others); Tue, 21 May 2019 10:00:11 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:32988 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728242AbfEUOAL (ORCPT ); Tue, 21 May 2019 10:00:11 -0400 Received: (qmail 1871 invoked by uid 2102); 21 May 2019 10:00:10 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 21 May 2019 10:00:10 -0400 Date: Tue, 21 May 2019 10:00:10 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Oliver Neukum cc: Christoph Hellwig , Jaewon Kim , , , Jaewon Kim , , , , Subject: Re: [RFC PATCH] usb: host: xhci: allow __GFP_FS in dma allocation In-Reply-To: <1558444291.12672.23.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 Tue, 21 May 2019, Oliver Neukum wrote: > On Mo, 2019-05-20 at 10:16 -0400, Alan Stern wrote: > > On Mon, 20 May 2019, Christoph Hellwig wrote: > > > > > GFP_KERNEL if you can block, GFP_ATOMIC if you can't for a good reason, > > > that is the allocation is from irq context or under a spinlock. If you > > > think you have a case where you think you don't want to block, but it > > > is not because of the above reasons we need to have a chat about the > > > details. > > > > What if the allocation requires the kernel to swap some old pages out > > to the backing store, but the backing store is on the device that the > > driver is managing? The swap can't take place until the current I/O > > operation is complete (assuming the driver can handle only one I/O > > operation at a time), and the current operation can't complete until > > the old pages are swapped out. Result: deadlock. > > > > Isn't that the whole reason for using GFP_NOIO in the first place? > > Hi, > > lookig at this it seems to me that we are in danger of a deadlock > > - during reset - devices cannot do IO while being reset > covered by the USB layer in usb_reset_device > - resume & restore - devices cannot do IO while suspended > covered by driver core in rpm_callback > - disconnect - a disconnected device cannot do IO > is this a theoretical case or should I do something to > the driver core? > > How about changing configurations on USB? Changing configurations amounts to much the same as disconnecting, because both operations destroy all the existing interfaces. Disconnect can arise in two different ways. Physical hot-unplug: All I/O operations will fail. Rmmod or unbind: I/O operations will succeed. The second case is probably okay. The first we can do nothing about. However, in either case we do need to make sure that memory allocations do not require any writebacks. This suggests that we need to call memalloc_noio_save() from within usb_unbind_interface(). Alan Stern