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 6DA01C5AE59 for ; Thu, 5 Jun 2025 05:13:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC9B86B05A0; Thu, 5 Jun 2025 01:13:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A79036B05AC; Thu, 5 Jun 2025 01:13:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9687E6B05AD; Thu, 5 Jun 2025 01:13:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 77E4A6B05A0 for ; Thu, 5 Jun 2025 01:13:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E7FB9EFE10 for ; Thu, 5 Jun 2025 05:13:29 +0000 (UTC) X-FDA: 83520178938.02.B9B653E Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by imf25.hostedemail.com (Postfix) with ESMTP id 97083A000A for ; Thu, 5 Jun 2025 05:13:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=O50PM8nT; spf=pass (imf25.hostedemail.com: domain of hyesoo.yu@samsung.com designates 203.254.224.33 as permitted sender) smtp.mailfrom=hyesoo.yu@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=1749100407; 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=TWZJnqmiFPsSy1+ILLqtvM1BwPxqpl14A88a5Y7yhVg=; b=8r49lfMqHPt6rbrDLGBOo176PRyju94WrEjhXyvChFxhqvvJRqzpZ1d5nPyOlPWkpSqo0c zejcKuhMT4Pcr7SY0eVC3vDgXVnq7tYmSgIl6F9Kc4O+HIF7KeY8V4gYNYTVrayZ9BxU+b mkSKRnx+mwcFn8tgkXMDmPIgXlDdAfg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=O50PM8nT; spf=pass (imf25.hostedemail.com: domain of hyesoo.yu@samsung.com designates 203.254.224.33 as permitted sender) smtp.mailfrom=hyesoo.yu@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749100407; a=rsa-sha256; cv=none; b=wFMajKVjCVT6McRWwnuvaksM87uOOfXjD5h4Tv8MHmfifjUO6/+3xCrs1BU9L5/Q+lvfHm rC8ZmU4I4IA3/NRecr+WJGzzt/9fn3fUrED07uIYD4EAKHcD0vbomFLOe3gHM9OoeeUEYH uUGTi73iMEqfTQT4VfmUCCBRRJuMByM= Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20250605051322epoutp031283adcbfb63d020438e20db83a22119~GDYx-FSCk1781017810epoutp03i for ; Thu, 5 Jun 2025 05:13:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20250605051322epoutp031283adcbfb63d020438e20db83a22119~GDYx-FSCk1781017810epoutp03i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1749100402; bh=TWZJnqmiFPsSy1+ILLqtvM1BwPxqpl14A88a5Y7yhVg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O50PM8nTZjeAH6peznjsVNd6ROJAp6sMkDLlxgluh1/bV+AZuGG13WvvLXqX+q4Eq R+5KEY0Fwt6gST2XIhanC4g0pZIV6FcfCNUQnjJfRLXT4HdPf/jyyLXU4u1RtZarV6 t1iUo0u+CinRkl2OzZLqFCL24N1yV2abe0xQq4UA= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPS id 20250605051321epcas2p41d48d5da8ce26a73ad4b5de424a807f6~GDYxoACPw3115231152epcas2p4R; Thu, 5 Jun 2025 05:13:21 +0000 (GMT) Received: from epcas2p4.samsung.com (unknown [182.195.36.89]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4bCXf930Kmz6B9m5; Thu, 5 Jun 2025 05:13:21 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20250605051320epcas2p31ea8aec2cbc88346cd08b2200a96e53f~GDYwk3cVo1550815508epcas2p3O; Thu, 5 Jun 2025 05:13:20 +0000 (GMT) Received: from tiffany (unknown [10.229.95.142]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250605051320epsmtip116d0132b5d4ad98ba02e5f10b4ee2d5f~GDYwhojvp2376823768epsmtip1Z; Thu, 5 Jun 2025 05:13:20 +0000 (GMT) Date: Thu, 5 Jun 2025 14:11:31 +0900 From: Hyesoo Yu To: Andrew Morton Cc: janghyuck.kim@samsung.com, zhaoyang.huang@unisoc.com, jaewon31.kim@gmail.com, david@redhat.com, Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] mm: gup: avoid CMA page pinning by retrying migration if no migratable page Message-ID: <20250605051131.GA3407065@tiffany> MIME-Version: 1.0 In-Reply-To: <20250604204323.95a646ae67f6800069a11e36@linux-foundation.org> X-CMS-MailID: 20250605051320epcas2p31ea8aec2cbc88346cd08b2200a96e53f X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----bfByJ-ZIY6BJv7sVO1BMUP1RgQAR8Q.m4BWNyUsw_2ev9GnZ=_322ae_" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P cpgsPolicy: CPGSC10-234,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20250605033432epcas2p4c024a9d05246b18c217f3562b3f53551 References: <20250605033210.3184521-1-hyesoo.yu@samsung.com> <20250605033210.3184521-3-hyesoo.yu@samsung.com> <20250604204323.95a646ae67f6800069a11e36@linux-foundation.org> X-Rspam-User: X-Rspamd-Queue-Id: 97083A000A X-Rspamd-Server: rspam09 X-Stat-Signature: 7c3f8hhdb88daut7iczrcc3cgwiahfc5 X-HE-Tag: 1749100406-71842 X-HE-Meta: U2FsdGVkX1+jnBIPz9Pb6HcSNX0dt7eamHRt9W4Ccw7e671Hx2NgM8hhbOrV4P07CwtWqMrEW3uWx0SXH3pyMV+7rS3pin2E8/LPpubaVf+juyIHrbm2YoDoRw3EHVX26CXeqb6ISRnk2Q3mCOvi+78IRe0uTBWotgb4LI7cjlHteZbye8WpS8LFOGNtQDIbaMfH9+0cPom56/2dauUj3W5N8X1ounFhd3OEZIxCEuPAiz3S8EoMQTq8QD2KuKQkyq4Cc8Zjy2TaaudwqL7xk22Ujb8MwhGrU68h8eIRNhJvXKRS1hI+u/CN4UBE9mR/1BBh1isZDz5oa6z+q0AhE8vnfsK86oWKryLckp0saHYoJzfep+F9c/jr1iepB8qkSfDRHB5A2GP2y5Nu9m1Mc3lvUOSjyuZ3wx0yO2xFBXYssngtEDAnsuqyy4J75bqtrH432P3S1/aCmanemgnezPYyXgR1YlxB0WsVsDkzJ4HH7OxNXVOgLKZuc1Rs84QeyBy2cdwU4GIJqcGpCCOPVL6bjnSayQmMzWLwkBgHUSo1sRZeKZjxXMoNMDgkI7FRdh/nF/vyB38rdWUAYDxRWEwdUCP3JxK+4dFwpY+QkFfZysWNGeh9SFW9ZUAek3FwWP5m+Qykfy28fATxOrws8ToVNwCAy9Oc4eSvW3wBP4+a279X4NFbGGytgTISZNX4iO55eF1Cw/UUoBpiaQrmZhH0Awdn+LW1u0yrXnbGohIo4deVnRcKZzxbl1AlHh9dRDpZ9XyymSbosOR5tW8KK8Bpw+PQhFKLgYzj3e6SMeF8FtE969tLnZo+ZNFxuMLslXkTeBa3N2vzrl8aePD+E87Kl+uaFVIVFW0qXBd4aeqnXraD/XNAoafLwVKuuKiQMueMEbRAh/B0aQ5aCLziPYvrmh483lGPwBS+mpxXbsFa+8Uqb0AKFsrrWdNW5x92hx3470PWht1pgNXNUdY fHBf1rht YyDC3l51D0ehN5o2L4n4AQvlnrBXH56RarWY8+ckglGE2ZItUqLWYLxHamtHK+tLzMuEtQFzihJ+Bkysi7J0mGkm+Y1yRFyUM8pbs4lIhX/ci6S84xKh/t2v27zsAjxBgrhNW7atZ6klxOvTqc+BaNAhYGMXwQWjDXsFTeT8Dr1My9UEirze0btJfAglZXwJXqlTjWgNJ64osMkiUjlLUGaBU5XL/d67miZFLdM6N9jbybz7MtDRftNVK86+iWW5iQPbjDKBzASYiaaY= 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: ------bfByJ-ZIY6BJv7sVO1BMUP1RgQAR8Q.m4BWNyUsw_2ev9GnZ=_322ae_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Wed, Jun 04, 2025 at 08:43:23PM -0700, Andrew Morton wrote: > On Thu, 5 Jun 2025 12:32:07 +0900 Hyesoo Yu wrote: > > > Commit 1aaf8c122918 ("mm: gup: fix infinite loop within __get_longterm_locked") > > introduced an issue where CMA pages could be pinned by longterm GUP requests. > > This occurs when unpinnable pages are detected but the movable_page_list is empty; > > the commit would return success without retrying, allowing unpinnable > > pages (such as CMA) to become pinned. > > > > CMA pages may be temporarily off the LRU due to concurrent isolation, > > for example when multiple longterm GUP requests are racing and therefore > > not appear in movable_page_list. Before commit 1aaf8c, the kernel would > > retry migration in such cases, which helped avoid accidental CMA pinning. > > > > The original intent of the commit was to support longterm GUP on non-LRU > > CMA pages in out-of-tree use cases such as pKVM. However, allowing this > > can lead to broader CMA pinning issues. > > > > To avoid this, the logic is restored to return -EAGAIN instead of success > > when no folios could be collected but unpinnable pages were found. > > This ensures that migration is retried until success, and avoids > > inadvertently pinning unpinnable pages. > > > > Fixes: 1aaf8c122918 ("mm: gup: fix infinite loop within __get_longterm_locked") > > v6.14. > > As ever, a question is "should we backport this fix". To answer that > we should understand the effect the regression has upon our users. > Readers can guess, but it's better if you tell us this, please? > Hi Andrew. We have confirmed that this regression causes CMA pages to be pinned in our kernel 6.12-based environment. In addition to CMA allocation failures, we also observed GUP longterm failures in cases where the same VMA was accessed repeatedly. Specifically, the first GUP longterm call would pin a CMA page, and a second call on the same region would fail the migration due to the cma page already being pinned. After reverting commit 1aaf8c122918, the issue no longer reproduced. Therefore, this fix is important to ensure reliable behavior of GUP longterm and CMA-backed memory, and should be backported to stable. Thanks, Regards. > > ------bfByJ-ZIY6BJv7sVO1BMUP1RgQAR8Q.m4BWNyUsw_2ev9GnZ=_322ae_ Content-Type: text/plain; charset="utf-8" ------bfByJ-ZIY6BJv7sVO1BMUP1RgQAR8Q.m4BWNyUsw_2ev9GnZ=_322ae_--