Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2091542yba; Fri, 17 May 2019 10:15:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqySBzBeA1qwb8XRBzJWzEgOxmOaG4vdy0oLZG/+cT8dMfF07yJSKPVYGR2F9cO73k376m1x X-Received: by 2002:a17:902:2e81:: with SMTP id r1mr42231554plb.0.1558113348114; Fri, 17 May 2019 10:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558113348; cv=none; d=google.com; s=arc-20160816; b=mJovf0OQJNcL4lusXkNgY16lO0KevmpB17qyLzvYvV0tjwkZGL8ACqnMlvTbHvhu/G 6SRI9lssmpe8+kqi3S5AOBnmHDR3k5jOMVpwog6ECyV5eqnaiZB9exzh4V078zMY4ueW GA/o4ESAtCUYDIYhD/A+WXaP+S1wV/7Lu7iyb7OAvOGq6E8BW8iF8Shrs+GNKw2Aqufp FAScsYUfopn1A/K+tr690rfD40fLg5JNEpUhxptVkmHDb4UOF3jpfueLbKVr55qRpaFa ijRpWqNks8jSwzXKB0goKtsuBNMiXEKf3AfHGGavR1cU/EY9H8AfL+6qbrzNdPPZ092q Liaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature; bh=gRcrtb5zkBV22N7ejZ8gd80yYzuG0eMMK0Likb2l39A=; b=TZeQ3QckxGpGHshFdo5grmc1YbNbS9KLDH3BKAlCovtqFGyXR82Pj7oehBvcVzcHzn 8k+dA9Oi5Qz2ol/GOtqAx6cCKmTc1z9shNJPcsPxAhZ4dnNJnGO151rqdGOcxtVyQPkI nLUFqTREdV4a6woqsB7YuiOxwDpIplbdZ715nHflFPvPoNA9Lg+/VKJPQr3qo6Ar8McF 7YXo+RTgcB1cDFdM3RStjtLIpuBszZ53uj1gFy0Y70qI6uQyH8CcDnqrmHLE6q9sOgSK 4sgYHX998w0dKyqF9lPbMyE1XCbrU0LCYLP7LFcJZAW4pL2h6r1zS6e24kL6J33nDONh r15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qLjX5pYM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 132si8241384pgb.210.2019.05.17.10.15.32; Fri, 17 May 2019 10:15:48 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qLjX5pYM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729398AbfEQQDE (ORCPT + 99 others); Fri, 17 May 2019 12:03:04 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:35078 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbfEQQDD (ORCPT ); Fri, 17 May 2019 12:03:03 -0400 Received: by mail-ot1-f66.google.com with SMTP id n14so7217045otk.2; Fri, 17 May 2019 09:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=gRcrtb5zkBV22N7ejZ8gd80yYzuG0eMMK0Likb2l39A=; b=qLjX5pYMmcTMjN5iFgyQsKZE0y6c8l2+gMnFTxjnwzcVJC9+73IQv1ERNRGBwqcVB1 jRNQe7asKnOot4X72/nbnRE7ZLXpGGHhCVQHVNfntOjMG1qo7pS5msGMHFXbT8alz6NV 8MZ4GlFAmF9tHddkLWQiIfiLZoD3R230cflReazsdSKB8hmkKBI5BpKwxrIt27vfGiRV iaoxpaCP0JJhEj2JXMFaw8wwGrfzzn0XPmAsNMq0oa8ktvb2lMmfwa7TtfouoWL0DbPa 0DGFpoS0qsgQPx2kd48oCzrUSwvRpDEoz39no2EGJVCoA96kzHrljKfOemLP4MpMrC+3 9VWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=gRcrtb5zkBV22N7ejZ8gd80yYzuG0eMMK0Likb2l39A=; b=QX2t0l632nKJLGVdsiMJfTazSfpVn0YXgbqBGE0Q6xNwKDvMNKzBU4ewPFQM4vVWWO I/zbvvhL4za3Su7GEo9Xv1N8S9M7Rxw/AYCkT8n7RN1boarq+nabJNl7O6PesKTnmalv 0Mo9Cmm9komJ7DmjQ1CIyTjy17SNre0EDgvPQhB2StZtH0BsQEqcw1TGllKHe+/cxnIp cbb8z2zBPweFyiJToaQAJlbBSlD5RCRMZnpz442oLkuSBqPICb+xe/Blx4gjHxpY8qxV Je3ZjaoMA/2Y5zS/KoT68GtCtlN5QE+bFkVDYPkfhcc53KUeacZYNjFW33OI/GeoaBxB nkdA== X-Gm-Message-State: APjAAAV0NPSvS2v1UHoK+H6HycCkmm78B7eKYDaVYyM3IsvYoD4qbsBD HRU2Vi9VGYgUX9EeuYBPlLL6qBCg0iEXSPHYqzk= X-Received: by 2002:a9d:64c1:: with SMTP id n1mr8954538otl.259.1558108983107; Fri, 17 May 2019 09:03:03 -0700 (PDT) MIME-Version: 1.0 From: Jaewon Kim Date: Sat, 18 May 2019 01:02:28 +0900 Message-ID: Subject: [RFC PATCH] usb: host: xhci: allow __GFP_FS in dma allocation 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 , ytk.lee@samsung.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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