From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793352053; b=xAIuFl6ILTXYDeacDUYD7/8zUgu+O/TUr+V0zqFCeRr1BPIiRkLoTvHK+DecO8U61lRF 5/sakWgTXQvlOXbvmXz4a7nhonW1Pu8NbHtpB3WsxoSx5kxbGqpla8imUJ+Nm6Um5UIX1 CXVVg2kwXIO7XlgFgLhSQ8HuMtDWPmO78YoYYPxVat19HxhAoZfyYaTDPD3Cmfe2iONq0 lPyAuiQe5B2gg7PZsvKj4j9+KxFNSB41qFjS7wYZXO8KYYM0xD3Y7wOBDFP4HQG1mrL+I QOZqSlwMhFNpGwckQv8S0gFGFz/keO/RbigbROOOOPj1nDzOGWHI136ND4IsIFhuW3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793352053; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=DwWDiQU31GhAJkKLOok0q5GmDT5UejWxDA7k4JTVj4M=; b=HXgEicaHc9Y/YijgXLLmFuO438dBWw+nxN9BAoG5zRwuGUgT2ycjZZKZtWJ/zTWQaAES E8+ptWN9pWwMRYGNNl8u3mT5JkghMP9MzOCqQ7tFPTFN9Hfyr9BHD1JalMqM6gpojtIJo jKzNWZh/MSbJfeBvvY1t2E9/aFPSCxk/7C1g2G6FoRAuuW/LxgZJoM/Ja5GbO+penJGL1 9mnkaDWqldkApKlKnqzgDVMks6o+NX9NiI0tdwYa3LBMjkECRvVaavbZnDxmVO9hC5g48 XpYzJGJ/u+xxunVXWtEss6WawsyEXqOCTdDKtYrb6k5zBo3LIcpYiRwlvRSjX+IvM/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=d87jxZYs; arc=none smtp.remote-ip=95.215.58.14 Received: from mta1.migadu.com (out-14.mta1.migadu.com [95.215.58.14]) (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 03604606A31F for ; Fri, 30 Oct 2026 09:20:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 03604606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=d87jxZYs X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=DwWDiQU31GhAJkKLOok0q5GmDT5UejWxDA7k4JTVj4M=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793352050; v=1; x=1793956850; b=d87jxZYsXzSYCQ/xHD6fPWdvBbmfDED2jZYdIP/wz0YMDb65qjez3nTkqQ2OiGGUSbvTbfQM 4fRPwHh32lyypRcBqLI618nMxfYTKzklpEZuKUGzwqzhkdwzTqJOKu5v5/QYZXXVsjgPD8Ix4e3 f6sg9vfDv/TQg6Cbx/x5kjZ0= X-Envelope-To: linux-doc@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id 222f0c8429a65a02; Fri, 30 Oct 2026 09:20:38 +0000 X-Mizu-Trace-ID: 222f0c8429a65a02 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.100.1.1.12\)) Subject: Re: [PATCH 06/15] mm/hugetlb: fix mremap() racing with page migration From: Muchun Song In-Reply-To: <20261028-fixes_hugetlb-v1-6-a0a033db180f@kernel.org> Date: Fri, 30 Oct 2026 17:20:12 +0800 Cc: Oscar Salvador , Naoya Horiguchi , Andrew Morton , Mel Gorman , Andy Whitcroft , Miaohe Lin , Michal Hocko , Rik van Riel , Hugh Dickins , Baolin Wang , Vivek Kasireddy , Dave Airlie , Jason Gunthorpe , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Jonathan Corbet , Shuah Khan , Randy Dunlap , Peter Xu , Breno Leitao , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gerd Hoffmann , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, stable@kernel.org, Chris Mason Content-Transfer-Encoding: quoted-printable Message-Id: <9FFF0EF2-A99A-4448-9CA3-50E1733D6232@linux.dev> References: <20261028-fixes_hugetlb-v1-0-a0a033db180f@kernel.org> <20261028-fixes_hugetlb-v1-6-a0a033db180f@kernel.org> To: "David Hildenbrand (Arm)" X-Mailer: Apple Mail (2.3901.100.1.1.12) > On Oct 29, 2026, at 04:13, David Hildenbrand (Arm) = wrote: >=20 > Migration of anon hugetlb folios walks the anon_vma, so the file's > i_mmap_rwsem does not serialize it against move_hugetlb_page_tables(). >=20 > There are various issues with that. Most importantly, move_huge_pte() > releases both page table locks before the TLB is flushed. Migration = can > then find the destination entry and finish migration, reusing the old > folio while the TLB still has entries cached. >=20 > Hold the anon_vma write lock across the move and the final TLB flush. > This also prevents concurrent rmap walks from missing entries moved > during rollback. >=20 > When we must allocate a destination page table, flush the TLB before > dropping the anon_vma lock, then reacquire it after allocation. >=20 > Dropping the lock only works around lockdep: hugetlb folios are not > reclaimed or migrated by allocation compaction, but their anon_vmas > share the lock class used by ordinary anonymous memory. Having a > separate lock class for hugetlb's anon_vma (like already done for > i_mmap_rwsem via hugetlbfs_i_mmap_rwsem_key) requires more thought. >=20 > There is a concern that this can block page migration of anonymous > folios quite a while ... which is not really different to what happens > to page-cache folios today. If ever a problem, we can temporarily > release the lock. >=20 > So let's keep it simple for now. Make sense. >=20 > It is a shame that hugetlb has to implement everything core-mm = implements > in a different way that just screams for problems. Yeah, nightmare in MM. >=20 > Fixes: 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage = backed vma") > Cc: stable@kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) Acked-by: Muchun Song Thanks.