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=1793016755; b=ghHbgaIINk+RPwxgmE8yNg0HKTa/02ZU3YvmQH/dxNyUnNavI0q37eLCF2QjJqXCCm1H tZbm3sPTqdwlWzkNCUV9wcj7jaWtZYaXLzY/fZu2w0HD/fDzW/EeSxsw+YWfiAIwXylb/ 5upz7+4RkSEqpw76YThXjBODLcgfvTa9VLMm1Ue6ZNbXiGMeiRyBHqKGIrkWFmVKOkfKM PGk+Y453qJ/B2wzlKFBkzXj/b4xy8rA7S9nEsdkTLVQNr64naB5v4keDA87H/FCGTP8L0 5nn880fp3gw1+ZN0vjE6eNNvpdyQqHEeqORrDGxn8uPoMmaKj48dBx2kiVVvLmRqHCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793016755; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:Autocrypt:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=sCtZvtAR22Ami4S2eIk3HMfDGlAC6il3qa+TGty4veQ=; b=tjWUyn3UIo9OdS0wPetbRDFRqzuGTJzcBA7yGDaueVzmrTdN9neQb2thoajQrVICaNzi xJADSOnPYNYtWMjfJpbUo8Dt13NcfqhUQ/hXEul0+5l50Pn4IKZmxRPINzT8cfOZ6gxQp IVQod9MJB/g9P8Mj6FqfcVBSww4MlYhXhgCJ2jBZTe1tKMCcKyp7NJEGE6jtFKreUTRMm oGnwKCyYeWd7UzrZbkXBq1hS/cRQ1ibVSvEx9NdokjZ+igzqH/tYV0TEKzXru0MEgL8yk /zlL9oh8zz535taT5/zIKfplNphWCXwIfI0qSa2nDLbWMq567P3zF/0nkXrTpCALvgw== 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=J5hXer1y; 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 522D4606A333; Mon, 26 Oct 2026 12:12:35 +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=J5hXer1y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FF3B1F01825; Mon, 26 Oct 2026 12:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793016754; bh=sCtZvtAR22Ami4S2eIk3HMfDGlAC6il3qa+TGty4veQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=J5hXer1yoooeUjppZ6vg8NVJpK4TPTZVdh9mBwO8PTZfOuoo4QYTexYN5v+PEzfkn +TkbN4+MdUGit7k3nxjDNTPx8XlLTmXCOWgk0q2jT0c6clk4Y+U204lwBOg4QpKeTb 2GrghX99FnCH1TA4q2dZ42c0kJQsGRxKR+N71jDq5SPhPn2abEnXgHtfFFbV3dCGpJ ZQby89YbBNK/CL7OkyiRCB9dXnyaZV7aCgMFQmE7ikIFxWmT3ZBZCV6pY1hl3k8x4B +VChZ6FM7OBEfqPxPtdnRfDXLcbT3EA2eUVGeSOVcQT4WGvNP89jipV5fpMMyTiwEe 6vW1Y4+W21ACA== Message-ID: <1398e842-db91-4482-949a-e21197a48b9c@kernel.org> Date: Mon, 26 Oct 2026 13:12:02 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/16] mm/shmem: various (urgent?) fixes To: Baolin Wang , Andrew Morton , Gregory Price , Zi Yan , Joshua Hahn , Rakie Kim , Ying Huang , Johannes Weiner , Vladimir Davydov , Michal Hocko , Hugh Dickins , Lukas Czerner , Carlos Maiolino , Christian Brauner , Jan Kara , Daniel Verkamp , Jeff Xu , Muchun Song , Oscar Salvador , David Stevens , "Matthew Wilcox (Oracle)" , William Kucharski , Chris Li , Kairui Song , Nhat Pham , Miaohe Lin , Naoya Horiguchi Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chris Mason , stable@vger.kernel.org, Josef Bacik , Eva Kurchatova References: <20261026-fixes_shmem-v1-0-703206d5fa0c@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/Ddm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Z8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/26/26 12:11, Baolin Wang wrote: > > > On 10/26/26 5:40 PM, David Hildenbrand (Arm) wrote: >> Hi, >> >> the fixing fun continues. >> >> This is a handful of fixes for shmem/tmpfs. I sneaked in a related >> hugetlb fix that stalled upstream. > > Wow, thanks David! > >> Some of the stuff is more urgent (patch #1, F_SEAL_EXEC, truncation >> hangs), others are less urgent but still rather unpleasant. >> >> The majority are fixes from Anthropic that I cleaned up or reworked. >> While doing that, I found a bunch of other issues and tried to fix them >> somewhat cleanly. >> >> In general, shmem + swap handling is a nightmare. shmem_undo_range() is >> such utter garbage it makes me want to cry. I mean, really, WTF did we >> end up creating there. Does any expert here have time to clean that up and >> make it *actually* maintainable. > > Agree. :) I'll re-read shmem_undo_range() and take a close look at the issues > you raised, and see if I can make shmem_undo_range() more readable. > >> The following things are still broken in shmem_undo_range(): >> >> (1) Truncate/punch of a single page of a large swap-error marker >> >> We don't split. Consequently, read access afterwards will still fail >> instead of returning 0s. >> >> I have a fix to try to split (which can fail), but I don't consider it >> that urgent, really. So I'm not including it. Might send it later >> separately. >> >> Truncate/punch of a partial page can obviously never do the right thing, >> as we cannot poison parts of pages ... >> >> (2) Truncate/punch whole pages within part of a large swap entry >> >> We try to read the entry, but if we are out of memory that might fail. >> Consequently, we will not free up swap space and a re-read will not give >> us 0s but the previous content. >> >> AI proposed a nasty NOFAIL patch which has too many nasty side effects >> IMHO (allowing users to force-read pages and retain them afterwards even >> though memory.max would disallow it). This needs a proper thought. Likely, >> support for splitting large swap entries (and large folios in the >> swapcache, which I recall is under developmentĀ  by Kairui). But splitting >> can fail ... >> >> (3) Truncate/punch of a part of a base-page swap entry >> >> We obviously have to read the page in, in order to 0-out the parts to >> discard. That might obviously fail. >> >> Maybe we should install swapin-error markers if swapping during >> truncate/punchhole fails, to at least tell user space on later access >> that something went wrong? We might affect unrelated data, outside the >> requested range, though. Anyhow, these are long standing issues and >> I don't consider them urgent. >> >> They need a proper solution. >> >> I did my best trying to test these fixes. I was able to reproduce some >> of the things (including unkillable truncation hangs), and the fixes seemed >> to help. >> >> But again, shmem_undo_range() is just an absolute mess. >> >> Please prioritize review of these fixes, I want to get fixes for the >> issues in a timely manner upstream. > > OK. Will review and test this serires this week. Thanks! If there are better simple fixes, please do suggest them. Any bigger cleanups ideally come on top. BTW, the next time I get a flood of these patches, would you be willing to do the early screening+revise? But be careful, some of them are pretty, pretty awful :) -- Cheers, David