From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ECF61262FD0 for ; Fri, 8 May 2026 17:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778261570; cv=none; b=K+QoW7JWs3OJIegeAJqrc3TXXwwQ9Y2EoFSezHsdMhdjSAYL6a+ZH/PeS12xv3MAi0HAzi4QmsWWm9ODWhvU5kgy4aJT1rU6Wyl+ORFINprlTisVhO7/szWkCo/rO4SA/wRO+AzsOSsOZt9myjxY2nZVYOkeT35DrieUcp4IA94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778261570; c=relaxed/simple; bh=CVZ2Lu2w6060hpJnLG6IemuNJfvzKhd0qIeDWWA2eC8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OGG8VVzJNPC5WwxmIJM3PeoQedoiIqTd2TCsrNxfbpwOyhdlJSzcIcQzOM2C3cLneUO89Vud88K6naBdv8ER0ntueyGFj18E0KljtiN5EykNy3TSV9FzOQuH2opGgoOyTi5xyzY5aGVYH3jD7ZIRjbGuFre5fNPXjN79L94mX8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c+eZOWn2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+eZOWn2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 425ADC2BCB0; Fri, 8 May 2026 17:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778261569; bh=CVZ2Lu2w6060hpJnLG6IemuNJfvzKhd0qIeDWWA2eC8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c+eZOWn27yCrRXqrrso0FMm56AyZ5fMd391l5nCDm7XuPy9LJJevh3Ygcp5cf0PyV NRFjJnjpx8tUoC5v4HShthRJDS6n4To0KMQVYN/bX99A7LupxrjRV0aAReO0Qiamiw k0bcNNlzhQFg+o2bjXfjdErp45eaFO9YrZZ8X4fERe56pU9KlJuIFnbE9g0Sxn1au0 F7Vk5tV0YsedgoRvaxYFTawECW3gc+gaOdh9tvVO6NroGj1AI0t8OT1zXPTUrMDDjs z9pPq4WKqn1921SQxdegO2XGen7oF2reAeCB3qpiHe8U2EwngCcUhMqEUruzoSV8/a eTh1V3Siz8xxg== Date: Fri, 8 May 2026 18:32:43 +0100 From: Lorenzo Stoakes To: Dave Hansen Cc: linux-kernel@vger.kernel.org, Andrew Morton , "Liam R. Howlett" , linux-mm@kvack.org, Shakeel Butt , Suren Baghdasaryan , Vlastimil Babka Subject: Re: [PATCH 5/6] tcp: Remove mmap_lock fallback path Message-ID: References: <20260429181954.F50224AE@davehans-spike.ostc.intel.com> <20260429182002.BB61C7BC@davehans-spike.ostc.intel.com> 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: <20260429182002.BB61C7BC@davehans-spike.ostc.intel.com> On Wed, Apr 29, 2026 at 11:20:02AM -0700, Dave Hansen wrote: > > From: Dave Hansen > > Previously, the per-VMA locking could fail in the face of writers > which necessitates a fallback to mmap_lock. The new > lock_vma_under_rcu_wait() will wait for writers instead of failing. > > Use the new helper. Wait for writers. Remove the fallback to mmap_lock. > > This really is a nice cleanup. It removes the need to pass the lock > state back and forth to find_tcp_vma(). > > Signed-off-by: Dave Hansen Yeah, LGTM again, though am not a networking guy so: Acked-by: Lorenzo Stoakes > Cc: Suren Baghdasaryan > Cc: Andrew Morton > Cc: "Liam R. Howlett" > Cc: Lorenzo Stoakes > Cc: Vlastimil Babka > Cc: Shakeel Butt > Cc: linux-mm@kvack.org > --- > > b/net/ipv4/tcp.c | 31 +++++++++---------------------- > 1 file changed, 9 insertions(+), 22 deletions(-) > > diff -puN net/ipv4/tcp.c~ipv4-tcp-vma-waiter net/ipv4/tcp.c > --- a/net/ipv4/tcp.c~ipv4-tcp-vma-waiter 2026-04-29 11:18:51.870676498 -0700 > +++ b/net/ipv4/tcp.c 2026-04-29 11:18:51.874676652 -0700 > @@ -2171,27 +2171,18 @@ static void tcp_zc_finalize_rx_tstamp(st > } > > static struct vm_area_struct *find_tcp_vma(struct mm_struct *mm, > - unsigned long address, > - bool *mmap_locked) > + unsigned long address) > { > - struct vm_area_struct *vma = lock_vma_under_rcu(mm, address); > + struct vm_area_struct *vma = lock_vma_under_rcu_wait(mm, address); > > - if (vma) { > - if (vma->vm_ops != &tcp_vm_ops) { > - vma_end_read(vma); > - return NULL; > - } > - *mmap_locked = false; > - return vma; > - } > + if (!vma) > + return NULL; > > - mmap_read_lock(mm); > - vma = vma_lookup(mm, address); > - if (!vma || vma->vm_ops != &tcp_vm_ops) { > - mmap_read_unlock(mm); > + if (vma->vm_ops != &tcp_vm_ops) { > + vma_end_read(vma); > return NULL; > } > - *mmap_locked = true; > + > return vma; > } > > @@ -2212,7 +2203,6 @@ static int tcp_zerocopy_receive(struct s > u32 seq = tp->copied_seq; > u32 total_bytes_to_map; > int inq = tcp_inq(sk); > - bool mmap_locked; > int ret; > > zc->copybuf_len = 0; > @@ -2237,7 +2227,7 @@ static int tcp_zerocopy_receive(struct s > return 0; > } > > - vma = find_tcp_vma(current->mm, address, &mmap_locked); > + vma = find_tcp_vma(current->mm, address); > if (!vma) > return -EINVAL; > > @@ -2319,10 +2309,7 @@ static int tcp_zerocopy_receive(struct s > zc, total_bytes_to_map); > } > out: > - if (mmap_locked) > - mmap_read_unlock(current->mm); > - else > - vma_end_read(vma); > + vma_end_read(vma); > /* Try to copy straggler data. */ > if (!ret) > copylen = tcp_zc_handle_leftover(zc, sk, skb, &seq, copybuf_len, tss); > _