From mboxrd@z Thu Jan 1 00:00:00 1970 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 EAD0FC5AD49 for ; Mon, 26 May 2025 07:50:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66DC56B007B; Mon, 26 May 2025 03:50:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61EB56B0082; Mon, 26 May 2025 03:50:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50E5F6B0083; Mon, 26 May 2025 03:50:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3125F6B007B for ; Mon, 26 May 2025 03:50:42 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 76D8B160437 for ; Mon, 26 May 2025 07:50:41 +0000 (UTC) X-FDA: 83484287082.29.96E53EF Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 269F714000B for ; Mon, 26 May 2025 07:50:37 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="O/9W6Agr"; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf23.hostedemail.com: domain of hyesoo.yu@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=hyesoo.yu@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748245839; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aOx9bz+ZRQgr1HpJ633gt2GbjdyY7gJsdsqeauCk10w=; b=HYIsefjMGhMQzfZ12D+Fq5Iua55v++dcsoScl3oRqO8HAtxGC+ENg0Xuo4o97t/WECMzpH uFvcrNqN/R+M2yB5yD/y3dRqRdacUkNGQKaCtR8OCJQMuzJQFib7xkRcSZepwmYbVsbqo4 oJxWkGJcwBdOwMCe6tV8AAb/5lRdWjU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="O/9W6Agr"; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf23.hostedemail.com: domain of hyesoo.yu@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=hyesoo.yu@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748245839; a=rsa-sha256; cv=none; b=jy6PORzdus92VG+yBcGaM3Tg9/AuUvuZKZn7DGGFEHYM7NIkyJpDwnZjei590nKq66NbKB 5AKMw5XO9aS5vwMQbf41oS+h6dpYm3bMRnAP1bA3LBt2XkHoCNpbaqI93unSJt147Fr94u JG0wtAwgyNA4ePKsjSB91NN/GiwB3wU= Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20250526075034epoutp044a7ae938362644ef6dcf4d7b82006d28~DBFLaXi9q1295912959epoutp04M for ; Mon, 26 May 2025 07:50:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20250526075034epoutp044a7ae938362644ef6dcf4d7b82006d28~DBFLaXi9q1295912959epoutp04M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1748245834; bh=aOx9bz+ZRQgr1HpJ633gt2GbjdyY7gJsdsqeauCk10w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O/9W6Agrs1OpPAOmeEbd7baj4j/f1+EmjTU3D/i73JBs+OYtYxnXEN+gUnlK4P+Cg NawqZg6OmtwxDiJEegqpt0ucKdAq1sR7llP8YscjNWrZLzKXB5rTJPOblQ4ByXdTm0 GjgLJi1Vs71jrhblwxlxMKrhKdonf1uSv8mMBklE= Received: from epsnrtp03.localdomain (unknown [182.195.42.155]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPS id 20250526075033epcas2p2e56578f79fcabd44e9d52660719877ef~DBFKtWj_d2434924349epcas2p2c; Mon, 26 May 2025 07:50:33 +0000 (GMT) Received: from epcas2p1.samsung.com (unknown [182.195.36.69]) by epsnrtp03.localdomain (Postfix) with ESMTP id 4b5Sc86HR5z3hhTD; Mon, 26 May 2025 07:50:32 +0000 (GMT) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20250526075032epcas2p27ecbd2dba55038b233b0cd561350ec34~DBFJgmbmG1695816958epcas2p2H; Mon, 26 May 2025 07:50:32 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20250526075032epsmtrp15260c5cb626f32b019b8844efadcd8fd~DBFJfywuz0465404654epsmtrp1a; Mon, 26 May 2025 07:50:32 +0000 (GMT) X-AuditID: b6c32a52-40bff70000004c16-69-68341d489177 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 16.E0.19478.84D14386; Mon, 26 May 2025 16:50:32 +0900 (KST) Received: from tiffany (unknown [10.229.95.142]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250526075031epsmtip174c362e9bc374bef3ec4ae4321490a0d~DBFJTeSdc2030520305epsmtip1G; Mon, 26 May 2025 07:50:31 +0000 (GMT) Date: Mon, 26 May 2025 16:48:45 +0900 From: Hyesoo Yu To: John Hubbard Cc: jaewon31.kim@samsung.com, David Hildenbrand , "zhaoyang.huang@unisoc.com" , "surenb@google.com" , "Steve.Kang@unisoc.com" , "huangzhaoyang@gmail.com" , Jaewon Kim , "linux-mm@kvack.org" , janghyuck.kim@samsung.com Subject: Re: reply: [RFC] pin_user_pages_fast failure count increased Message-ID: <20250526074845.GA2848800@tiffany> MIME-Version: 1.0 In-Reply-To: <4e2305d6-b067-4963-b16a-367a254d22c1@nvidia.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRmVeSWpSXmKPExsWy7bCSnK6HrEmGwdRdrBZf1/9itph99heL RffmmYwWve9fMVlsnlNssfHpInaLe2v+s1os2NPPbDH50gI2i0ktPcwOXB47Z91l91iwqdRj 06dJ7B69ze/YPN7vu8rm0bdlFaPH4faz7AHsUVw2Kak5mWWpRfp2CVwZs+4fZyw4LFTxaFd1 A2M/XxcjJ4eEgInEndffmUBsIYHtjBIXf/FDxCUlZn0+yQRhC0vcbznC2sXIBVTzmFHi6dk9 bCAJFgFViX1N79hBbDYBdYkTW5YxgtgiAmoSb968ZAdpYBZoZpaYf2szM0hCWMBVYukRkCIO Dl4BPYlNB2QgFn9gkeg6oQ1i8woISpyc+YQFxGYGmvln3iVmkHJmAWmJ5f84IMLyEs1bZ4NN 5BSwk7i2+wbzBEbBWUi6ZyHpnoXQPQtJ9wJGllWMoqkFxbnpuckFhnrFibnFpXnpesn5uZsY wfGjFbSDcdn6v3qHGJk4GA8xSnAwK4nwyswxyBDiTUmsrEotyo8vKs1JLT7EKM3BoiTOq5zT mSIkkJ5YkpqdmlqQWgSTZeLglGpg2npZqe8Ng3HpoZ6ydVkHEg2u7DRpPmwdG6vuL/XV2ikw cLFAtIrqz0kf99qyKkqXp/a6/VI6JxozW1/f4PyyrAAb/3tpivaXTu94bunmx6eVfqi/+rb6 8RnLlPmPONgtOXzlhffl/SeN7rv+Sus7kxFbtH33JKYfxzpO9Ycv/SSpfYDR2H7ije0V9kHl B12sJgX9qWxr1Deu6pJ7eeLfhJ1nkriKc65FJmUzny72v1Qh5vTu+SOeHeu7XAqOPz68pGHF K/vdJy4vsgm15J8/JfC7tVrVzQN3SzZ3fPj9IjTLr/v6oc1/f7OY7L7XEPCk2Wm63vEWzQ5D obNFBzZ/SNM5fltojmv+4h1Sc36sVmIpzkg01GIuKk4EAGcF6QgOAwAA X-CMS-MailID: 20250526075032epcas2p27ecbd2dba55038b233b0cd561350ec34 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----oRxFN-IW6TEbmBusn.EXIiq7I5yRwYOXOizBgewo77BvK4Z6=_ba424_" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P cpgsPolicy: CPGSC10-234,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250522130101epcas1p435244c12cfc9bb7895008b8ea98af064 References: <1dd70770-f097-46bc-99b1-1bd3249032fb@redhat.com> <99ae448a-5c5e-4491-8cf7-1325f47e225e@redhat.com> <20250522130901epcms1p31d757b179fbb3563cad6bef4a1829235@epcms1p3> <20250522144418epcms1p2a31c1a5c95b1937077bddf1b30495e83@epcms1p2> <20250523023709epcms1p236d4f55b79adb9366ec1cf6d5792b06b@epcms1p2> <4e2305d6-b067-4963-b16a-367a254d22c1@nvidia.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 269F714000B X-Stat-Signature: yekzf6ptho3ndb4swsccpf4gmr5ngaim X-Rspam-User: X-HE-Tag: 1748245837-59091 X-HE-Meta: U2FsdGVkX1/+V+BffXCBqCyuCHrV48ncJJJJixCwcucya4NYwNUHUtWNd8wm795VQIYfP0pVlsrkusYXUBiengsOsud41eYRXQFenL2Ohk+4MDhmTrrP58zBlC8/LYjsUJ7QLAqn/jzEoJBWiQQTsXi+FCx5C6T2YTT6b6FWcGZt8aKGjOZCi0oI/jngA3H5ghd7JPLZAH5DI937hZXnznlrfOcZoloDbv5HAua8e6r7TjH+XE4TSW/7uQMEPe0OMVC1CCUOCqg3ZhEG067WEFINcq8M9n04RUVqjXO/G9HQ2/hHMC4BSm5tpK9dvIeaUxaVflJm4/gRF5Gvyxwt6rglNY4iUL7eutVOL2YzQfn1lArxXDRN0EGwDHnbNsQzslWdRdK29uVqdvk5zJ0W5B2MWmrNe7jRwXf2ajZOszaPKHQ6acFnZ7TiFm/HXJdeDomB5pP4UAizkQhwR0e6g5+xE+oOzKTAkiQ6wyuhxSif4HY6zEjq5dxJr2hn57C+rVq6jJX8cuDyZ7CI+IEKz5HpmXlyMIqwgnrZ439t0vzKXABVTiXPnstxUKBKWCcFoVITJGYqx6AjQ7iGwu2yhAzj8ggqJvU4qc1kabxVC33KMVlIrCXyRQMXwzSamP7IeODLdV0At6mB/VXmGENZVOLcRtxIrCyjcg4jq4Sddj3LHrv05/9oIbmUAsnrdjbYvlwysc86ZkIqXbw5jFJHbighNnSKXwbsGeqqA8PFoBwFbW4hGaZB88voxnUOpiO/nInfpalWybCheCDTxJMQ55hlA3/ubMKRCtZSVxrUFpbQz6Mue4e87ajc8PxDWaVbxCwTVEY+ulDz+Vabdc6CONjNK7B+gW8eS2PIHMsSe3WlIxdQLE9nwusq33SLV7AkKQlljMF7P/inxAXRq+sbsDSr3Kt64i3gTDdN/XhIzTDD/iykoMoOEyBNexItXJFB6gTafysdPi5nxY3uF7V pveTHVsc 8rCv3gEVap4FUT4uipBUlwgOFaMnos7DL9GBpOUJrEbeBZ9RQ8KKDG200LeMV/vtzSY36kw7D56n5R537lFGiwEFiWmhcuIJAlifG9JEKvuyGla/C8P2W7sOyC+oBWVVVNeYdW8TEs6/f760H3yfRLG781V92hT3jg56Vric+d8XHtiLw5NZhPZ3U/n9DymaSbjz8QmgNWVX9dgHG+KEBx6wVeD+JzBkB97y9oxKYvybLARPFe5U13w1qWZL1Br7V9Nc6mCbAEhaKnt0Rjmq0IAOByhUl69HFuJusxKDKR68xI5SgPk2qa3Awt0QEKNK/AK3toRn7ziNtsUzBIYks6IPEIj09R51vZbpM 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: List-Subscribe: List-Unsubscribe: ------oRxFN-IW6TEbmBusn.EXIiq7I5yRwYOXOizBgewo77BvK4Z6=_ba424_ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline On Thu, May 22, 2025 at 07:52:41PM -0700, John Hubbard wrote: > On 5/22/25 7:37 PM, 김재원 wrote: > ... > > I think this is what you meant, please let me know if you have an idea to make this nicer. > > We may be to able to prepare the patch next week. > > > > static long > > check_and_migrate_movable_pages_or_folios(struct pages_or_folios *pofs) > > { > > + bool any_unpinnable; > > LIST_HEAD(movable_folio_list); > > > > - collect_longterm_unpinnable_folios(&movable_folio_list, pofs); > > - if (list_empty(&movable_folio_list)) > > - return 0; > > + any_unpinnable = collect_longterm_unpinnable_folios(&movable_folio_list, pofs); > > + if (list_empty(&movable_folio_list)) { > > + if (any_unpinnable) > > + pofs_unpin(pofs); > > I think this is correct, although as I mentioned in the other thread, > that implies that commit 1aaf8c122918 (which didn't add nor remove > any pof unpinning) is probably not the true or only culprit, right? > > > + return any_unpinnable ? -EAGAIN : 0; > > Ha, the "?" operator almost always does more harm than good. > > Here, for example, it has obscured from you the fact that any_unpinnable > is being checked twice, when you could have merged those into a single "if". > Hello, I was wondering if the original problem - an infinite loop when pages allocated by cma_alloc() in vm_ops->fault are passed to GUP - still remains unresolved. (To be honest, I'm not quite sure how such pages end up being pinned via GUP. Is that the expected behavior, or could it possibly indicate a bug ?) Would it be make sense to try calling __lru_add_drain_all(false) in collect_longterm_unpinnable_folios ? We could consider limiting the number of -EAGAIN retries to a fixed count (e.g., 5 attempts) to avoid an infinite loop. Or perhaps in check_and_migrate_movable_pages_or_folio(), if the list is empty but any_unpinnable is true, we should consider returning an error instead of EAGAIN to explicitly prevent longterm pinning of CMA allocated memory. I'd be interested to hear what others think. Thanks, Hyesoo Yu. > > + } > > > > return migrate_longterm_unpinnable_folios(&movable_folio_list, pofs); > > } > thanks, > -- > John Hubbard > > ------oRxFN-IW6TEbmBusn.EXIiq7I5yRwYOXOizBgewo77BvK4Z6=_ba424_ Content-Type: text/plain; charset="utf-8" ------oRxFN-IW6TEbmBusn.EXIiq7I5yRwYOXOizBgewo77BvK4Z6=_ba424_--