From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 0724032B99F for ; Wed, 29 Apr 2026 18:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777486808; cv=none; b=kbEefvx62FRsSPi+EnKc5Tje+EwBjYBf4DRufswWANEYULgc+bQUmX0/nH3ALDwQxDZzWRaxkGWnHITpX8BEZyomDiOOwGFQbl3UGhABII00O1EWpZeiSw36oQ8nr1wIQICLIlHmSyjgylB6JQzfGjifWeY+VX+QAAWn2mHQauk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777486808; c=relaxed/simple; bh=+GTbivOW+M0MfDpe1qWwwf3hHWabdB0SE6jBLZ6CPSM=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=Oy8ml/+KKbnREOzd0vZJtYvkikypt8RMpFwP8uh0DGhrCdHWbEccEeKbXHkvqEI4evzvo7oMv4b3RyBWIw34D4slmWNdaIHyf2fu9q7/BniBnNe0K31qf943EMH4c4m46SBeyDj2flyFTHnCe53CIZyhuG/aB3clK1StV0A+GZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Dt4nP5Ke; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Dt4nP5Ke" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777486807; x=1809022807; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=+GTbivOW+M0MfDpe1qWwwf3hHWabdB0SE6jBLZ6CPSM=; b=Dt4nP5KeGJC5Gsy21TuPfUZiPOnYUKhS6lDmvTHaA7cg9Z8vjuycFLIS Zv7mmaaOtABdIWSpXslznTaZCDp/HJwO0bVEfuBIaww4ZMVJjaCjWqHgi 56lof4r5iU2pImJbnAugZtN8UFREPbqQ5G055AkkktCLSKguHyCqvl4/z sJ4fQx52gh0PxayTfCqwi+HrABa8A/tZaFeyFo9y0dukPfwMFzL38l0D3 Sn0UYdqvHacuiXeaHze3rFBebYrnBmpXcHybjMB+4q9XMwZajqGrhAupo 1WB19MdWoev8SVP6WNrOCkYkYYnF4DKcydR3fQ1ehQkzq/43uxRX5QSbO Q==; X-CSE-ConnectionGUID: LHR2j8emSNiPNNyp48OBpQ== X-CSE-MsgGUID: /3HY1D3ARSG5clluFuANbA== X-IronPort-AV: E=McAfee;i="6800,10657,11771"; a="95990134" X-IronPort-AV: E=Sophos;i="6.23,206,1770624000"; d="scan'208";a="95990134" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2026 11:20:06 -0700 X-CSE-ConnectionGUID: /QEVPuNTTE6LY2Xy0HqMUw== X-CSE-MsgGUID: /5JWNQ8AQzSyc14sr4YyRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,206,1770624000"; d="scan'208";a="239336441" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by fmviesa005.fm.intel.com with ESMTP; 29 Apr 2026 11:20:03 -0700 Subject: [PATCH 5/6] tcp: Remove mmap_lock fallback path To: linux-kernel@vger.kernel.org Cc: Dave Hansen , Andrew Morton , "Liam R. Howlett" , linux-mm@kvack.org, Lorenzo Stoakes , Shakeel Butt , Suren Baghdasaryan , Vlastimil Babka From: Dave Hansen Date: Wed, 29 Apr 2026 11:20:02 -0700 References: <20260429181954.F50224AE@davehans-spike.ostc.intel.com> In-Reply-To: <20260429181954.F50224AE@davehans-spike.ostc.intel.com> Message-Id: <20260429182002.BB61C7BC@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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); _