From patchwork Fri Mar 3 05:03:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13158340 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 F3278C64EC4 for ; Fri, 3 Mar 2023 05:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C5B96B0074; Fri, 3 Mar 2023 00:03:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 573876B0075; Fri, 3 Mar 2023 00:03:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413FA6B0078; Fri, 3 Mar 2023 00:03:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2F9306B0074 for ; Fri, 3 Mar 2023 00:03:58 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EA2BD1C5E17 for ; Fri, 3 Mar 2023 05:03:57 +0000 (UTC) X-FDA: 80526394914.10.0435CF5 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 0656114000E for ; Fri, 3 Mar 2023 05:03:54 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=WEZEAoTm; spf=pass (imf23.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=1677819835; 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=PG+FVUDX3161x8uXoq6zC61Na4POwRccQbBdfYze8IM=; b=KCm9TYNHiRtZDfSrOPirYBaK5zSyAcTeDq1iaBhF10tLlLM4N3gNY6QC1C0K8WDmzn++C0 eW79YQRI8Is9jbxOm5XJlpW6oSA+wSqzUcUlf8KeHCZzFu8mLJHglneSiciwlv9kUIeyUh 3rLxS41z6ETB+dqwwqfDfod/hzcGbbQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=WEZEAoTm; spf=pass (imf23.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=1677819835; a=rsa-sha256; cv=none; b=l/1ZsQ14j7YI49WWTe9lyrqEqDj2BTvgrY37fNxVjJKWeRyAkjG5yx2EownXYaWJaFaSzO 7Ojd9cPm5q3HOZHzPFgyDlDJXd6+1svAPDWiZjLolwrFS2dsGTpdLIrnUu9hz35vssNMXB +pvcLnYulGgkMQfd1iQc7f0hrHBytd8= Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230303050351epoutp0454612d3f1ec322086a98788d4b46453d~I0D9VF6mI1585915859epoutp04s for ; Fri, 3 Mar 2023 05:03:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230303050351epoutp0454612d3f1ec322086a98788d4b46453d~I0D9VF6mI1585915859epoutp04s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1677819831; bh=PG+FVUDX3161x8uXoq6zC61Na4POwRccQbBdfYze8IM=; h=From:To:Cc:Subject:Date:References:From; b=WEZEAoTm2YwuoWPmOwWcYSnSotIFsDXANVkMsgmpVltAq9NVYOYZadQ7DPRfsGhWf 6I0GySlJWeExePbW5VBI7EV3LU2A12zQx4k8ztgarLeoKjD++SU4U/IJNEt26iRCWq 5IiueTwNpIr2xxMxk87WnDts3Te7IkFk91Hwwv/E= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20230303050350epcas1p4e61f63bd8fed30c9633213e6fe2f96da~I0D8rImcR0225602256epcas1p4W; Fri, 3 Mar 2023 05:03:50 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.38.248]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4PSbTy5ypjz4x9Q8; Fri, 3 Mar 2023 05:03:50 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id EE.36.37890.6BF71046; Fri, 3 Mar 2023 14:03:50 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230303050350epcas1p1e2dc42f8ac677af9653ca7017a4b9225~I0D8ObJXi1154711547epcas1p1F; Fri, 3 Mar 2023 05:03:50 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230303050350epsmtrp1c713e37505a476b04be01b189392fb09~I0D8NDmOI2620326203epsmtrp1E; Fri, 3 Mar 2023 05:03:50 +0000 (GMT) X-AuditID: b6c32a38-5fbfa70000029402-fd-64017fb650d0 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id CF.9B.31821.6BF71046; Fri, 3 Mar 2023 14:03:50 +0900 (KST) Received: from jaewon-linux.10.32.193.11 (unknown [10.253.104.99]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230303050350epsmtip13199ed373bbb6e825f2ae13cf16dc2c5~I0D8DOVXU3190631906epsmtip1c; Fri, 3 Mar 2023 05:03:50 +0000 (GMT) From: Jaewon Kim To: jstultz@google.com, 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: [RESEND PATCH v2] dma-buf: system_heap: avoid reclaim for order 4 Date: Fri, 3 Mar 2023 14:03:32 +0900 Message-Id: <20230303050332.10138-1-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7bCmge62esYUg43H9CzmrF/DZrHw4V1m i9WbfC26N89ktOh9/4rJ4s+JjWwWl3fNYbO4t+Y/q8Xrb8uYLU7d/cxu8W79FzYHbo/Db94z e+z9toDFY+esu+weCzaVemxa1cnmsenTJHaPO9f2sHmcmPGbxaNvyypGj8+b5AK4orJtMlIT U1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4AuVlIoS8wpBQoF JBYXK+nb2RTll5akKmTkF5fYKqUWpOQUmBXoFSfmFpfmpevlpZZYGRoYGJkCFSZkZ0x495yx YJ5YxdePT9gaGLsFuxg5OSQETCQmn9/G2sXIxSEksINR4vWj1ywQzidGie5Hq9ggnM+MEn+O f2SHaWm9P5cJIrGLUeLOpcdQ/d+BWjbcZQGpYhPQlni/YBJYQkRgMaPEmxtfmEESzAKlEm/f nACzhQW8JHp2toLZLAKqEj9vXgNbwStgK7Hz7V5miHXyEqs3HGAGGSQh8JVd4tPu9ywQCReJ 4w/nQd0kLPHq+BYoW0riZX8blF0u0Xh5GtSgConeLYdYIWxjid6eC0BxDqCDNCXW79KHCCtK 7Pw9lxHiTj6Jd197WEFKJA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Y9qz7oHWJk4mA8xCjBwawkwlvdwJAixJuS WFmVWpQfX1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dUA5N/JDfPYo+Z+tav nx5scp7I9HOvUozQ8Qtihb/3ndnf1HclrGLZykPa5cntp9P3qPsrpOYeKr5VkHbgx79M36vP XoSWvoy8Jf7imEjZc3u1s3+Opsjti5jeM6vi379H0ybJz1r5dLvTLf2fMv8Uj6e0M2b/U7L6 GnT12AwPRp9g9275XTd78jbtn3vSMDXObl2YSuUE9wmhRhtq2l/nrzls/2h1/eK/qcI7X59x u9f08nSIiPKZOdwWF3+8X7Hi5tQszrlMVSbL2JV9mbO+TJDyN1QSrFK7/vqNkfNyXV7JdVuX M75VrX1ycduLzsspd35y/ZHeIXRis+yxo3Z53Mn68xW//j3yY3nutp9JWUHxSizFGYmGWsxF xYkAiorPoL0CAAA= X-CMS-MailID: 20230303050350epcas1p1e2dc42f8ac677af9653ca7017a4b9225 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230303050350epcas1p1e2dc42f8ac677af9653ca7017a4b9225 References: X-Rspamd-Queue-Id: 0656114000E X-Stat-Signature: b3ayypfpgwa8bc73xq8bozgyj1bi4s75 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677819834-493775 X-HE-Meta: U2FsdGVkX1+A9aISpHIGBHX6wEmQpByocali+NAX0XqRJLpgEE64+NDXDPNcZ8+7Oj5lSwwlJcu8pk06KRB9p7plTuhFVEKJLNT3wM0gGVyyulqTsqs+LoHt877hGvs+AJXcNOgZsjXMq6rP+5QvcX9VLOPe7N9yJWzDBITGnV/ZGAs5ecmktkZ8n9SVXeobRA0oXSq65lrkVf01sBvIun3kASRWzOJKXTkonV2615bO5uSA1APD8PK8QcGY1AhUy3pKKMM8yZasoWRx//YIGj2T8huaGXGamb06h47vAESg7+hlMveTjqPJ2JKNKec0WxQoE2H+Agxt+FMqijV8imUgj5ZJbLh/QZfFa9ijRQqB6OM7UPbB/GM7fdDxtt0ywzuNyRVx8iGrd12p+GJpRwTn7at3ifYA4ot4Wo4S2KfmjHqCBuzQIHAKrVRcxblH6TmTVAsOTJJP2mYraw2k/DaZkxnt/AOzftRuUUF98/5uaA58qTXKH4kmLBSJgY45pNmYneaJQhHlSyr3zP0srOry4nk71XN/ey4bx76MZs58dEzkXdoqaL6cYRxaTlEEGsJV/Irh017oJ8neHiWknf2rEkQnBX0RP2vbOckJ/D8vwXXNZqk+uFbeG0gD28o9/TTzjZ9okmgPjT+QEA0fWx+fcYasY8PEpTtGqVBgG1habSwF+MCCYNuXfEKboVSlDf8yykRt0Q430rZQa9G+3E9DOwf2Y16ouHP1cVn5UN4rmFc6LK4iY5E57ilw0Xt5/0X1qoPLPr0J5/PYnG/gsEF1uSF4YowsetbKURh4r47/IH6y0WEMA7pX6WxJZFmTZ4eY//bsllakeql+JaXxw5+NkigejDPeyvsokxy8awa+iFyVhZ808P/UiC1moOGyYg5fwRDOR9MwVTby4Lti/T5NKxTqoTsoi4zC1gjl2/o8pZ82jVCVYNSQfc6zWVL+lYOD+M/JNbSesVjf76C RDNMEwXc ajCyJGXzYOYid+hUE1CZ3+vRu7AFT8m54sPwzT75gIZnh14zkO6AaqpNi/9rJY0k6VZL14afur7zpzRXfWnwvYgYfKEbcKMDjmfvzBza6m0VqJcpoKWSF589ESbPiuqSFVlz5y5PtLYnU2VRaZGm1ILjnjExY2si85hCJylZ7kva8x64g5Vx3gwf3u46nDFqDj9snqIqOBqOzwAAPln3zaQbJYpFZj4RMicDjbe9NGlegGBEoXASPfYGiAtNxbtoeo/Opgpuzi82EdsNO1d4higSTDA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-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