From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249147; b=l/iUpSM9uPSLuTTcqJV++8cRpXtfMJGXzITpOQT6A04Aylp+7iHmxKNzJTK0pYlmPdOe BvbM4bddrI38L9eTig5swImQRWr/BU2ta9Iqpsiy51NzJF4VOjkUIlJ0xvk7MRLestNn6 hFcDUXdrqqAWRHgs24R7mqU1/oaJGM6qcTkYq7yeBi1dz5lSZwmxr/3R95D51ZwE0ZyYF bOOQiGZ6N8LIUtIGkpPgR3akCm/Hj/Pusm8VXEYyBFwh3qBOUkw/sehCj0P45OMfYudBD Bznd7m2xPUPJ/rboHQuOyjRSVwIziMNb9oR/O/J/o21KTf2u6nDJtRaLhkPnqr+vciQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249147; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=KzYIxrV4P0riX4vRM3I961GF020sESa0dfaji9Baeis=; b=EuabEwXqtdqv/Mdc6GzJOu+fG3ek5q17N9/M3m30behRZy1TsjWHD0+DLvlLJPxfpzTR ruHaPI2Qm/RBNOCpbkvc4WVCIm8EYaFDpUlbQ4t8iQkn5NzgrXM981I6ac27Imgv04qtt opilmZtYBeFDITS8Q1sNhHNHbz7tfwDAYf7Z0o757T8X8oclE1e9Y0VC/RT6pfdrN97yZ AgheZtitYsxDTTi9EGu4uippC4az+WeHVIfJbtpQzDxOPtoJCavWkxRKjCpe06I2tDLMr TfiNM08u8j8BnELRd6o4Dv+LjFqkrzwaCiqUA7h4ZOHiQerH3if3z1QAL0zWlauDKpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=TiMrGq8C; arc=none smtp.remote-ip=209.85.219.43 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0FB2606A322 for ; Wed, 2 Dec 2026 22:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F0FB2606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=TiMrGq8C Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-92107df3f13so128730466d6.3 for ; Wed, 02 Dec 2026 14:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796249146; x=1796853946; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=KzYIxrV4P0riX4vRM3I961GF020sESa0dfaji9Baeis=; b=TiMrGq8CFk/y8VVQfnQAaTgdJXF56BJfYI/GdHZ+MMUvvJX/hBJVHHKSPTupspOJeu wjEu2lc+cJPocxE3LwjDBAot732hA1m0dfVHi898m/zqbdxXdQtR6SewPbIGQY3X9IRA Y1d1nc0w09E9smZyM49dhnWqVgvtaPFV2Q8Ky1o6IqCLI6+WF+6aCfbKCcVEE6etqHoc 27q1wbU1WviFI7yEK9nDXeA6+5cifuMKnqMUFQqxJnJsM23pFo3GZ9EI6L8N2ucUxNPL ugPSMUpaFbD+9FAyr+2qi6PYZqjDmyHf35MHgdCtOTpoWO/7qV0ZX40AWxtj+VJ/JoPP 2plw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796249146; x=1796853946; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KzYIxrV4P0riX4vRM3I961GF020sESa0dfaji9Baeis=; b=sdVeEOMXaIgnC9hpIWEfn210dUMxXU7rHaYfIKbwlJQ9JayS8bOoNMwr0SX6fXQdL2 hvQN3gp2+rYOW6b4Vh4P80rOrp1nRvBCXqlKghTGfHrUvWDKDhbrvLgbiGiRL6j7kFjQ P4PMFX3T/VIbNZOt8X0gUQ1bXc7KMzGOIme7m4TWOhhaYQ5Xn4r74tRsrKOdXrMoROZy GJerCd+NjBk4SwOM1CnHPn5h0mwVlHA1bN0+sTioioFCCDGEFejWOOkR2Z3HhKENeXdx HPwAw1lndxKA2IQk46vcLcAEyFFWQJW/7e3do+oGvwYv5iXiydGVnkyIa/AsOUI1xYGW ZZMA== X-Forwarded-Encrypted: i=1; AL+hErF4qemqh2pO6OTL1sAKCIjwMG6R2sezmW3VCVOu7y9x4mNKD4YjPYYxjXCJ7mwkrQBrfFJK76Zf9K+lw/U=@vger.kernel.org X-Gm-Message-State: APuU4Z+YsT7qQ5Vft1gcyBJ9ec1OjxYmt2OaymuEpNKBOUuk+iPMSdK2 H40EJUrfM0D0ZaSHE12ercSWYeKd23yMOrvzQsAxPliXxCLG47mX033NR9EKb89GZ6I= X-Gm-Gg: AZFdTZeJeb8ghbR+U6gN2Jcgdo2agSIo1DYFqeb6qqJJ2IZVaTm0MB67/moTcAA2cM2 7dmMQg1xTbT0jd9eGkml0DTi5twePdgNKk9e4F4aLtpBlvfuhuSej1U5ZftMYMFLBkA+NooN64A DTMrYMYbDBPW1NDf4aTN6OTc1yLqxP4nmbMr+5iALC8kjcZVT3Z/c6NLHy0EzegyztcruUp02ss j9pe0Jam9LrvNGgotyK46ezBot4lUvF81TGWaqgSRe9QMme/kY6QsahNBT7oS0cWR8ZhUZCs+bb 0rfef6BI8r1CC8WC/D846cFBzeK7rtc3hsh0/BPtLQw6oRuCm0PCeWZwH5vBncPtv8Rr3CgFopM gHXiQI//9umS9xkjuFkBtf0JBu40923uI94+5/ZywLXPfINNkkuSbLSWmOmOJ/Q/e0+75BjdWIJ s+/2P05PlJqqcgPrm9ygU39n+N7G3VmBHqUh/Z9HydIeGOpSo2KAi4fg/EBownM9evAGvbMZOO4 Bt5f/Iz4Dm6okhzJ3XqDfHYvEygtypTLKTwI6HxIyvpKcc5Gh/dFlZKdBIyYOmb0s2Y9U/bW1yy XD5Za+n/+5fige13UHih8P3Ucj4VG+COYs8cDuP/lvZC4hGhq4k5dRZrTR8v9daKnpa9Ci/HP0Y 8iouq1CA= X-Received: by 2002:a05:6214:40c:b0:91c:81c4:e662 with SMTP id 6a1803df08f44-921349d1bacmr779593116d6.8.1796249145707; Wed, 02 Dec 2026 14:05:45 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9217c38f19csm214766566d6.26.2026.12.02.14.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 14:05:45 -0800 (PST) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 11/32] mm/khugepaged: store new folio before adding it to LRU From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason In-Reply-To: <20261129-fixes_core_3-v1-11-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-11-f66094116801@kernel.org> Date: Wed, 02 Dec 2026 17:05:43 -0500 Message-Id: <179624914335.2841792.4127747354008823986.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, David Hildenbrand (Arm) wrote: > From: Chris Mason > > collapse_file() adds the new folio to the LRU before adding it to the > page cache. If SHM_LOCKed, the folio will be added to the unevictable > LRU. A concurrent SHM_UNLOCK walks the page cache to make all folios > evictable again, and can miss the new folio: > > collapse_file() SHM_UNLOCK > =============== ========== > folio_add_lru(new_folio) > /* unevictable */ > shmem_unlock_mapping() > /* misses new_folio */ > xas_store(&xas, new_folio) > > Consequently, if SHM_UNLOCK races with a collapse in a SHM_LOCKed SysV > shared memory segment, the new folio can get stranded on the unevictable > LRU. > > Let's improve it by adding the new folio to the LRU only after adding it > to the page cache. > > There is a more fundamental race that must be sorted out to fix this > completely: check_move_unevictable_folios() skips folios that are not on > the LRU without taking the lruvec lock, while lru_add() checks evictability > before marking the folio as being on the LRU. That affects all folios that > are added to the LRU, and requires a more generic fix. > > This has low urgency, as it only strands a folio on the unevictable LRU. > No need to CC stable. > > Fixes: a2e17cc2efc7 ("mm/khugepaged: maintain page cache uptodate flag") > Signed-off-by: Chris Mason > [ david: simplify description and comment ] > Signed-off-by: David Hildenbrand (Arm) Reviewed-by: Gregory Price (Meta) -- ~Gregory