From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A6BD606A322 for ; Fri, 4 Dec 2026 15:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fpwwt3bA Received: by kanga.kvack.org (Postfix) id DA73F6B05B3; Fri, 4 Dec 2026 10:17:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D7E976B05B8; Fri, 4 Dec 2026 10:17:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C93056B05BB; Fri, 4 Dec 2026 10:17:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A4EDF6B05B3 for ; Fri, 4 Dec 2026 10:17:55 -0500 (EST) Received: from smtpin28.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 19F15C0407 for ; Fri, 4 Dec 2026 15:17:55 +0000 (UTC) X-FDA: 85506655710.28.F8016D0 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf13.hostedemail.com (Postfix) with ESMTP id 6AA862000E for ; Fri, 4 Dec 2026 15:17:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Fpwwt3bA; spf=pass (imf13.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796397473; b=q9vNSUAdU3KyvZrQKBiRNa176ilDvvsOI0Zqa7WnMAqO0A1vfW0hQGKZLiRiP23Ey0oH6j kc+DRIAjPNPwOveST0Rkrd6lWcUywl/AhP7bjHLxuLhwTIprTJe2sLPHqQLbdBGm4G2vaD JLE3g5O51+6Q7p5wveKB5v3Z6g7Yg3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796397473; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ycVJ+REoS06TIMmyFXkvENAmq274p452jCKMNebmp7k=; b=J0DMFh+ndhte74t2z3jYzqi8FyPkEx+o17T4MNwgOKuSw0mQLfyCteVsWrhaTibsnXbnvR J2H8nAxmsOlGH05zHoRPRc5zBhw8UbAd31+VTIum4OthhElry75K5C0QHokPOLyNI3ItGD oSz2I2xEVXWx8A4DJnfByrwyDsuX9UI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Fpwwt3bA; spf=pass (imf13.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9D3AA611A6; Fri, 4 Dec 2026 15:17:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D2061F000C2; Fri, 4 Dec 2026 15:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796397472; bh=ycVJ+REoS06TIMmyFXkvENAmq274p452jCKMNebmp7k=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Fpwwt3bAk8ExY332aXARsTYvSbNIM+xwpbyP1aUy/iImCp2ox6Sb3RjbbXy/HGqdC boRCzo6uZ2sj6LzsAWMPd/WxLL+wiZCnSsQbHdhXIoRtZ6M/Reo4h4RcTsZuQhs4UV Z6ojRCK9il5tpK3AeNFfkARzgAfoNTn6V+ICq6nhGZli2hKD2KxpPc2MuO9/cnfrPi tqLS38kTnjjaq7n4mV9OlP3BG/YpNHU8oMCAtfDvCdhAphaqoEVDrICtKiEhmQ5P67 upLD4XSgonrOYW63u2joaFto4uQcHhky3DiT/MFpnkNsx8vmpoAL2UadEu/QMg34EZ FQDd//LZQxxGQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/3] mm: gup: handle fault retries in __mm_populate() Reply-To: sashiko-reviews@lists.linux.dev To: "Yeoreum Yun" , "Jason Gunthorpe" , "John Hubbard" , "Peter Xu" , linux-mm@kvack.org, "Jan Kara" , "Josef Bacik" , "Johannes Weiner" , "Lorenzo Stoakes" , "Liam R. Howlett" , "Vlastimil Babka" , "Mike Rapoport" , "Suren Baghdasaryan" , "Michal Hocko" , "Jann Horn" , "Pedro Falcato" Cc: "David Hildenbrand" , "Andrew Morton" , "Harrison Crosse" In-Reply-To: <20261203-infinite_mm_populate-v1-1-da5f1bccb3a2@arm.com> References: <20261203-infinite_mm_populate-v1-0-da5f1bccb3a2@arm.com> <20261203-infinite_mm_populate-v1-1-da5f1bccb3a2@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 15:17:50 +0000 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6AA862000E X-Rspam-User: X-Stat-Signature: hrtx3dxba7538soixd811p67b189xhks X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag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s8cd/cPyQ4St1vnheuJBvqTEeT/XMQ5hWYBYWe9CCMFMtZvOui/9ONDI3lUsvJPlLfbQEjXwMwdzeiVviH5+0OFCe38UZBH/tJoaduphZ4uUny41bVi2ZGmes/1keBFsOyfpwdwffsHO6QTvR+bTENdEzVYdkmzFnT9vfo3ZeMW4eqUJnG22bwmRhnJqB4n1ms4LrmsKsAO7Q3FlES0TInRy9tgyLXI6bYCMsVZMu4x2mt3SRw3WCCNrDJhflsWwt/syynYxLxQ19Tz1EIMA3IUMKidDMYx6dOquth0ZNewKMM3jSJpLOKaWdrLr/y5bGi36hJOgxlGCg69PN3nDzFSzHs2MSYhShoE8B89a7r1d/iCJZ9ja5jJV3v8FkqKAdmaHa8UUMrVaIu4cr73UFknoxN7xHIvgCN/Vn6JcajxHpwGuVCN8ory3LMFHNWbzhPF3r62nfTUxDBrq8ceIm8FyNqjcNhUHwQgk/dMBckcjdns4ZKe9L2XoWYScMaT2995/KE+T+Nknnez6oALMyY3UlF3iBOExdjqvj8vrib0cbZs131k+NChfnnWuPafECIt5+Yd7ICdjS4SQP7knZzng7hJfDlel8Eq+ci9BA8ZZoivENJ0KpvVc7nkBiHwqxpm8nkk/sH82bk8ERNhPOOKTUTOCOfmz76+8pRrFxF/m8rV+Qv6wfRO6tvSr/sPdsDmCZhVfg4ByI98l+4uJZFfq8TE4Ypu9+9fUzyL8GmluUIPVVvplLOKfbR50m5jSkIBKEYVc34nMjoHDVwTWo/cMy6mVo41qDChoX8eju486co90YsxBurbbA546rk= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] mm: missing Signed-off-by trailer for Co-developed-by co-author - [Medium] mm: stale tried flag in __mm_populate() leaks FOLL_TRIED to next VMA - [Medium] mm: __mm_populate() flushes LRU batches after every 1-page retry - [Low] mm: missing kernel-doc for retry param in __populate_vma_page_range() -- commit d410414cbb98de6eb94b0fba36ff0f79882dcf4e Author: Yeoreum Yun > mm: gup: handle fault retries in __mm_populate() > > When populating a file mapping whose reads repeatedly fail, > __mm_populate() can retry the same page indefinitely. > > On the first fault, filemap_fault() may drop mmap_lock before reading > the page and return VM_FAULT_RETRY without reporting the read error. > __get_user_pages() then returns the number of pages processed, which > may be zero. However, __mm_populate() retries the faulting page without > FOLL_TRIED, allowing this sequence to repeat indefinitely. > > To address this, track whether __get_user_pages() dropped mmap_lock > After reacquiring the lock and looking up the VMA again, retry a single > page with FOLL_TRIED. > > Fixes: 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operati= ons") > Co-developed-by: Harrison Crosse > Signed-off-by: Yeoreum Yun [Severity: High] Co-developed-by: Harrison Crosse is missing a matching Signed-off-by trailer. Per Documentation/process/submitting-patches.rst, every Co-developed-by tag must be immediately followed by a Signed-off-by from that co-author. > diff --git a/mm/gup.c b/mm/gup.c > index ec0bc99202169..d2ff0b667e377 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1886,7 +1886,7 @@ static __always_inline long __get_user_pages_locked= (struct mm_struct *mm, > } > =20 > /** > - * populate_vma_page_range() - populate a range of pages in the vma. > + * __populate_vma_page_range() - populate a range of pages in the vma. > * @vma: target vma > * @start: start address > * @end: end address > @@ -1905,8 +1905,8 @@ static __always_inline long __get_user_pages_locked= (struct mm_struct *mm, > * If @locked is non-NULL, it must held for read only and may be > * released. If it's released, *@locked will be set to 0. > */ > -long populate_vma_page_range(struct vm_area_struct *vma, > - unsigned long start, unsigned long end, int *locked) > +static long __populate_vma_page_range(struct vm_area_struct *vma, > + unsigned long start, unsigned long end, int *locked, bool retry) > { [Severity: Low] The kernel-doc comment for __populate_vma_page_range() does not document the new @retry parameter, which triggers a warning under make W=3D1 / scripts/kernel-doc. [ ... ] > @@ -2058,8 +2069,14 @@ int __mm_populate(unsigned long start, unsigned lo= ng len, int ignore_errors) > * Now fault in a range of pages. populate_vma_page_range() > * double checks the vma flags, so that it won't mlock pages > * if the vma was already munlocked. > + * > + * If we dropped the mmap_lock due to VM_FAULT_RETRY, retry only > + * the faulting page with FOLL_TRIED, so the fault handler > + * reports errors instead of making us retry forever. > */ > - ret =3D populate_vma_page_range(vma, nstart, nend, &locked); > + populate_end =3D (tried) ? nstart + PAGE_SIZE : nend; > + ret =3D __populate_vma_page_range(vma, nstart, populate_end, &locked, = tried); > + tried =3D !locked; > if (ret < 0) { > if (ignore_errors) { > ret =3D 0; [Severity: Medium] Can tried stay true when __mm_populate() moves on to a different address or VMA? After __populate_vma_page_range() drops mmap_read_lock, another thread can unmap the faulting VMA or replace it with a VM_IO/VM_PFNMAP VMA. On the next iteration, __mm_populate() advances past the faulting address without clearing tried: mm/gup.c:__mm_populate() { ... if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT)) continue; if (nstart < vma->vm_start) nstart =3D vma->vm_start; ... } The first fault on the next VMA then runs with FOLL_TRIED (FAULT_FLAG_TRIED), so maybe_unlock_mmap_for_io() keeps mmap_read_lock held across blocking file I/O and mm_account_fault() accounts it as a major fault. Resetting tried =3D false in both branches would avoid leaking retry state across addresses. [Severity: Medium] Does clamping the retry to a single page cause a performance regression by flushing LRU batches after every 1-page retry? __populate_vma_page_range() unconditionally calls lru_add_drain() before returning. The next iteration then re-enters __populate_vma_page_range() for [nstart + PAGE_SIZE, nend) under the same mmap_read_lock, repeating gup_vma_lookup(). During mlock() on swapped-out memory or MAP_POPULATE on a writable MAP_PRIVATE mapping, the 1-page retry queues one folio into mlock_fbatch or cpu_fbatches.lru_add, and lru_add_drain() immediately takes lruvec->lru_lock with IRQs disabled to flush it instead of batching. Hoisting lru_add_drain() out of __populate_vma_page_range() to populate_vma_page_range() and once at the end of __mm_populate(), matching faultin_page_range(), would avoid draining 1-folio batches on retries. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-infinite_m= m_populate-v1-0-da5f1bccb3a2@arm.com?part=3D1