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=1796383330; b=Zh7AYJXGLucxi9uhFYi2o4DcCIpLh+DZ9OwkZrj4AeTivY2+XaTGWHn0HO0WYjyAEfyR ADGK8djvP7SlR84/Szn+yk2HDoTLLPOP1xQVVRSwAvifpEM3NSYHhu0zNdgpLFJYdKDsF PmFZAs32085cqXy+sAqkzfVOXS4e9R4eNFvTSU5Q48/O4ddLiWWJfotEOxIGZnBtv+yUB uHYVZb+GlOpVyH9uTlwAGJa3qS8nNnlux4VuPCt4jnXLEKkWAIBIwVeBQurG2TF6avi0x H2H7eP3nb2SNasbt78ozQyAAIgbdRCsoJDc9/DLegOK2W6mX70wBaSv2VKAPS+Jqppw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383330; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=T5mlCcYR2P9c+Eaoea59WiT5hE4mxxwkCvVQHOBtC58=; b=5VMLWkZEtHRqVGBFaAxASlY1rbSxxR0UyXJkElAI4HWsccXoq3ZKmAf8LqsgwwQzOcha v8cUKcF/Z4ZN/2ERlW7CPwu8QTw5b0UJXfLrIyB6evkgUQOrvPYQlRhtKX+yo1xN0YVcs GWETz3EDdLQP0rJcrG6ScczjYbBBoFMMYstWF+JaD4SfM5jRWjRrClswCMqytoalKZ5pG kdQrKWGQeQ9s2dAmsfbFVF3855DeieDZU+/24RWayZo9Liew6XGvp0tZbeWT1njZZrJL/ fzsLI0gtlkiZFDcofXQN1tNR0ey+gF/leHsRwIqt75Eq8tNyOL4yF2y7f3u0DbQK7+g== 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="e91ljy/Y"; 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 04593606A322; Fri, 4 Dec 2026 11:22:10 +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=e91ljy/Y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F3B41F000C2; Fri, 4 Dec 2026 11:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796383329; bh=T5mlCcYR2P9c+Eaoea59WiT5hE4mxxwkCvVQHOBtC58=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=e91ljy/YhY6FXQiFJuoeqWFcnqgFSNCbAiLRgNcYIZpdwmp3NHxBJfpVAE983PZjD 6hq4m240ndFVch+AnMziSq1J+dsr8n9jbjeIzixpg2lxUG31RzBLdnEUTdjnLNQuUK /+/iqR7NCrMJkgnc04wvu6f4jwZmF3P6Fr74c5jKlZfAD/tAgSWjnTWGfFMirfsL+l 7rOT66hpvkiiefTmWC3yQ4iDFSsKEOcFnbFY7B1WLlLglXl1Itn9yQAbdD/i8NB1+4 7/8kKG4xJQEXY6m3IQrPMrEGmwOwsQFB0wRCW37+cKKsNEguTJdhoyNu7McuJoWfLA jJxCMs55NZWAQ== Date: Fri, 4 Dec 2026 11:21:59 +0000 From: "Lorenzo Stoakes (ARM)" To: Barry Song Cc: Zicheng Wang , Chuanhua Han , Suren Baghdasaryan , Andrew Morton , linux-mm@kvack.org, tao.wangtao@honor.com, zhangji1@honor.com, Yu Zhao , Kalesh Singh , Kairui Song , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , David Hildenbrand , liam@infradead.org, Vlastimil Babka , Mike Rapoport , Michal Hocko , Pedro Falcato , Jann Horn , Johannes Weiner , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-doc@vger.kernel.org, Matthew Wilcox , Hugh Dickins , Ridong Chen , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 0/5] mm/mglru: walk page tables under per-VMA locks Message-ID: References: <20261201131135.2914944-1-hanchuanhua@xiaomi.com> <20261204103856.71027-1-wangzicheng@honor.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Dec 04, 2026 at 06:43:33PM +0800, Barry Song wrote: > On Fri, Dec 4, 2026 at 6:39 PM Zicheng Wang wrote: > > > > Hi Suren, Chuanhua, Lorenzo, > > > > We hit the same stalls (140-250ms mmap/munmap/mprotect waits on > > SurfaceFlinger and Launcher) and have a measurement that may be > > relevant to the try_lock_next_vma() direction. > > > > In 3 dogfood user traces we picked for this problem, each with janky > > frames over 500ms, a direct reclaim task doing the aging walk holds > > mmap_lock for 140-250ms. Over 99% of that hold is spent runnable, > > waiting to be scheduled; the aging walk itself runs for less than 1ms. > > Each trace has thousands of direct reclaim events inside the jank window. > > > > A finer lock narrows who waits, but not how long. The walker runs with > > preemption enabled while holding the lock, so a round can be preempted > > mid-way and the lock is then held for the whole scheduling delay. > > > > Since the aging walk itself is already fast (<1ms), could we simply > > disable preemption during the walk's lock-hold window instead of > > changing the lock? We are testing a ~60-line prototype (no new lock or API) > > and will send the patch and data separately—mainly wondering whether > > you would prefer bounding that non-preemptible window at PUD or PMD > > granularity. > > Hi Zicheng, > > Disabling preemption for 1 ms is unlikely to fly upstream, as > that's simply too long. Now imagine 200 threads doing direct > reclaim, each in a different memcg. That could result in a > cumulative preemption-disabled time of 200 ms. Yup :) In general we don't disable preemption unless we have to, and in general I think when you look to a solution like this it's typically indicative that the abstraction level of the proposed fix is wrong, i.e. you're asking the wrong question :) IOW this suggests that holding the VMA lock is the right solution. Since (as I gather) Suren is looking to provide try_lock_next_vma() and update the BPF code to reflect this (Suren - let me know if this is accurate), I suggest you wait for this work. Another point to be cautious of here is that a pure-VMA lock walk of VMAs is very fiddly - you control nothing about what the _other_ VMAs are doing i.e. have no stability on that, so you may observe unexpected things in a traversal. Suren has written a lot about this into the VMA lock work around /proc/$pid/maps (in both comments and commit msgs and what is asserted in self tests) so I suggest having a look at that code in the meantime to assess what would need to be taken into account in this approach. -- Cheers, Lorenzo