From patchwork Fri Feb 10 04:56:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13135383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 003FCC05027 for ; Fri, 10 Feb 2023 04:57:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76A5A6B00F3; Thu, 9 Feb 2023 23:57:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71B006B00F5; Thu, 9 Feb 2023 23:57:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BBE76B00F6; Thu, 9 Feb 2023 23:57:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4972F6B00F3 for ; Thu, 9 Feb 2023 23:57:00 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 141EE12138D for ; Fri, 10 Feb 2023 04:57:00 +0000 (UTC) X-FDA: 80450172600.30.B8971D0 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf22.hostedemail.com (Postfix) with ESMTP id B5AE1C0007 for ; Fri, 10 Feb 2023 04:56:56 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="rf5/KHfi"; spf=pass (imf22.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676005017; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:references:dkim-signature; bh=Cn1KuYc/mahYf9SbC/oia3n2YKJAJcamRSiHkL5dW2o=; b=u6fwkkLPjXidr7BQYstR0+sOQw++e0tXTXUPNlbKI6aZZsfv5o9l8t2lCi6hOehyIhRgIb UgOLZnjZIXmh0i2parj8tazQyILUIF1hxwkqUciABH8e/tcq5u4+nKFi5VP0wBb3YaJnL6 8Z7ep2N2nev5Og7++I6rq1t4n6S+qzQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="rf5/KHfi"; spf=pass (imf22.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676005017; a=rsa-sha256; cv=none; b=csH+UImXleKcMHts6+3R4enlIu64s0PyinaaZXE4HXB6o7CHrCfIuw+HugykK6JRmHupXV JKwRR0ULD8K7eol3h0r7JekKql9EHYsdikTkNTtUL8BOn+pnwXFm4YSbI8bDyrNdlVdPrE cOgdcsmDTls2vyfSqKhdpEKsUUHChDk= Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230210045652epoutp04bfc14e34d3f01e45d97d96a7b34155cd~CXa3mFKWJ2857228572epoutp04S for ; Fri, 10 Feb 2023 04:56:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230210045652epoutp04bfc14e34d3f01e45d97d96a7b34155cd~CXa3mFKWJ2857228572epoutp04S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1676005012; bh=Cn1KuYc/mahYf9SbC/oia3n2YKJAJcamRSiHkL5dW2o=; h=From:To:Cc:Subject:Date:References:From; b=rf5/KHfiG7a3Facxj47GgvCyAjeBLzM8ZzRfwROq2nGX+jNBV7W8tHB1KZ5s+qoo5 5DH2UeBD38ATwvdQ7EhbD7AwyTuUlwNz/ks9LK5gC0KUgDi2G3vxK650zxQcx3ZLOd YXPaJd1rULeKjtA4YNACCpslPkhnWhWVQyY8ZxJw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20230210045651epcas1p2469593e100856b8a770911ba862b96e7~CXa21NQ2A1103911039epcas1p28; Fri, 10 Feb 2023 04:56:51 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.36.223]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4PChKb6Nkhz4x9Pr; Fri, 10 Feb 2023 04:56:51 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 36.19.52037.39EC5E36; Fri, 10 Feb 2023 13:56:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230210045651epcas1p1392354722c8ad6d4ffad6f934ba78742~CXa2FbIoo1938319383epcas1p1v; Fri, 10 Feb 2023 04:56:51 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230210045651epsmtrp29de923bce4b2a647162de8d9bf11ebfd~CXa2EgFaT3117131171epsmtrp2Q; Fri, 10 Feb 2023 04:56:51 +0000 (GMT) X-AuditID: b6c32a37-55fff7000001cb45-65-63e5ce93fbca Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 72.83.17995.39EC5E36; Fri, 10 Feb 2023 13:56:51 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.99]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230210045651epsmtip2437b3564d0f4a1195cc19c0e35980726~CXa17OKrr2907929079epsmtip2H; Fri, 10 Feb 2023 04:56:51 +0000 (GMT) From: Jaewon Kim To: john.stultz@linaro.org, tjmercier@google.com, sumit.semwal@linaro.org, daniel.vetter@ffwll.ch, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH v2] dma-buf: system_heap: avoid reclaim for order 4 Date: Fri, 10 Feb 2023 13:56:08 +0900 Message-Id: <20230210045608.23274-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmvu7kc0+TDQ40GVnMWb+GzWLhw7vM Fqs3+Vp0b57JaNH7/hWTxZnfuhaXd81hs7i35j+rxetvy5gtTt39zG7xbv0XNgduj8Nv3jN7 7P22gMVj56y77B4LNpV6bFrVyeax6dMkdo871/aweZyY8ZvFo2/LKkaPz5vkAriism0yUhNT UosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNTbZVcfAJ03TJzgA5WUihLzCkFCgUk Fhcr6dvZFOWXlqQqZOQXl9gqpRak5BSYFegVJ+YWl+al6+WlllgZGhgYmQIVJmRnPLh4gaXg vWjFnJaLzA2MDwW6GDk5JARMJHY/m8YGYgsJ7GCU+N4Y18XIBWR/YpSY8/EbK4TzmVGi+9Qk ZpiO3k3vmSESuxglDrfOg3K+M0pcnfGSHaSKTUBb4v2CSWDtIgLLGSU+Pl0I1s4sUCrx9s0J MFtYwFniy70vYMtZBFQlJjc/YwWxeQVsJY4c+MUCsU5eYvWGA2AbJAS+skvcXnOFFSLhIjF7 yT42CFtY4tXxLewQtpTE53d7oeLlEo2Xp0HdXSHRu+UQVK+xRG/PBaA4B9BBmhLrd+lDhBUl d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wCgvtVyvODG3uDQvXS85P3cTIzg0tbR2MO5Z9UHvECMTB+MhRgkOZiUR3u8THycL8aYk VlalFuXHF5XmpBYfYpTmYFES573QdTJeSCA9sSQ1OzW1ILUIJsvEwSnVwCRnUeBrFi0ktKrp b9rzuMtp5ae/e9qasNsn2V5ZMvNnUYTNomU1tS2rY3bMviXwfEXyNP9Gn6jyn5YbHi746zeB d+bvbR8fvvxR9Er4k9ZsIbbjVqmTC4/f+b7454TQ20YsXud4HPit4lcfDWCffPHc2+R9Ulde cJ7pm7byz54N+/75nuhjkfv82ipGdm/jbBnX8FDj6jPBlhpnGp39a0/5zA67NafobNVm1U33 etpSrol+3m1TsWMa200dluO3fx3gPK6VUMrVtjDn+y61xfkTDp5ma5MTZu978ZDDXEbaQJph j9Udo6NzBPRcVLSnqbwPvLe4aNVa++9KF57tjMx5+9nw0WzlnyVvRC5qPzZRYinOSDTUYi4q TgQAHrcN+7wCAAA= X-CMS-MailID: 20230210045651epcas1p1392354722c8ad6d4ffad6f934ba78742 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230210045651epcas1p1392354722c8ad6d4ffad6f934ba78742 References: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B5AE1C0007 X-Stat-Signature: j8cp9asqgszxmq56g97614jabzysjpu7 X-HE-Tag: 1676005016-290679 X-HE-Meta: U2FsdGVkX1/kbOThupO43jqvlz35fIb3l9EheZa3anMgMWCN3ZCMd85Q5c1zltnMsmEOvYHjtCMSSOFTUP9CeYjD1SpOKN2fJw3KQcTHUI7TjxTTb+DTaYVcIAm51ewvDdlOMuzBh98NIMzbBrtXljuy6UVXguhqqw5z/Uhh76eC4Qt+olHLbAzqypOLf99k0+qCPUxmWKMMHdso/3k0uNFF6ZlO0hQjcJsFt+D9evB6Rwuv6E7ngLqHPVFimY3WuOd/LOxzE7Hx/pL3XcGugz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ner-majordomo@kvack.org List-ID: Using order 4 pages would be helpful for IOMMUs mapping, but trying to get order 4 pages could spend quite much time in the page allocation. From the perspective of responsiveness, the deterministic memory allocation speed, I think, is quite important. The order 4 allocation with __GFP_RECLAIM may spend much time in reclaim and compation logic. __GFP_NORETRY also may affect. These cause unpredictable delay. To get reasonable allocation speed from dma-buf system heap, use HIGH_ORDER_GFP for order 4 to avoid reclaim. And let me remove meaningless __GFP_COMP for order 0. According to my tests, order 4 with MID_ORDER_GFP could get more number of order 4 pages but the elapsed times could be very slow. time order 8 order 4 order 0 584 usec 0 160 0 28,428 usec 0 160 0 100,701 usec 0 160 0 76,645 usec 0 160 0 25,522 usec 0 160 0 38,798 usec 0 160 0 89,012 usec 0 160 0 23,015 usec 0 160 0 73,360 usec 0 160 0 76,953 usec 0 160 0 31,492 usec 0 160 0 75,889 usec 0 160 0 84,551 usec 0 160 0 84,352 usec 0 160 0 57,103 usec 0 160 0 93,452 usec 0 160 0 If HIGH_ORDER_GFP is used for order 4, the number of order 4 could be decreased but the elapsed time results were quite stable and fast enough. time order 8 order 4 order 0 1,356 usec 0 155 80 1,901 usec 0 11 2384 1,912 usec 0 0 2560 1,911 usec 0 0 2560 1,884 usec 0 0 2560 1,577 usec 0 0 2560 1,366 usec 0 0 2560 1,711 usec 0 0 2560 1,635 usec 0 28 2112 544 usec 10 0 0 633 usec 2 128 0 848 usec 0 160 0 729 usec 0 160 0 1,000 usec 0 160 0 1,358 usec 0 160 0 2,638 usec 0 31 2064 Signed-off-by: Jaewon Kim Reviewed-by: John Stultz --- drivers/dma-buf/heaps/system_heap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index e8bd10e60998..920db302a273 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -41,12 +41,11 @@ struct dma_heap_attachment { bool mapped; }; -#define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO | __GFP_COMP) -#define MID_ORDER_GFP (LOW_ORDER_GFP | __GFP_NOWARN) +#define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO) #define HIGH_ORDER_GFP (((GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN \ | __GFP_NORETRY) & ~__GFP_RECLAIM) \ | __GFP_COMP) -static gfp_t order_flags[] = {HIGH_ORDER_GFP, MID_ORDER_GFP, LOW_ORDER_GFP}; +static gfp_t order_flags[] = {HIGH_ORDER_GFP, HIGH_ORDER_GFP, LOW_ORDER_GFP}; /* * The selection of the orders used for allocation (1MB, 64K, 4K) is designed * to match with the sizes often found in IOMMUs. Using order 4 pages instead