From patchwork Mon Jan 20 09:26:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13944912 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 657D1C02188 for ; Mon, 20 Jan 2025 09:26:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F10AA6B0085; Mon, 20 Jan 2025 04:26:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC1666B0088; Mon, 20 Jan 2025 04:26:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAF71280001; Mon, 20 Jan 2025 04:26:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BD9FC6B0085 for ; Mon, 20 Jan 2025 04:26:44 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 615881229BE for ; Mon, 20 Jan 2025 09:26:44 +0000 (UTC) X-FDA: 83027300328.14.BD0D5CD Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by imf18.hostedemail.com (Postfix) with ESMTP id 844071C0009 for ; Mon, 20 Jan 2025 09:26:41 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737365202; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=s+Et8Ukq9v95jG7plOdwAJfXcR2ngJ36aczGjQLoMQg=; b=WzRMcv+ZJ2MeBNx3RbqaBv4Nklep1Tzu8YL5YvBbn3nG4YOuVI+Npj6Q3bgw4LmSTt8Z4s zd5LoY9AHUIkmsCvPRplODtbiiLAggM/eG2gLAhRG3Xwi2eKGT8Im92ymKPWYuZ1oNzq1n Tk3gEWUeZE7lPjhdvhLSM0H4pSKoPBY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737365202; a=rsa-sha256; cv=none; b=zwK5bNwqwQwJsuuW0IPIV41VSyUfNGytVwEgZqPEfL7WM3y5JYJ7QAiOHj4UZkbe+Oj+lm kDKrrbpPdxFX/QDfD4SAT1/5XaJf/plEzMiyk0Lmnwg/3qHtuZAnOj7e693W8E+5Z3Iq6G R0V9gA24w5LhdxgeqsAzfjZbf2HBDIQ= Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 50K9QEOm065386; Mon, 20 Jan 2025 17:26:14 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Yc4cr1Sfkz2Mx5j2; Mon, 20 Jan 2025 17:22:52 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 20 Jan 2025 17:26:11 +0800 From: "zhaoyang.huang" To: Andrew Morton , Alistair Popple , John Hubbard , , , Zhaoyang Huang , Subject: [PATCH] mm: gup: fix infinite loop within __get_longterm_locked Date: Mon, 20 Jan 2025 17:26:04 +0800 Message-ID: <20250120092604.3590285-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 50K9QEOm065386 X-Rspamd-Queue-Id: 844071C0009 X-Stat-Signature: m3ub1341y5xd8agssfz3odnfuq4dr1d1 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737365201-477540 X-HE-Meta: U2FsdGVkX19d+ERSgpah43f0ayiDVx1FDikTn68l2AID3DoENPA0mP/JIZEVBpftlfuqmND52sToaN83rdhbnUtaONMsB9b3D2ecoJAov3jQ0vmli+tNwots2nR0gJklpF8waQiHJkquKWRUQe8DB/3COkOAK83DPes/eyQzg+W6DFCckQ5/tV/Q2YsKIJ9HSkaaxadLvyAGGvPDAr50piANotZkumBbKaVoNf+PwjGpsKFB5CwxKkJTPg6jAG3BSVMntKDBtKX7fVhZhdDyspbIhHeeCQq5EKwqi9lfRgffkRlJOJKW4QSKv2y4VNjLMrKQLbTe6PFlJZrW95udOHZ3DiUCVg05pXZzsnpJ8u8i4ps/8GSSVFki0hAsRYN1iWwuP+l8TT6eWECuQJ56IpeOMQ3WrtosCfylrCYjZ3xA4DyDDfHIaZhwtnkK7Ecw8QYBJ60Nh65prKUkusUGUCWld2GWiWpylwdj1+DoriPoH4GB22c113Jt3wpC9bja4S8F3kzxGipy0gbdY/lZVscOWy/HInqHrT95dfdtwLWSAcUiSr0FwUGBEmLJazjsScckcBX8Z/uMnBuB41Ja/nt+OWLpHRa4W9+1mwRBDN/bV4LerLb2QX/gH3kE90Ra431Ztgx00SOtD3VkELf9YYOHImbYLjX1j2MjZj3WXDNjgMh8HHzTNsLMecBmk8srEFYX4uL/I82GAIkT7rt1e5CObBCHoAbXB+pbnFnI5cB1qmZhfLmS/l2RpqtuW8MrLNVJ6ngXu59/xUOLL+QCqv43xMpOKlfASIePX5oL5tx6h1I5IxchSSscLBXZH1TyIunluUC25ur0vMKLYEgakn4V8F5sGpPQLQYuahTZeTwptwdF91VNEcqcrPQS7reYrrNnawVd017QFNiln6IKUnNJocNTLnfA5+0ALQB9iiK0dPqML99cSK2oRajKqwJhMoCYTRdZGL7NfVXN/PB KUaT27dx TYoy0XvmKJapvr0SgnbhQQWmzZWB7RA9kFS2lUTSrz9Ibgsrb8QpHkHgVYG5nw+N4TF8pXPsGa356HHFzI6ihYtFd9Mp1jgljT/qk2BorQjo++b74pKoA9OBTOmjmuieLQ+k5sGLiwuDSNrk1p4KWwd3gkcCBMI13/l+VYkPAt+G+Zptm5Bsjzt2ZY8XNKQagzAK4/jNSYIrtPwiLz+SAV5KtsGwVoEglgVEh/ThnrhqNOh2IQqGqI+kBPQ== 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: From: Zhaoyang Huang Infinite loop within __get_longterm_locked detected in an unique usage of pin_user_pages where the VA's pages are all unpinnable(vm_ops->fault function allocate pages via cma_alloc for hardware purpose and leave them out of LRU). Fixing this by have 'collected' reflect the actual number of pages in movable_folio_list. Signed-off-by: Zhaoyang Huang --- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 3b75e631f369..2231ce7221f9 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2341,8 +2341,6 @@ static unsigned long collect_longterm_unpinnable_folios( if (folio_is_longterm_pinnable(folio)) continue; - collected++; - if (folio_is_device_coherent(folio)) continue; @@ -2359,6 +2357,8 @@ static unsigned long collect_longterm_unpinnable_folios( if (!folio_isolate_lru(folio)) continue; + collected++; + list_add_tail(&folio->lru, movable_folio_list); node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio),