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=1796143868; b=jJJYcldrzAp7WGkcf6RCda/VS3ilWl66xsZARkk12jpyr9kMfvgYYNQhirsJLq/laK8E cTzHaqkd0zPoWxqPtNOZQkpoFj4TD/deIga0okEt3UYCdUvVa3ljElAhfQfxLNCxa1sGN vIGKIUYFYw3q+aQRU/DUqf+Q0CxkF67rbwkushbmOi71+RLXTYST8LtIYHq4u1C0fBSO8 KYR7mwxP6DIrrw4ai+xo/He/YcKPbGC82R16wQYG3wTdPdPLSqwr4DmL8z9zRvun5R7HH ipQOtiZWWVkc59E1cgiAFccsRREBXqCOeyog0zKwf9n+TJphb5FJKtvUsWReJKaE47g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143868; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=r5unxtt2h6rr3rG0oZgON/vsAIw+9JRnvSsCJDMSD6c=; b=vyDv/LsgU+E5UyuGNGAtdw57LP8jmdaqj/mw3I/8h2SmbOfWhVG9QejfdIsKDBo17RwM 3Z3jDmllukcBrucTpsLVy4oQduKVKNc5CQUKBClXscn7/PbXp1CeeUgRdPkX+GLkS8286 E9VD+7ylNfQMy0obCh5KT55bhBKS/K9PjUxPfCaCjCsi2LXUv2euDRsMOmFL16n1oqC2N Rebo3AcHKfIXJnujRVC1m29FYvd/d/0p2D+JhPshbBE78gjhLcv3MXJ1CLKlcad7rVQG+ D8z9N9RVCF/8cb4Bww9ZNzXb+L0bV87z8Et+rDWqLkJD1c1EWTf5CchYhJN9+4sRh1g== 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=VS2IdoEi; 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 E972A606A32C; Tue, 1 Dec 2026 16:51:07 +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=VS2IdoEi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E1351F000C1; Tue, 1 Dec 2026 16:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796143867; bh=r5unxtt2h6rr3rG0oZgON/vsAIw+9JRnvSsCJDMSD6c=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=VS2IdoEiEG0KLswXz6tEe2NE2xsC6rZVHzLLC7jAF4JmXxL+KOmpj+bPO7kTw1CLl p0TE1LItFrI0QL0r/oZXFCsTasSEqfebvMVo6UeFH3iipSI/itp12eLohfnEiEjOFo IQt+cnXbYqEsd55KDOJg+nMB8oxm931uOUa/hM+DblF7ecnZcDJdMVPuXy34j91G8L tWMaiFJAm0dmHrDUixqYP9ZjOJTo8z/M00nvot+sf/XXveypubFtphRHGks8uSNXhk CwpLTBDYEv5nMVp//2V13cafjo06QMZHCi4Wjby79uO7KgcAaoXNDkwdwogLxdvikN G6DZAGAeE4/Tg== Date: Tue, 1 Dec 2026 16:50:51 +0000 From: "Lorenzo Stoakes (ARM)" To: "David Hildenbrand (Arm)" Cc: Muchun Song , Oscar Salvador , Andrew Morton , Jinmeng Zhou , Hongfu Li , Andrea Arcangeli , Mike Kravetz , Naoya Horiguchi , Hugh Dickins , Baolin Wang , Dave Airlie , Vivek Kasireddy , Gerd Hoffmann , Mike Rapoport , Mel Gorman , Dave McCracken , Andy Whitcroft , Adam Litke , Rik van Riel , "Liam R. Howlett" , Vlastimil Babka , Harry Yoo , Jann Horn , Lance Yang , James Houghton , Yang Shi , Suren Baghdasaryan , Shakeel Butt , Pedro Falcato , Gregory Price , Zi Yan , Joshua Hahn , Rakie Kim , Ying Huang , Matthew Brost , Byungchul Park , Alistair Popple , Wanpeng Li , Andi Kleen , Kenneth W Chen , Hugh Dickins , Michal Hocko , David Rientjes , Joern Engel , Jonathan Corbet , Shuah Khan , Randy Dunlap , Michal Hocko , "Aneesh Kumar K.V" , KAMEZAWA Hiroyuki , "Kirill A. Shutemov" , Sasha Levin , Guillaume Morin , Wanpeng Li , linux-mm@kvack.org, Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , linux-doc@vger.kernel.org Subject: Re: [PATCH 19/21] mm/hugetlb: use the VMA lock to stabilize flags for PMD sharing Message-ID: References: <20261125-hugetlb_fixes_2-v1-0-db27fd2f71a8@kernel.org> <20261125-hugetlb_fixes_2-v1-19-db27fd2f71a8@kernel.org> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261125-hugetlb_fixes_2-v1-19-db27fd2f71a8@kernel.org> On Wed, Nov 25, 2026 at 11:33:17PM +0100, David Hildenbrand (Arm) wrote: > huge_pmd_share() currently only shares the page tables of another VMA if > it can read-lock the mmap lock of the corresponding mm. That refuses > sharing whenever that mm is write-locked or if the mmap lock is > contended. Is this much of a problem really? I'm not sure this change is really worth it? > > mprotect() holds the VMA write lock while changing the flags and the > page table entries, so let's read-lock only that VMA instead. As we hold > i_mmap_rwsem, that VMA remains part of its mm and cannot go away. Ugh lord :) > > Add vma_trylock_read(), a variant of vma_start_read(), that does not > require being called with the RCU read lock held, and will also not drop > it itself. (As discussed off-list) Hmm you're not adding a variant on vma_start_read(), you're creating a completely distinct API for obtaining a VMA read lock, without a fallback. And one that relies upon the caller getting things right re: dependent locks. And given what we've seen in BPF recently, it turns out people already find ways to open-code things to be broken so I fear what they might do with this. Also note that all VMA read locks are trylocks (yes I know a lot of the API stuff here is a mess :) Right now lock_vma_under_rcu() is the way (TM) to get a VMA lock without an mmap lock already held. For now I'd like to maintain it as that. So overall can we drop this patch? It doesn't seem critical and hugetlb screwing itself over by being built as a series of hacks-on-hacks seems like a hugetlb problem :) This seems like a perf optimisation rather than a bug fix so I think it's safe too. (Also not really all that worried about making PMD page table sharing less likely, that is a cursed broken thing in itself :P) -- Cheers, Lorenzo