Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2507581yba; Fri, 17 May 2019 19:23:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl0R3ZtaqVPBRiTjQJV0IUTKcaJtU6KCqITK2dGaNHZJ6KFrhV0qYKP7qsqM68WkwThuCf X-Received: by 2002:a62:117:: with SMTP id 23mr35817046pfb.156.1558146202950; Fri, 17 May 2019 19:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558146202; cv=none; d=google.com; s=arc-20160816; b=nEDExgUQaydgW93soy6m7GpuM5Sp6OjtVt/n+WKsG9MiQotzyJ+SGXbB8MKyFvA4cD K06WJtHklrX9iiGlu/cSxEcJQUdGkO+Iqj3/my0V0hjzl2uIlCiCdOq6gEofD1CkqUiv hZr2RizKyTIFi6F6vRqw2Nr2q9HTRwm8m/VU18MUI62kTiV4BqNCea/P7s7nKu1QV1Yt cx/s2mqh9SG0tjKZ4bdoq4UkmS/S01GwC5PakvBz2wOr0Ds+WrarAbMtB/Qqi8q15U3b D5dXsBQ3299/xgLnW0BR7ZvpFIotCnhaikbARNsdKlWBD2Hayn/SV0mCFMZpt21Zbuen 19/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nQoQJoHpzJQYSi8VTTlyTdi+eKb5pb19O1ImUVZ7ifQ=; b=QA0kx8HDyWk8yCePTuLu2RcHyAwoQBEuqKsYtEOAz3TFNXY1CfMFbLYPtoGGEJnOPZ wqC4cxdfGripkYDyGsMYple5ZK7bLgszPLDwH+l48OHlzO/VozvvaydZIwnlreFyJZxg /YygjtwJdz6XFWnJnCrhsLaIDaokqU4tE5ZN1DN3+iqEwSRrYBRq9gRC2aDzXmfRWjXf FErg55CtkGiGaJj2e/vf068LMGlaWjEA2cC65nBfD5wkY/h4UTEe2lQSc3eyvhRnxXhb FsK4yb56XcYboAvWK4YyWIm0CTS47dyfL01haymSEWSvG9P94lrSYJvZJ7QljGcpWzLK 3MIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l4ipXGRA; 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 m18si9442540pgv.209.2019.05.17.19.23.07; Fri, 17 May 2019 19:23:22 -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=l4ipXGRA; 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 S1727958AbfERBxh (ORCPT + 99 others); Fri, 17 May 2019 21:53:37 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40272 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbfERBxg (ORCPT ); Fri, 17 May 2019 21:53:36 -0400 Received: by mail-ot1-f65.google.com with SMTP id u11so8389691otq.7; Fri, 17 May 2019 18:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nQoQJoHpzJQYSi8VTTlyTdi+eKb5pb19O1ImUVZ7ifQ=; b=l4ipXGRAjIUzrlrkNvaTG2k7I+bCkITMEedVuFdJU25ONJvkJw5RSmJ17hfa8hOlTj mNz+//ZqwGZCy+TvYGRK0bDw0eTbWJ5r+kSSmDLPhgun28oX3ZxMC7XPRpjVdYpkMDni omHVPXuYpg8wrhglnXxlow1lzLh96xxBmyWiMeoD+1gwQZWGntUKXA5decjWwKiBG/lx axYgdvPwoEQZka/tB8jXG2WFzWSkSZWogp1PycM1fBN5M8h783W4P4NzgFB5oWuHQYP5 lBWYYo1w+qK5lL3mmcj3Y+cilEa1QO9YPKCKkewslqpnFc3OzC0DSNTcs5DiBqIFGYFw 0goQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nQoQJoHpzJQYSi8VTTlyTdi+eKb5pb19O1ImUVZ7ifQ=; b=PID6GIxodNvBJofQ+/f8ZwwvS5fpSt4SAl8XZQdXSpWLXmlwAHm5lvS8L8EyTnXSzg Tq+btrFrAeq4oTFq++mTDEPGWowiNBK/tII8nFEEPSf4KKsbR3mu9X8l0Ked3B2O2+eJ z+iJwyE+e/XK49l4thn/J5P/e1dMQNd1vPREBRn482N6poVx48p2WrGIDlyw8UIXJcub Xzyh2zoWhgLwzeJlYUh/BVGiBi+9jp+cn/34OT4Q5RofxYQQi28eUw04XNao4lcV8Zib jf7AMPhy+a+I9Xs4Y2TE6+HaOdaEej9MpEKZN6EWNGBj5Qgjhdj0QmYFiT35UovnqAuq vYxw== X-Gm-Message-State: APjAAAV+4r1/FA6Kskfsuaruw15W4oy6GGG5dIELWia+ItSE4gma8LTO nRWtHcyA4FFe9rf1ifHT4YNMneHMrHUxguArwFM= X-Received: by 2002:a9d:4808:: with SMTP id c8mr3385903otf.316.1558144416123; Fri, 17 May 2019 18:53:36 -0700 (PDT) MIME-Version: 1.0 References: <20190517163420.GG31704@bombadil.infradead.org> In-Reply-To: <20190517163420.GG31704@bombadil.infradead.org> From: Jaewon Kim Date: Sat, 18 May 2019 10:53:03 +0900 Message-ID: Subject: Re: [RFC PATCH] usb: host: xhci: allow __GFP_FS in dma allocation To: Matthew Wilcox Cc: gregkh@linuxfoundation.org, m.szyprowski@samsung.com, linux-mm@kvack.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jaewon Kim , ytk.lee@samsung.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you for your comment. In ARM64 architecture, default CMA region is commonly activated and it could be used if no specific memory region is defined. The USB driver in my platform also uses the default CMA region as DMA allocation. If using the CMA to do DMA allocation is improper, then do you think that the USB driver for my platform should be changed not to use CMA? According to my understanding, in CONFIG_DMA_CMA on both v4.14 and v5.0, __GFP_DIRECT_RECLAIM will try CMA allocation first instead of normal buddy allocation. Then it will get default CMA region through dev_get_cma_area API. Please refer to dev_get_cma_area code below though I am using v4.14 for my platform. git show v5.0:include/linux/dma-contiguous.h 61 #ifdef CONFIG_DMA_CMA 62 63 extern struct cma *dma_contiguous_default_area; 64 65 static inline struct cma *dev_get_cma_area(struct device *dev) 66 { 67 if (dev && dev->cma_area) 68 return dev->cma_area; 69 return dma_contiguous_default_area; 70 } Thank you 2019=EB=85=84 5=EC=9B=94 18=EC=9D=BC (=ED=86=A0) =EC=98=A4=EC=A0=84 1:34, M= atthew Wilcox =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Sat, May 18, 2019 at 01:02:28AM +0900, Jaewon Kim wrote: > > 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 ? > > No. __GFP_FS implies __GFP_IO; you can't set __GFP_FS and clear __GFP_IO= . > > It seems like the problem you have is using the CMA to do DMA allocation. > Why would you do such a thing? > > > 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. > >