From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22609488D9C for ; Thu, 6 Aug 2026 20:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786046772; cv=none; b=INgzomxkcGQyhZnjiCYtU+xUNYUKndbEiHivrRd1sQQD2V1+37tX/sAbzhtU1h6Xb5Efu0nRyuqVt3D7D7mCThzyoWyaOhFnZDvM+TTuiGSZHRp9P1I9p3tw8/0xZnUHbgFngcipUhRpy9lmrB7TwwHCnTdkQzOJR9BUeVbLG2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786046772; c=relaxed/simple; bh=TPi0HX2ysFtmGcnCVFDQsVS2ZyLYaf8xLB2ebNG9mOI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AJeH1Rq9f+iOkFE8xmI/dYD1gqvx+KQm9ehaG1rgcN6Wp9wt76FORa99WiTtUI9ND7usJj79JxfuA99bgwHZREGv4hYYpOyNJagUk55ZES7EC6uVvNTPcXO3ZJsCzMzZqNHwpUl+xSdgdkBGsP45ONVmOxqg38U8VT3RSrNWiRA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hpS44DOr; arc=none smtp.client-ip=209.85.215.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hpS44DOr" Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-ca124bf0189so1049720a12.0 for ; Thu, 06 Aug 2026 13:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786046763; x=1786651563; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=FBBPYUiw+wGnA3pW6euCqNL/2cPXXNetrkceEEdDJ4M=; b=hpS44DOr2zunUyEdaAMcKvOltrwHWaXiTJjDM3ugaWYV12Svs08N2FpBI3/UYEUV8K 0mNRAwcKNa7czncq/LBMXy5s+/4UrIHvFe5aGRauwaKNMcyRkObJc9i+Lvpz47Mk5Anm +vbtaHitC6Ro2COJrgBabl7YeBiMnl947PIvlnVs8zoMGd9Np/HtUZQ0gzMKZx1A7Ycs CzdArs+E2Qy4LPvpAhCX5Y4+yTe06vafVadghmE4gN2GAcF/E7mAfp2zI7x4d+k+DDlF /fZdz9L+i8pp2dYekpkYYG+x2R7pgR8a8+gaZRCleA7bVXTDlMKD1h1JxOojbdCfsWf9 x9+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786046763; x=1786651563; h=content-transfer-encoding:content-type:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=FBBPYUiw+wGnA3pW6euCqNL/2cPXXNetrkceEEdDJ4M=; b=hip2pIEz19u76hsvHIYJePVF5mf4E1aPOV7HZ5rRVB3KkwORA61F/e6XW8/AiePWtX wFyla4seGCqoJx7c7gQF4PskZf7Ry8azncA9Hcp+Ss09dHVajAkzLYDomAzushAZHiw0 UT9B5YP/Uea10Y3LASBqNO3KjTX3WpnBqwQRPIJdU5NgTXzeae2NRiaSllGpaLOdRK5y 0eUJuozXHe/6dqsp0zNwibTH4tflyM+5RfvG0EzzuLPjkhETgnjDs0gLD1d8vJVevqKI vrkyK9lMAamA6snAxZ5vlT5PMa8I5J5hkw+sN+eGA6d0yCAYH7eEbrFQXppx/1AAFvtM 6uPQ== X-Forwarded-Encrypted: i=1; AHgh+RqIr3mrbZtt2Pqn8hBcD7XxZoRPkkPComen52vxp1ar+iWiGSaEiSNRUnXtDDNFD3XXOdlrjhAEKNdWeAk=@vger.kernel.org X-Gm-Message-State: AOJu0YxD1qQRoSTtY8o7zgH0smbDyqsO8Y/fFgi4Z3IXKQ0VbK4cFX84 +jHYj7Vtcy1qis892iN01tgX0MstwYR34TxcNuQeY0OmvIWSH0ZYfAvsHN/UxYMsCxDxGcQ27w9 Dmawh9A== X-Received: from dlea14-n1.prod.google.com ([2002:a05:701b:420e:10b0:13d:31db:8d94]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:914f:b0:3b3:a66e:3911 with SMTP id adf61e73a8af0-3cb9c2c4782mr8716046637.19.1786046762261; Thu, 06 Aug 2026 13:06:02 -0700 (PDT) Date: Thu, 6 Aug 2026 13:05:48 -0700 In-Reply-To: <20260806200548.3124802-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260806200548.3124802-1-surenb@google.com> X-Mailer: git-send-email 2.55.0.654.g21b8a5bc05-goog Message-ID: <20260806200548.3124802-6-surenb@google.com> Subject: [PATCH v4 5/5] tcp: Remove mmap_lock fallback path From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: dave.hansen@linux.intel.com, Liam.Howlett@oracle.com, ljs@kernel.org, david@kernel.org, willy@infradead.org, shakeel.butt@linux.dev, vbabka@kernel.org, jannh@google.com, aliceryhl@google.com, arve@android.com, cmllamas@google.com, christian@brauner.io, tkjos@android.com, dsahern@kernel.org, davem@davemloft.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, surenb@google.com, syzbot@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. The fallback removal does not affect NOMMU case because TCP_ZEROCOPY is gated on CONFIG_MMU. 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 Signed-off-by: Suren Baghdasaryan Acked-by: Lorenzo Stoakes Acked-by: Vlastimil Babka (SUSE) Tested-by: syzbot@syzkaller.appspotmail.com Cc: Andrew Morton Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Shakeel Butt Cc: linux-mm@kvack.org Cc: Greg Kroah-Hartman Cc: Arve Hj=C3=B8nnev=C3=A5g Cc: Todd Kjos Cc: Christian Brauner Cc: Carlos Llamas Cc: Alice Ryhl Cc: David S. Miller Cc: David Ahern Cc: netdev@vger.kernel.org --- net/ipv4/tcp.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 455441f1b694..62defe70f3ce 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2167,27 +2167,18 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *= sk, } =20 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 =3D lock_vma_under_rcu(mm, address); + struct vm_area_struct *vma =3D vma_start_read_unlocked(mm, address); =20 - if (vma) { - if (vma->vm_ops !=3D &tcp_vm_ops) { - vma_end_read(vma); - return NULL; - } - *mmap_locked =3D false; - return vma; - } + if (!vma) + return NULL; =20 - mmap_read_lock(mm); - vma =3D vma_lookup(mm, address); - if (!vma || vma->vm_ops !=3D &tcp_vm_ops) { - mmap_read_unlock(mm); + if (vma->vm_ops !=3D &tcp_vm_ops) { + vma_end_read(vma); return NULL; } - *mmap_locked =3D true; + return vma; } =20 @@ -2208,7 +2199,6 @@ static int tcp_zerocopy_receive(struct sock *sk, u32 seq =3D tp->copied_seq; u32 total_bytes_to_map; int inq =3D tcp_inq(sk); - bool mmap_locked; int ret; =20 zc->copybuf_len =3D 0; @@ -2233,7 +2223,7 @@ static int tcp_zerocopy_receive(struct sock *sk, return 0; } =20 - vma =3D find_tcp_vma(current->mm, address, &mmap_locked); + vma =3D find_tcp_vma(current->mm, address); if (!vma) return -EINVAL; =20 @@ -2315,10 +2305,7 @@ static int tcp_zerocopy_receive(struct sock *sk, 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 =3D tcp_zc_handle_leftover(zc, sk, skb, &seq, copybuf_len, tss); --=20 2.55.0.654.g21b8a5bc05-goog