From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E33F4606A320 for ; Tue, 1 Dec 2026 13:24:49 +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=ebbKIyN3 Received: by kanga.kvack.org (Postfix) id 0C6136B05B1; Tue, 1 Dec 2026 08:24:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09E526B05B2; Tue, 1 Dec 2026 08:24:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA8126B05B3; Tue, 1 Dec 2026 08:24:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CC1CE6B05B1 for ; Tue, 1 Dec 2026 08:24:48 -0500 (EST) Received: from smtpin30.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CB37040E96 for ; Tue, 1 Dec 2026 13:24:47 +0000 (UTC) X-FDA: 85495484214.30.9EBB625 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf17.hostedemail.com (Postfix) with ESMTP id 2D6EF4000D for ; Tue, 1 Dec 2026 13:24:46 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ebbKIyN3; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of ljs@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=ljs@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796131486; b=KA0JH6uOKKW2IymZ0EpaTsEdPPHFgoo4DCm8J59eIoDBP6oY04lSOCCSHajzRv0/qcp1y6 YsE4hDacIFzhQ8Aq3akTuePGZFuge0NJXClWWuZyZzknO73ht21DnKrP4mNFJe7w47BFuM vatRfCGbaWA9xRW9PQkLh10STxSWXZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796131486; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=i4ZKueFcjEPZMihAbe5n6ouVPP4fZwO1xDJZY345UDw=; b=KVu9GktC17513wpXgb7A8LQrwU5gAQxIie8J7ZoqMjsQTwHFM6c8vduiIVlYOyMqNDLeIj hSbuyE1y30xzzyF+qt68SPvgh48Pi0FHt5W8Zjqi/jaQ79igZmZPpKyoBOdM6IdrOokrf9 NojYyDnY6d0/6mJZJRbIp6Kw/ZbzLUs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ebbKIyN3; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of ljs@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=ljs@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 723DD62570; Tue, 1 Dec 2026 13:24:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB6201F0089F; Tue, 1 Dec 2026 13:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796131485; bh=i4ZKueFcjEPZMihAbe5n6ouVPP4fZwO1xDJZY345UDw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ebbKIyN32DBq+vuMVz+CoHXUWQU04RM0ynrcgObfFkMU4afqC3wJmhoouubwXtIcD mYMOLxY5w59363AfEmeYcl5d5A0OzSF5xPn1DvG4Q9zJsj3IQl0advp3lb19guCnCK 8czpA/bU3qPumGijYlPjqRXIRWAkb9xRlrAdcjTjcIqPYgpdBn+sEDy/FO/ct8ms6Y P/XvQMkBSL3vm8uANVMWVmxrlRPMuw169En09Z/TvHR8Bmg4GxTb0PvI4cOPb7A4CR dSiPf8ctvyngepEO6xbMC+7ZSB5ehsZBMZcmc0fRCcV5KQsonQvzgf1qm4G5CJmg6k 0i7xWRX03aOHA== Date: Tue, 1 Dec 2026 13:24:34 +0000 From: "Lorenzo Stoakes (ARM)" To: Chuanhua Han Cc: Andrew Morton , linux-mm@kvack.org, Kairui Song , Barry Song , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Suren Baghdasaryan , Pedro Falcato , Jann Horn , Johannes Weiner , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-doc@vger.kernel.org, Michal Hocko , Matthew Wilcox , Yu Zhao , Kalesh Singh , Hugh Dickins , Ridong Chen , linux-kernel@vger.kernel.org, Chuanhua Han Subject: Re: [RFC PATCH 1/5] mm/mmap_lock: add vma_start_read_rcu() helper Message-ID: References: <20261201131135.2914944-1-hanchuanhua@xiaomi.com> <20261201131135.2914944-2-hanchuanhua@xiaomi.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261201131135.2914944-2-hanchuanhua@xiaomi.com> X-Stat-Signature: 1ommotdtnwira5rspp8fko1sj5zxyogi X-Rspamd-Queue-Id: 2D6EF4000D X-Rspamd-Server: rspam02 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham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/PWk28/qOszlx1A89Uu4ShTHp0u+JsUe8iO76Nmlq9WJBH9D/2pFeFZ5RLK/TNBcwuB7Q/+CIEekpSOzyVN95oVReSEaYGdHVqErXsBLPDyya32juqycsV2VAbHJzW9mdFXcVJoLBSA4u4JvR3LYpVQwBq98nrHnZaM61SA+7ehj0SUFb3S1qoO5sHvLJtEoZ47hJ1hGFkQCFoNkyYqgItmJDhHuWQgkkYGruP7+AJ3xwGoeb10LKu+OeMp9J0DtI3B4jbjuGCy2jICluO+JdnHOFg/aj1VXi98AMqPjFxkq/aE5/eNG9w6D7Q2NNFtmLqGivSZ4ROcMPToljdvH5dCSqQATLgG8At3IPmhPg6c2XIu0BTIG4CPtehBoDIK6hosxKZV+C6eAWc48beGcTXfSW0Mba+0RKfrPjcXJML3U1UQLYuQsyR6dhql3g8yXOeFRh3engevgUIdao340nI+3bHC0zjAvAEj1g9Hq1qGVd4Zrsq3SJ3kwSi+OuxkMA= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 NAK. You're not doing this. Any of it, sorry. On Tue, Dec 01, 2026 at 09:11:31PM +0800, Chuanhua Han wrote: > A later patch makes the MGLRU aging walk lock VMAs one at a time instead > of holding mmap_lock for the whole mm. The walk only tries to read-lock > each VMA it finds under RCU, and skips the VMA if its lock is held for > write, rather than waiting for the writer. It does so in two places: No. > > - While iterating the VMA tree under RCU. > > - While holding a PTE lock, inside the RCU read side critical section > of pte_offset_map(), to hand the VMA lock off to the next VMA in > the same PTE table without dropping the PTE lock. Waiting there > could deadlock: a writer such as mprotect() takes the PTE lock > after the VMA write lock. > No. > vma_start_read() does not fit the second place, and is awkward in the > first. When it fails, it leaves the RCU read side critical section, > which the PTE table mapped by pte_offset_map() depends on, and the > iteration has to look the next VMA up again. If the VMA has been > recycled for another mm, it also mmdrop()s that mm, and __mmdrop() is > heavy enough that vma_start_read() already defers it until after RCU; > it should not run under a PTE lock either. lock_vma_under_rcu() and > lock_next_vma() build on vma_start_read() and, on failure, retry or > fall back to mmap_lock. The walk cannot open code the locking, which > relies on helpers private to mm/mmap_lock.c. NO. > > Move the body of vma_start_read() into __vma_start_read(), which stays > in the RCU read side critical section and returns the other mm through > @drop_mm instead of dropping it, and rebuild vma_start_read() on top > of it with the same behavior. No. > > Add vma_start_read_rcu() on top of __vma_start_read(). It returns NULL > both when the VMA cannot be locked and when it is detached, since the > walk skips it either way. The caller mmdrop()s the mm returned in > @drop_mm after dropping its spinlocks and leaving RCU, and, as with > any VMA found under RCU, checks that the locked VMA still covers the > range it expects. No. > > No functional change. Not true, you're creating a brand new API and expecting VMA maintainers to maintain it indefinitely. Also to give you free review time. > > Signed-off-by: Chuanhua Han No thanks. As VMA co-maintainer let me just make this simple - I am not interested in changes like this from unknown people, at all. Sorry. LLMs have changed the landscape. Do smaller changes first. I have no confidence you understand any of it. -- Cheers, Lorenzo