From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793273883; b=PXSLBExwhOhkjRhQTBn/VVXBNNf8AOUvM544rEv83GlGajEJC5onmuSLeCjelfObLI4r BhySzfnzGvkNQXC7N/9Cd5iQvy//ui2u3KsMd+QXlm5E7SnTTHmKRbYBaVUbu3aPsJ+iD Rz6q/x1ZUPmrmgfWKf40V7lGPdpC3dOD3BGT6oEqbyPKGd3Exat/Q7vGffPlPhCNDXcJ8 kIAkg4Cw4AUYrBKngwYnVaJY6eYx/WpIapAAAz9xs5FN9N2hgO+cEm8HC4S3zPi1U6Idi kbkva7J7z2D3AW4LoUYSPkF+WOpiVWg1q0mI3vF3JABUy7efakQ8O+ruyI3XELmXeVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793273883; h=Received:DKIM-Signature:Received:Received:X-ME-Sender:X-ME-Received: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=hNCQwk1kVwwDQd6YdP9bn0F2tzwSBJGnMYrpsz+xroI=; b=H/aVNKUjpf9eBpBeg9pQa/yjoRb6LG6YKHEkRsJKGb4zofRFAW40n9c9wmiyKCyQGIQt Tit5HcXmWtpEgtpiQYNlogoxuSXUUlLadpTmEX8ByVTDFZU1CmZqC/GzwBYixEXR6IXE6 bDRdv+4CpxBs4pyoVkvAIMhvNnCP/2x6FB3AO0GU/vf0xgtu8VTjjcDXOVNTNZWqSSNUC LiwgTpgDRFLov2GTleRDwZoqMY10+0XIhse9LH2G+nuHBa3wR0Uj5FaNwvZ0vi8L6P3bj QoOD6BJl59DRpZmoogzoBKYdzD2aWyeXa6IFRr+jAaNA21joQODVdSOTPScciD2tc6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y+wvSFRZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 986E0606A31E for ; Thu, 29 Oct 2026 11:38:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y+wvSFRZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AA971F01828; Thu, 29 Oct 2026 11:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793273883; bh=hNCQwk1kVwwDQd6YdP9bn0F2tzwSBJGnMYrpsz+xroI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Y+wvSFRZHiA/CwsgHT6WIkTAUfN/hrULLfM6EXRseX5ekir+xOA8Ej16YbJjdUqYr qlT+J37lnqOzHyYf+2qkV4FchoGpuWsz5ktqIWegKLAYBh3JkfOM/ckol2afDh0pzK hOYIJDSt/hhYRKye+2l2lWlYg2jgxWgWeU2nC/UukkaaN5T6itDQt+EB83IuKiD+EU N9o0KhHh9CduPUzqioKIbXxMiw9Fysvs711ZluJx+5fe/UUQi0Z12wrSGCetLRakSs rQNAAXQQe/ernfQrdf74dWLEyz98D+fBxX8UgDEpxsp8CN45dekmS0VBB6QZ9VH/dk kaPO9u32T6Ecw== Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.ams.internal (Postfix) with ESMTP id 61199198003A; Thu, 29 Oct 2026 07:37:47 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 29 Oct 2026 07:37:57 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEJDAstCk+7zNgejakM4nNk+p9JZpQkZ6Wp/ORPY45DYJ9sLHFzb2OSqjFNCrREyO 88yfN6Bm2PU/BZ+n9uLJeM8IQCx6gh4dmoBjtrR/gRMQnW1vav0T4U3R0wWLGH7ILSJz0U jdMa6OkiVebfbkVm5JCCWeL4Bgmn1pDydwYsJOPck3Qdns4HPrCASx59vSMT+/j+yF0qvX G2BRvU5cIsoY70+iA26gBsYSOUUpx4hNQp6J+87EVccCZ9Ae0yLIol7hi0rblFUAevpiPd uHrIkD9QzQyn3BgarrdLD501N6XdbeMUSrCRkW1q1L/F8zcqlxf0OSCgggqIu+bFPdnmVK NcNYxpSkwWOCwZcLOuaYHRTsxYx6D85JDsOHrpKL1vEhmUAKDtUhCnUAlLFqot1DM9q/eV ZTIcjPJqq14fF0zy0HGkF60Z4NFN+bSz/WNKQw6f5WcVzsXmI0zvI1J66w/XqmME697OXQ zERHpQf1f2P1KpVc8eIXbHuzD/SOd6B+KE+lUnfFtKDQN9VNcFcye2oj8ZEx6A7qEAQffs IUWqlyPo0fg/2eaM6xeJ2DOITKhJqU9srQCSgILo9WyD2HhperaR62DEVqvtfMq6CL02UO uYQhCBNO5b6ROgC+/K/MpQZdw9fNc5YCZUTnJbGBtnaHKfxJROTOsVpYwzvA X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Oct 2026 07:37:45 -0400 (EDT) Date: Thu, 29 Oct 2026 11:37:44 +0000 From: Kiryl Shutsemau To: "David Hildenbrand (Arm)" Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, stable@vger.kernel.org, Josef Bacik Subject: Re: [PATCH 05/46] mm/truncate: look again if a folio left the mapping Message-ID: References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-5-6f74bec9a5bb@kernel.org> <2f2ef336-2186-4f20-b7f5-565e60471bda@kernel.org> X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2f2ef336-2186-4f20-b7f5-565e60471bda@kernel.org> On Wed, Oct 28, 2026 at 10:45:34PM +0100, David Hildenbrand (Arm) wrote: > My brain hurts, does the above make sense? Yes, I missed that the loop only goes back to start when a lookup comes back empty below end. When the last batch reaches end, it exits without another look. It doesn't need the split either: any punch hole whose last page is in the page cache gets there. That exit looks unintended to me. b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios") turned the "if (start >= end) goto out" early exit into the loop condition. Before it, the loop went back to start until a lookup from start found nothing; Hugh kept that on purpose for hole punch in 792ceaefe621 ("mm/fs: fix pessimization in hole-punching pagecache"). Restoring it is enough, and makes the "restart to make sure all gone" comment true again: + if (start >= end) + return; + index = start; - while (index < end) { + for (;;) { Then a replaced folio is found on the next round, and truncate needs no special case for it. -- Kiryl Shutsemau / Kirill A. Shutemov