linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaewon Kim <jaewon31.kim@gmail.com>
To: gregkh@linuxfoundation.org, m.szyprowski@samsung.com,
	linux-mm@kvack.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Jaewon Kim <jaewon31.kim@samsung.com>, ytk.lee@samsung.com
Subject: [RFC PATCH] usb: host: xhci: allow __GFP_FS in dma allocation
Date: Sat, 18 May 2019 01:02:28 +0900	[thread overview]
Message-ID: <CAJrd-UuMRdWHky4gkmiR0QYozfXW0O35Ohv6mJPFx2TLa8hRKg@mail.gmail.com> (raw)

Hello I don't have enough knowledge on USB core but I've wondered
why GFP_NOIO has been used in xhci_alloc_dev for
xhci_alloc_virt_device. I found commit ("a6d940dd759b xhci: Use
GFP_NOIO during device reset"). But can we just change GFP_NOIO
to __GFP_RECLAIM | __GFP_FS ?

Please refer to below case.

I got a report from Lee YongTaek <ytk.lee@samsung.com> that the
xhci_alloc_virt_device was too slow over 2 seconds only for one page
allocation.

1) It was because kernel version was v4.14 and DMA allocation was
done from CMA(Contiguous Memory Allocator) where CMA region was
almost filled with file page and  CMA passes GFP down to page
isolation. And the page isolation only allows file page isolation only to
requests having __GFP_FS.

2) Historically CMA was changed at v4.19 to use GFP_KERNEL
regardless of GFP passed to  DMA allocation through the
commit 6518202970c1 "(mm/cma: remove unsupported gfp_mask
parameter from cma_alloc()".

I think pre v4.19 the xhci_alloc_virt_device could be very slow
depending on CMA situation but free to USB deadlock issue. But as of
v4.19, I think, it will be fast but can face the deadlock issue.
Consequently I think to meet the both cases, I think USB can pass
__GFP_FS without __GFP_IO.

If __GFP_FS is passed from USB core, of course, the CMA patch also
need to be changed to pass GFP.

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 005e65922608..38abcd03a1a2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3893,7 +3893,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct
usb_device *udev)
         * xhci_discover_or_reset_device(), which may be called as part of
         * mass storage driver error handling.
         */
-       if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
+       if (!xhci_alloc_virt_device(xhci, slot_id, udev, __GFP_RECLAIM
| __GFP_FS)) {
                xhci_warn(xhci, "Could not allocate xHCI USB device
data structures\n");
                goto disable_slot;
        }


Thank you

             reply	other threads:[~2019-05-17 16:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 16:02 Jaewon Kim [this message]
2019-05-17 16:34 ` [RFC PATCH] usb: host: xhci: allow __GFP_FS in dma allocation Matthew Wilcox
2019-05-18  1:53   ` Jaewon Kim
2019-05-20  5:56 ` Christoph Hellwig
2019-05-20  9:09   ` Oliver Neukum
2019-05-20 10:12     ` Christoph Hellwig
2019-05-20 14:16       ` Alan Stern
2019-05-20 14:23         ` Christoph Hellwig
2019-05-21  8:54           ` Oliver Neukum
2019-05-21 13:27             ` Christoph Hellwig
2019-05-21 13:11         ` Oliver Neukum
2019-05-21 14:00           ` Alan Stern
2019-05-22  6:31             ` Oliver Neukum
2019-05-22 14:56               ` Alan Stern
2019-05-22 20:47                 ` Oliver Neukum
2019-05-23 14:01                   ` Alan Stern
2019-05-28 12:34                     ` Oliver Neukum
2019-05-28 14:25                       ` Alan Stern
2019-05-23 12:32   ` Oliver Neukum
2019-05-23 16:35     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJrd-UuMRdWHky4gkmiR0QYozfXW0O35Ohv6mJPFx2TLa8hRKg@mail.gmail.com \
    --to=jaewon31.kim@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jaewon31.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=ytk.lee@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).