From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1757B3C661A; Wed, 20 May 2026 12:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779281770; cv=none; b=PUyc5l0cdqjK7Sq3yJtdlRgYu8hkzMgHRj+W/fq6bbookRVuGcqTmXQsoagP5QMCtk7WMylsiz1TfMDXV60gpg32R3GB5BH5FZunFGJvCYDUmDmF8/crHDtjPjasD85ZyrDwJPjOurns5peY3HWDrgzrrZA+STk5i3bV0cwk/uM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779281770; c=relaxed/simple; bh=ehjp2pyKA5Vmb1tl80rzsbvCFR/pkm4mxPnsNK2uQRw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dr4YbRoIhD0Yld979/OqpVK/5viDElb79oUOuOUg/JgWwWA5rC0y/5GAw27/zIuxwFmZTqkrekMjUkLvyqFv0FFzXo8erNrH4pgcncKtLLsluealKkm+kCF6gIjZBngqm6if1xbn8orYfxA2bYqGZuoZhuKq/9N0yl4etSIWMFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=odw+ysF2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="odw+ysF2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 195301F000E9; Wed, 20 May 2026 12:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779281768; bh=IHcIhsCGtp+zFimfYJhlVXiifBlHPpWiDOsOVHQEJSk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=odw+ysF2fSGs0CYgREQtSvLkA7C1vnjLq+yTGH8uUyZQL5gIwy8l0sgOhMQFrvR/U uhiwWUqoaRwvkgB0dpBHlc/BUJ1q5+UUOAqod11j8iXpTYoTcMdKWbeJzuR6xMAqQ+ OvTmgxH6iYYQP1hB8J7APtE6URdQBmktp1g/AVzlcWRxqXXJ8L/XVRnaqQo7zC7Xng ETzTvLZhkt1SvKxjfJTjvTYcMABci75fb1o2/YPfIpAPbJkiRERe++WMYYQiw7kmc/ 0b+T91xT73D5pkQltTZRR+EMWtVC4246AhUUcvutCmfPfiXeX8053NtPz89QYDfQc2 xRaHqWoL1+79g== Date: Wed, 20 May 2026 13:55:58 +0100 From: Lorenzo Stoakes To: "David Hildenbrand (Arm)" Cc: Suren Baghdasaryan , Barry Song , Matthew Wilcox , akpm@linux-foundation.org, linux-mm@kvack.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com, jack@suse.cz, pfalcato@suse.de, wanglian@kylinos.cn, chentao@kylinos.cn, lianux.mm@gmail.com, kunwu.chan@gmail.com, liyangouwen1@oppo.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, youngjun.park@lge.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Nanzhe Zhao Subject: Re: [PATCH v2 0/5] mm: reduce mmap_lock contention and improve page fault performance Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, May 20, 2026 at 12:33:56PM +0200, David Hildenbrand (Arm) wrote: > On 5/19/26 14:53, Lorenzo Stoakes wrote: > > On Mon, May 18, 2026 at 12:56:59PM -0700, Suren Baghdasaryan wrote: > > > >>> > >>> I think we either need to fix `fork()`, or keep the current > >>> behavior of dropping the VMA lock before performing I/O. > >> > >> I see. So, this problem arises from the fact that we are changing the > >> pagefaults requiring I/O operation to hold VMA lock... > >> And you want to lock VMA on fork only if vma_is_anonymous(vma) || > >> is_cow_mapping(vma->vm_flags). So, we will be blocking page faults for > >> anonymous and COW VMAs only while holding mmap_write_lock, preventing > >> any VMA modification. On the surface, that looks ok to me but I might > >> be missing some corner cases. If nobody sees any obvious issues, I > >> think it's worth a try. > > > > Not sure if you noticed but I did raise concerns ;) > > > > I wonder if you've confused the fault path and fork here, as I think Barry has > > been a little unclear on that. > > > > What's being suggested in this thread is to fundamentally change fork behaviour > > so it's different from the entire history of the kernel (or - presumably - at > > least recent history :) > I don't want fork() to become different in that regard. > > There is already a slight difference with vs. without per-VMA locks, because > there is a window in-between us taking the write mmap_lock and all the per-VMA > locks. I raised that previously [1] and assumed that it is probably fine. > > I also raised in the past why I think we must not allow concurrent page faults, > at least as soon as anonymous memory is involved [2]. > > ... and I raised that this is pretty much slower by design right now: "Well, the > design decision that CONFIG_PER_VMA_LOCK made for now to make page faults fast > and to make blocking any page faults from happening to be slower ..." [3] Thanks for the background will read through! :) But yeah I think the transition from !vma->anon_vma -> vma->anon_vma being a bit slow is kinda ok most page faults will of course have anon_vma populated. Be interesting with CoW context, because we won't need to mmap read lock there at all :) > > [1] https://lore.kernel.org/all/970295ab-e85d-7af3-76e6-df53a5c52f8b@redhat.com/ > [2] https://lore.kernel.org/all/7e3f35cc-59b9-bf12-b8b1-4ed78223844a@redhat.com/ > [3] https://lore.kernel.org/all/2efa2c89-3765-721d-2c3c-00590054aa5b@redhat.com/ > > -- > Cheers, > > David Cheers, Lorenzo From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A568CD4F3C for ; Wed, 20 May 2026 12:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TbSk3lLbJQbz4PIPplHctl8xAprp5Ty351KB9Z9n+t0=; b=3rn4GaAB8AIhFm JFnhCSeHQZUrew7KPPWHFyp7NIxbaoFk5KVParKkQfZPvGUzZcRfgXGQ5lPVgj+I5fwGx/9BKiNuY q1M8/9pflfltgMdLpULGQpyxQSnzDA6ECfeBgRqsZkUAOl+kycGMI71m8jCjZIjcg4DNQRzjk/odE 5ZJwlSkbFI62I+Ru+XDrKBCL8E1G8kcrui/oCPtZysfDJOWqb75RJlEZMT9AMypkVNjsxsEYN2F9D Rf3bkC3CzxBEJKC5bqc+B2F10qnfaliogkpASJHXQFUqt+K9ILFDJK9vDer6XXWEEYpmE1R29a+Bg +x5xpRV9eyMoRaJvyYbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wPgT7-00000004cRX-0nYQ; Wed, 20 May 2026 12:56:13 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wPgT3-00000004cQE-3snd; Wed, 20 May 2026 12:56:11 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C1BEF4184E; Wed, 20 May 2026 12:56:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 195301F000E9; Wed, 20 May 2026 12:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779281768; bh=IHcIhsCGtp+zFimfYJhlVXiifBlHPpWiDOsOVHQEJSk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=odw+ysF2fSGs0CYgREQtSvLkA7C1vnjLq+yTGH8uUyZQL5gIwy8l0sgOhMQFrvR/U uhiwWUqoaRwvkgB0dpBHlc/BUJ1q5+UUOAqod11j8iXpTYoTcMdKWbeJzuR6xMAqQ+ OvTmgxH6iYYQP1hB8J7APtE6URdQBmktp1g/AVzlcWRxqXXJ8L/XVRnaqQo7zC7Xng ETzTvLZhkt1SvKxjfJTjvTYcMABci75fb1o2/YPfIpAPbJkiRERe++WMYYQiw7kmc/ 0b+T91xT73D5pkQltTZRR+EMWtVC4246AhUUcvutCmfPfiXeX8053NtPz89QYDfQc2 xRaHqWoL1+79g== Date: Wed, 20 May 2026 13:55:58 +0100 From: Lorenzo Stoakes To: "David Hildenbrand (Arm)" Cc: Suren Baghdasaryan , Barry Song , Matthew Wilcox , akpm@linux-foundation.org, linux-mm@kvack.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com, jack@suse.cz, pfalcato@suse.de, wanglian@kylinos.cn, chentao@kylinos.cn, lianux.mm@gmail.com, kunwu.chan@gmail.com, liyangouwen1@oppo.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, youngjun.park@lge.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Nanzhe Zhao Subject: Re: [PATCH v2 0/5] mm: reduce mmap_lock contention and improve page fault performance Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260520_055610_014858_CAB80005 X-CRM114-Status: GOOD ( 26.81 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Wed, May 20, 2026 at 12:33:56PM +0200, David Hildenbrand (Arm) wrote: > On 5/19/26 14:53, Lorenzo Stoakes wrote: > > On Mon, May 18, 2026 at 12:56:59PM -0700, Suren Baghdasaryan wrote: > > > >>> > >>> I think we either need to fix `fork()`, or keep the current > >>> behavior of dropping the VMA lock before performing I/O. > >> > >> I see. So, this problem arises from the fact that we are changing the > >> pagefaults requiring I/O operation to hold VMA lock... > >> And you want to lock VMA on fork only if vma_is_anonymous(vma) || > >> is_cow_mapping(vma->vm_flags). So, we will be blocking page faults for > >> anonymous and COW VMAs only while holding mmap_write_lock, preventing > >> any VMA modification. On the surface, that looks ok to me but I might > >> be missing some corner cases. If nobody sees any obvious issues, I > >> think it's worth a try. > > > > Not sure if you noticed but I did raise concerns ;) > > > > I wonder if you've confused the fault path and fork here, as I think Barry has > > been a little unclear on that. > > > > What's being suggested in this thread is to fundamentally change fork behaviour > > so it's different from the entire history of the kernel (or - presumably - at > > least recent history :) > I don't want fork() to become different in that regard. > > There is already a slight difference with vs. without per-VMA locks, because > there is a window in-between us taking the write mmap_lock and all the per-VMA > locks. I raised that previously [1] and assumed that it is probably fine. > > I also raised in the past why I think we must not allow concurrent page faults, > at least as soon as anonymous memory is involved [2]. > > ... and I raised that this is pretty much slower by design right now: "Well, the > design decision that CONFIG_PER_VMA_LOCK made for now to make page faults fast > and to make blocking any page faults from happening to be slower ..." [3] Thanks for the background will read through! :) But yeah I think the transition from !vma->anon_vma -> vma->anon_vma being a bit slow is kinda ok most page faults will of course have anon_vma populated. Be interesting with CoW context, because we won't need to mmap read lock there at all :) > > [1] https://lore.kernel.org/all/970295ab-e85d-7af3-76e6-df53a5c52f8b@redhat.com/ > [2] https://lore.kernel.org/all/7e3f35cc-59b9-bf12-b8b1-4ed78223844a@redhat.com/ > [3] https://lore.kernel.org/all/2efa2c89-3765-721d-2c3c-00590054aa5b@redhat.com/ > > -- > Cheers, > > David Cheers, Lorenzo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv