From nobody Thu Mar 28 21:45:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:a689:0:0:0:0:0 with SMTP id j9csp579910jam; Wed, 22 Sep 2021 10:27:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNtX+Xh/sPGaBRGd6TLBu0J3Iov+aAEFrEUJKx87aC/2S72pC3n6OPDLtCVqo9kDZmdSTo X-Received: by 2002:a17:90b:791:: with SMTP id l17mr159083pjz.155.1632331626016; Wed, 22 Sep 2021 10:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632331626; cv=none; d=google.com; s=arc-20160816; b=QpxuDoIIWwFTKBAdAlmPlok1Zgvsd1yqtt76PmAEijgJcju7HFfbyzbIIovPz2CzOj JEkQxdLtAgNUKKMz0rzc0LbkZS/R6yjbO2i8a+O4nsDvwC00/DEYcDm3+2ofh+W+PoMI oNud45bfqjGsSHHl5TTqfm4RJCUo7LkAfoetzngB+WQkIlB82ui943uP2hCexfqeUeXA SM9ZPvWqWI7p//sNJZG3Ftp/xKBDebiG2q7zcKOeKH98Nl4TipnmMRBAbUZD1n+fdlDR 3VBO2xZ8FO4aYrF5cboPLgmy6WTROBbl85G8txemBetUNJO+kcK0jnfttZWMVP7VzQBR YUoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ocBV2wXfiOTn1O2w09aLkS14Tww2/enRy19+rxA+SrQ=; b=auS3WboWODK70IuYt6L3rlGwxO9zoY8Z4XOWkKRGwGRWFS610iWcBt6xxhi0hklbmL hwi0e9/TAnYJQZxMXwTd9cvR//4Jecgv3srNNrR3rKhcktM/dYBODVhWqJ5kdGLEERYM g/iXh4oJy6oEAcGD5aQPlCI0xPJ+7mOjzM/9NYFqA8ybfFkbhYNC8tz63alM78Jjth6o 339WSnoVjiTrmJKI9OIHPcF68V+/+LoYz3JhjGE5ba53LAzHZZn5hq/AHsxDmsfYYYZE d2mV0beORGQYfKi+fGJw/FOzv9Taer8RzhoT26yB55YlFsEloM/h9cNDO1TVgtBlHXqX X57A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DqPSD1us; spf=pass (google.com: domain of mptcp+bounces-2015-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2015-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id w18si3765329pff.198.2021.09.22.10.27.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Sep 2021 10:27:06 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-2015-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DqPSD1us; spf=pass (google.com: domain of mptcp+bounces-2015-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2015-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sjc.edge.kernel.org (Postfix) with ESMTPS id 4E4423E0EA0 for ; Wed, 22 Sep 2021 17:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EE33FCE; Wed, 22 Sep 2021 17:27:04 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (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 29D8E3FCB for ; Wed, 22 Sep 2021 17:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632331622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ocBV2wXfiOTn1O2w09aLkS14Tww2/enRy19+rxA+SrQ=; b=DqPSD1usAhK2wGQaS5+PxB6ptvZuNdTr8e/0OVDNFx1v6+qxERZ4jLUEeLp8gbXtRZtkOj fKYkNKHoc1Z8Ffk3hs9HZ4Widj60Y/cK1YTP/6zdqaWkqLOYY3qINrnvi08GtVG+8WLuAa CHrEOcGnOZL8iMs0x3qvZ77xkKYwfnM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-yBKxnveKPI-3xBWZUA5Fsg-1; Wed, 22 Sep 2021 13:27:00 -0400 X-MC-Unique: yBKxnveKPI-3xBWZUA5Fsg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AD6210151E1; Wed, 22 Sep 2021 17:26:59 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CED019724; Wed, 22 Sep 2021 17:26:57 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Mat Martineau , Eric Dumazet , mptcp@lists.linux.dev Subject: [PATCH net-next 1/4] tcp: expose the tcp_mark_push() and tcp_skb_entail() helpers Date: Wed, 22 Sep 2021 19:26:40 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Type: text/plain; charset="utf-8" the tcp_skb_entail() helper is actually skb_entail(), renamed to provide proper scope. The two helper will be used by the next patch. RFC -> v1: - rename skb_entail to tcp_skb_entail (Eric) Acked-by: Mat Martineau Signed-off-by: Paolo Abeni Reviewed-by: Eric Dumazet --- include/net/tcp.h | 2 ++ net/ipv4/tcp.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 3166dc15d7d6..4a96f6e0f6f8 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -581,6 +581,8 @@ __u32 cookie_v6_init_sequence(const struct sk_buff *skb= , __u16 *mss); #endif /* tcp_output.c */ =20 +void tcp_skb_entail(struct sock *sk, struct sk_buff *skb); +void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb); void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, int nonagle); int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e8b48df73c85..c592454625e1 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -647,7 +647,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long a= rg) } EXPORT_SYMBOL(tcp_ioctl); =20 -static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) +void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) { TCP_SKB_CB(skb)->tcp_flags |=3D TCPHDR_PSH; tp->pushed_seq =3D tp->write_seq; @@ -658,7 +658,7 @@ static inline bool forced_push(const struct tcp_sock *t= p) return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1)); } =20 -static void skb_entail(struct sock *sk, struct sk_buff *skb) +void tcp_skb_entail(struct sock *sk, struct sk_buff *skb) { struct tcp_sock *tp =3D tcp_sk(sk); struct tcp_skb_cb *tcb =3D TCP_SKB_CB(skb); @@ -985,7 +985,7 @@ struct sk_buff *tcp_build_frag(struct sock *sk, int siz= e_goal, int flags, #ifdef CONFIG_TLS_DEVICE skb->decrypted =3D !!(flags & MSG_SENDPAGE_DECRYPTED); #endif - skb_entail(sk, skb); + tcp_skb_entail(sk, skb); copy =3D size_goal; } =20 @@ -1314,7 +1314,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr= *msg, size_t size) process_backlog++; skb->ip_summed =3D CHECKSUM_PARTIAL; =20 - skb_entail(sk, skb); + tcp_skb_entail(sk, skb); copy =3D size_goal; =20 /* All packets are restored as if they have --=20 2.26.3 From nobody Thu Mar 28 21:45:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:a689:0:0:0:0:0 with SMTP id j9csp579940jam; Wed, 22 Sep 2021 10:27:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4jjwC0PxwlNXRI9rv/N08nrukTnN8Qp2ZHUMVUVL9hdgCj79yAgQHtuk0oxkyZMt1kQT/ X-Received: by 2002:a05:620a:916:: with SMTP id v22mr420673qkv.338.1632331628335; Wed, 22 Sep 2021 10:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632331628; cv=none; d=google.com; s=arc-20160816; b=jdnEMLR7y1jZcWybZGXE/nu4+qNjeYr2QoqNh0b3YUo1j056tjABXewYep74J0xON3 hMqC3ybXIuDzNEEqk667E9o/8COsPBa2Xu+1oaoKw9H82P82XzegcbleRwk+9NZbvgn2 i8CbCz0cXbE4HBjXHUNKtBYW5mwRcpCSXo4+3v4dbqiTgmBI0D/A1Kmk0Olbu8cZnc3B Wa+/A3OjSHsjJwXXgY3553lGgBtH3qAWagF7KcgmcabNAfxQU/2DDrGilemn87d8S4Hm cANe2mnpqUy/q0sxSJAPJrrb+z40Qf8iByhN+kgLL3yjE875nuZW4PYapUuWbhZVaQ9b 6nkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M07wprL0X3f7HruIFF/SqWbzyeUsqMkXranvpz3WQoE=; b=xttDzlxoiZY9lk8+/Gw6jn4MZewv0/F5JILP4OwMlMW0W3Oqv/Vf3KyaMrSHpPQA7C VMgEiMJ01FG4IF/ybXZ9PsZDejDKSmfuGKtSRZX2JByF4h07ohv287EABqydy1zNCoOr iraBQQ9psI8e8LP1KlbrpjPVbePNfBe/IwLXlW+nWkEb4jXeact/lBXF8f8jeVFFHHzL H0230v7C3p4dT48KuI/PGE2CybfZY+fQcT+2zp75YNmQqDFF3aByJlWery4YHgOzFWD1 8z+PxU0fKIeqVMqKoQyWb8I8MQfSTKlJvaljXS2OfJmxDsMTEA87a0DjgmTak5R10S7R fioA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfVojZaf; spf=pass (google.com: domain of mptcp+bounces-2017-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2017-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [2604:1380:1:3600::1]) by mx.google.com with ESMTPS id n12si2186891qta.116.2021.09.22.10.27.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Sep 2021 10:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-2017-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) client-ip=2604:1380:1:3600::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YfVojZaf; spf=pass (google.com: domain of mptcp+bounces-2017-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2017-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ewr.edge.kernel.org (Postfix) with ESMTPS id E65301C03D2 for ; Wed, 22 Sep 2021 17:27:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FB1E3FD0; Wed, 22 Sep 2021 17:27:06 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (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 F13223FCD for ; Wed, 22 Sep 2021 17:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632331624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M07wprL0X3f7HruIFF/SqWbzyeUsqMkXranvpz3WQoE=; b=YfVojZafsEm2fEsowUfqV/AALVBzWwXpj0BO7cZd4DWT66mOiK4qHTvLsYge54rocF9/wY yJbwRY8J0jrwZbMYSZCmezly6GcabcnsKSl6uftpR1ss4z1ZAf5na82i/LhnAvxOHIL94y Tp9cxgj2WPlAl+n0Lkgw09tZfaYL+JU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-123-9SsQ3LRRPs6POAjkeAG6og-1; Wed, 22 Sep 2021 13:27:02 -0400 X-MC-Unique: 9SsQ3LRRPs6POAjkeAG6og-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58F051006AA3; Wed, 22 Sep 2021 17:27:01 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEB4919733; Wed, 22 Sep 2021 17:26:59 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Mat Martineau , Eric Dumazet , mptcp@lists.linux.dev Subject: [PATCH net-next 2/4] mptcp: stop relying on tcp_tx_skb_cache Date: Wed, 22 Sep 2021 19:26:41 +0200 Message-Id: <7507d77018397cff4238b4b058dd770197078c82.1632318035.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Type: text/plain; charset="utf-8" We want to revert the skb TX cache, but MPTCP is currently using it unconditionally. Rework the MPTCP tx code, so that tcp_tx_skb_cache is not needed anymore: do the whole coalescing check, skb allocation skb initialization/update inside mptcp_sendmsg_frag(), quite alike the current TCP code. Reviewed-by: Mat Martineau Signed-off-by: Paolo Abeni --- net/mptcp/protocol.c | 137 ++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 60 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index dbcebf56798f..7e5f76092b64 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1224,6 +1224,7 @@ static struct sk_buff *__mptcp_do_alloc_tx_skb(struct= sock *sk, gfp_t gfp) if (likely(__mptcp_add_ext(skb, gfp))) { skb_reserve(skb, MAX_TCP_HEADER); skb->reserved_tailroom =3D skb->end - skb->tail; + INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); return skb; } __kfree_skb(skb); @@ -1233,31 +1234,23 @@ static struct sk_buff *__mptcp_do_alloc_tx_skb(stru= ct sock *sk, gfp_t gfp) return NULL; } =20 -static bool __mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk, gfp_t = gfp) +static struct sk_buff *__mptcp_alloc_tx_skb(struct sock *sk, struct sock *= ssk, gfp_t gfp) { struct sk_buff *skb; =20 - if (ssk->sk_tx_skb_cache) { - skb =3D ssk->sk_tx_skb_cache; - if (unlikely(!skb_ext_find(skb, SKB_EXT_MPTCP) && - !__mptcp_add_ext(skb, gfp))) - return false; - return true; - } - skb =3D __mptcp_do_alloc_tx_skb(sk, gfp); if (!skb) - return false; + return NULL; =20 if (likely(sk_wmem_schedule(ssk, skb->truesize))) { - ssk->sk_tx_skb_cache =3D skb; - return true; + tcp_skb_entail(ssk, skb); + return skb; } kfree_skb(skb); - return false; + return NULL; } =20 -static bool mptcp_alloc_tx_skb(struct sock *sk, struct sock *ssk, bool dat= a_lock_held) +static struct sk_buff *mptcp_alloc_tx_skb(struct sock *sk, struct sock *ss= k, bool data_lock_held) { gfp_t gfp =3D data_lock_held ? GFP_ATOMIC : sk->sk_allocation; =20 @@ -1287,23 +1280,29 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, struct mptcp_sendmsg_info *info) { u64 data_seq =3D dfrag->data_seq + info->sent; + int offset =3D dfrag->offset + info->sent; struct mptcp_sock *msk =3D mptcp_sk(sk); bool zero_window_probe =3D false; struct mptcp_ext *mpext =3D NULL; - struct sk_buff *skb, *tail; - bool must_collapse =3D false; - int size_bias =3D 0; - int avail_size; - size_t ret =3D 0; + bool can_coalesce =3D false; + bool reuse_skb =3D true; + struct sk_buff *skb; + size_t copy; + int i; =20 pr_debug("msk=3D%p ssk=3D%p sending dfrag at seq=3D%llu len=3D%u already = sent=3D%u", msk, ssk, dfrag->data_seq, dfrag->data_len, info->sent); =20 + if (WARN_ON_ONCE(info->sent > info->limit || + info->limit > dfrag->data_len)) + return 0; + /* compute send limit */ info->mss_now =3D tcp_send_mss(ssk, &info->size_goal, info->flags); - avail_size =3D info->size_goal; + copy =3D info->size_goal; + skb =3D tcp_write_queue_tail(ssk); - if (skb) { + if (skb && copy > skb->len) { /* Limit the write to the size available in the * current skb, if any, so that we create at most a new skb. * Explicitly tells TCP internals to avoid collapsing on later @@ -1316,62 +1315,80 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, goto alloc_skb; } =20 - must_collapse =3D (info->size_goal > skb->len) && - (skb_shinfo(skb)->nr_frags < sysctl_max_skb_frags); - if (must_collapse) { - size_bias =3D skb->len; - avail_size =3D info->size_goal - skb->len; + i =3D skb_shinfo(skb)->nr_frags; + can_coalesce =3D skb_can_coalesce(skb, i, dfrag->page, offset); + if (!can_coalesce && i >=3D sysctl_max_skb_frags) { + tcp_mark_push(tcp_sk(ssk), skb); + goto alloc_skb; } - } =20 + copy -=3D skb->len; + } else { alloc_skb: - if (!must_collapse && - !mptcp_alloc_tx_skb(sk, ssk, info->data_lock_held)) - return 0; + skb =3D mptcp_alloc_tx_skb(sk, ssk, info->data_lock_held); + if (!skb) + return -ENOMEM; + + i =3D skb_shinfo(skb)->nr_frags; + reuse_skb =3D false; + mpext =3D skb_ext_find(skb, SKB_EXT_MPTCP); + } =20 /* Zero window and all data acked? Probe. */ - avail_size =3D mptcp_check_allowed_size(msk, data_seq, avail_size); - if (avail_size =3D=3D 0) { + copy =3D mptcp_check_allowed_size(msk, data_seq, copy); + if (copy =3D=3D 0) { u64 snd_una =3D READ_ONCE(msk->snd_una); =20 - if (skb || snd_una !=3D msk->snd_nxt) + if (snd_una !=3D msk->snd_nxt) { + tcp_remove_empty_skb(ssk, tcp_write_queue_tail(ssk)); return 0; + } + zero_window_probe =3D true; data_seq =3D snd_una - 1; - avail_size =3D 1; - } + copy =3D 1; =20 - if (WARN_ON_ONCE(info->sent > info->limit || - info->limit > dfrag->data_len)) - return 0; + /* all mptcp-level data is acked, no skbs should be present into the + * ssk write queue + */ + WARN_ON_ONCE(reuse_skb); + } =20 - ret =3D info->limit - info->sent; - tail =3D tcp_build_frag(ssk, avail_size + size_bias, info->flags, - dfrag->page, dfrag->offset + info->sent, &ret); - if (!tail) { - tcp_remove_empty_skb(sk, tcp_write_queue_tail(ssk)); + copy =3D min_t(size_t, copy, info->limit - info->sent); + if (!sk_wmem_schedule(ssk, copy)) { + tcp_remove_empty_skb(ssk, tcp_write_queue_tail(ssk)); return -ENOMEM; } =20 - /* if the tail skb is still the cached one, collapsing really happened. - */ - if (skb =3D=3D tail) { - TCP_SKB_CB(tail)->tcp_flags &=3D ~TCPHDR_PSH; - mpext->data_len +=3D ret; + if (can_coalesce) { + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); + } else { + get_page(dfrag->page); + skb_fill_page_desc(skb, i, dfrag->page, offset, copy); + } + + skb->len +=3D copy; + skb->data_len +=3D copy; + skb->truesize +=3D copy; + sk_wmem_queued_add(ssk, copy); + sk_mem_charge(ssk, copy); + skb->ip_summed =3D CHECKSUM_PARTIAL; + WRITE_ONCE(tcp_sk(ssk)->write_seq, tcp_sk(ssk)->write_seq + copy); + TCP_SKB_CB(skb)->end_seq +=3D copy; + tcp_skb_pcount_set(skb, 0); + + /* on skb reuse we just need to update the DSS len */ + if (reuse_skb) { + TCP_SKB_CB(skb)->tcp_flags &=3D ~TCPHDR_PSH; + mpext->data_len +=3D copy; WARN_ON_ONCE(zero_window_probe); goto out; } =20 - mpext =3D skb_ext_find(tail, SKB_EXT_MPTCP); - if (WARN_ON_ONCE(!mpext)) { - /* should never reach here, stream corrupted */ - return -EINVAL; - } - memset(mpext, 0, sizeof(*mpext)); mpext->data_seq =3D data_seq; mpext->subflow_seq =3D mptcp_subflow_ctx(ssk)->rel_write_seq; - mpext->data_len =3D ret; + mpext->data_len =3D copy; mpext->use_map =3D 1; mpext->dsn64 =3D 1; =20 @@ -1380,18 +1397,18 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, mpext->dsn64); =20 if (zero_window_probe) { - mptcp_subflow_ctx(ssk)->rel_write_seq +=3D ret; + mptcp_subflow_ctx(ssk)->rel_write_seq +=3D copy; mpext->frozen =3D 1; if (READ_ONCE(msk->csum_enabled)) - mptcp_update_data_checksum(tail, ret); + mptcp_update_data_checksum(skb, copy); tcp_push_pending_frames(ssk); return 0; } out: if (READ_ONCE(msk->csum_enabled)) - mptcp_update_data_checksum(tail, ret); - mptcp_subflow_ctx(ssk)->rel_write_seq +=3D ret; - return ret; + mptcp_update_data_checksum(skb, copy); + mptcp_subflow_ctx(ssk)->rel_write_seq +=3D copy; + return copy; } =20 #define MPTCP_SEND_BURST_SIZE ((1 << 16) - \ --=20 2.26.3 From nobody Thu Mar 28 21:45:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:a689:0:0:0:0:0 with SMTP id j9csp579959jam; Wed, 22 Sep 2021 10:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvvtOuxaTbUsPDepIaOCD6pDQrz2woK5+WYXA8ksujMNls0dXo5yoon3zL/rkDl79jvJbA X-Received: by 2002:a37:b686:: with SMTP id g128mr437807qkf.68.1632331629511; Wed, 22 Sep 2021 10:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632331629; cv=none; d=google.com; s=arc-20160816; b=vFlhyl9zsMdpeqO1K7MtwPEmQoI9LwrcM7I0YBto4KLnA8KuHitK/B3JdLFp81RmAm o6plwO9mBcAueuUxRqgqkpAIjwwJ/xyxtoFpYYwn/vXxSX6BSYcA9yQuBuB0rk543Rlg LyxWT/z6TayxMQDYRORnJFjjTP6E4n+RVvkn2kf0sB7kBkjtUO1LZIXRUVDmRKYw/R9q gx2qgV4Dds7lRXfvGLstGtY00PK/945GNyjgoTtPvz3VHsuz+W8lhYtClTuJJwHGDwgR 9DXRLaRE46k0hHgWOKCduWd7oXV/24UaKsa+i++C+SAJ7rw0MRpKW0sNAakS2zQCdexE R60Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=N8nuT0dVHQfNFFHpAtAf7gLVW6Ovil5Qtijg6ZCY4K0=; b=GYczgeTUGz9i9Pr5G50aLvZh9zRarbdzg5WoLqhj3GFAiOwOaHo86CpncwW0esXYd6 XUSwhJTEfwJ27+dT0blc7BIv8O40MvDC7vqsLHmROwfQPZTjQiCfIH58+KyfHIykQ9l/ 8iYO21oCXo3T9Z7/OkiZi7koLVICTnavALUFNffHJqLEx6gVA557TcmcV55CdiLbPSpG akRk/vwgwghwQ8x+JWthVmAxuDYxqk0Wec8GRfeQDYt1Dw9O32aP7zGbmtZVqDHo+aIa WguD3saeVF/YIG6REahWJwLzP+6+fRrp0RQoq1pc27+4Iv1S1qfUgXaCaVJAOrr5EjRG 3uTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dfF5TdX2; spf=pass (google.com: domain of mptcp+bounces-2018-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2018-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [2604:1380:1:3600::1]) by mx.google.com with ESMTPS id w24si241229qki.263.2021.09.22.10.27.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Sep 2021 10:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-2018-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) client-ip=2604:1380:1:3600::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dfF5TdX2; spf=pass (google.com: domain of mptcp+bounces-2018-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1:3600::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2018-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ewr.edge.kernel.org (Postfix) with ESMTPS id 3D3531C0A68 for ; Wed, 22 Sep 2021 17:27:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B75343FCB; Wed, 22 Sep 2021 17:27:07 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 B9BD23FCD for ; Wed, 22 Sep 2021 17:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632331625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N8nuT0dVHQfNFFHpAtAf7gLVW6Ovil5Qtijg6ZCY4K0=; b=dfF5TdX2oMUzc/7bBeuNhBslwtDbnzDOxegzELTzzcV3patdsUZ5zYJVWTVD6ra5XPzYyv 3WwYXeMwe/+/bXTAqTyUJ9BBy5Dc5/cBzUHpQapdcVc6gGLtkCX4RHJz7BQnc2eq+2298B onflvnh6mU8QCl6WI9zzik50sKfMYHQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-UmL-LV2AOoygY5GXQ8y7Hw-1; Wed, 22 Sep 2021 13:27:04 -0400 X-MC-Unique: UmL-LV2AOoygY5GXQ8y7Hw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BECC19251A3; Wed, 22 Sep 2021 17:27:03 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADC071972D; Wed, 22 Sep 2021 17:27:01 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Mat Martineau , Eric Dumazet , mptcp@lists.linux.dev Subject: [PATCH net-next 3/4] tcp: make tcp_build_frag() static Date: Wed, 22 Sep 2021 19:26:42 +0200 Message-Id: <5e04e52a27a272a19d23162ea20ef62fd91c94b4.1632318035.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Type: text/plain; charset="utf-8" After the previous patch the mentioned helper is used only inside its compilation unit: let's make it static. RFC -> v1: - preserve the tcp_build_frag() helper (Eric) Signed-off-by: Paolo Abeni Reviewed-by: Eric Dumazet --- include/net/tcp.h | 2 -- net/ipv4/tcp.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 4a96f6e0f6f8..673c3b01e287 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -330,8 +330,6 @@ int tcp_sendpage(struct sock *sk, struct page *page, in= t offset, size_t size, int flags); int tcp_sendpage_locked(struct sock *sk, struct page *page, int offset, size_t size, int flags); -struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags, - struct page *page, int offset, size_t *size); ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, size_t size, int flags); int tcp_send_mss(struct sock *sk, int *size_goal, int flags); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index c592454625e1..29cb7bf9dc1c 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -963,8 +963,8 @@ void tcp_remove_empty_skb(struct sock *sk, struct sk_bu= ff *skb) } } =20 -struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags, - struct page *page, int offset, size_t *size) +static struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int = flags, + struct page *page, int offset, size_t *size) { struct sk_buff *skb =3D tcp_write_queue_tail(sk); struct tcp_sock *tp =3D tcp_sk(sk); --=20 2.26.3 From nobody Thu Mar 28 21:45:59 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a02:a689:0:0:0:0:0 with SMTP id j9csp580019jam; Wed, 22 Sep 2021 10:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7yhrEtvP4mlhFAKp1EFx+4tXe1s1ZAUsz43sig0hiO31EHRwfsBfksqg47kGDwP8wsc5g X-Received: by 2002:a17:90b:384a:: with SMTP id nl10mr12753021pjb.65.1632331634356; Wed, 22 Sep 2021 10:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632331634; cv=none; d=google.com; s=arc-20160816; b=e9+ycPE/wsUocYcLtItXMsB9D8WFIITARjMZUTIzJqY2RnG2GyMrRChL7oP10E9BfI dKNH0L9+LnPHokw12LywxLEcoSMqT7qp17uhlxX22tS5T0J0cRimNq1Gb+IWGGUb5RLu /sL7ddrYgDIDe/9DPMqAmzGvF/o2LkHhFUNmvsSBfHqpYP070gBAaku2ObGQ3kb8emVS K+w4uZzc7G20j6E0/TiD6cq16XMNwUM5T8QMfcQMRmChtWbsnye0/gklHk2OjdHY06rL s4CdQ1jCKdAEFwhY0C/s3yGHpyucJ2PqMgyJPB+UMISCs/5olzJp3uLm9mpsrb0oiwx1 xaWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HxxplK21M64p9hR45/jYVkT90OzzKHal/FHla5Gxp/8=; b=OMwDOB7uBt+AJ2ESpUHyGbO4v9BebfuCIrrstZyfL82LOrgJNoCp/ktBXgBTmbcp4g UwZ/x434GL/dCjpsrVPj1smDdAZKjhR4nkmS51PxVkIA+7w35wg+FALg8kFKqRwgvX6C 9DTKYZ+xVfcojERxAV3cxQFwJbjSEogN6ExO3RboHlLniLGI/MJDGWluecRng8tF0Xrd QbV9cFKSv2RknHHvEEYLf5jHV0Mnc7exc+XiEqfmlpToOvi9NGSMuYfVixMJ365NY6Zo vDF2B8o0MvMe5ETkFII11hUSFMvVteDlJjngEvOGtlK2jfgkwIkVzTSz/TOPqyiefju+ sxWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qc06MKdw; spf=pass (google.com: domain of mptcp+bounces-2019-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2019-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id d11si2913995plh.6.2021.09.22.10.27.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Sep 2021 10:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-2019-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qc06MKdw; spf=pass (google.com: domain of mptcp+bounces-2019-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-2019-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sjc.edge.kernel.org (Postfix) with ESMTPS id B26333E0E75 for ; Wed, 22 Sep 2021 17:27:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 912793FCD; Wed, 22 Sep 2021 17:27:12 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (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 2A83B3FCB for ; Wed, 22 Sep 2021 17:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632331630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HxxplK21M64p9hR45/jYVkT90OzzKHal/FHla5Gxp/8=; b=Qc06MKdw6xOhOj1FKZnyww7oRPioOXkFRzpMrO/T68dzYChNBIN9JL3rxLhORb5Onmfedq TFR/JuLBIPBUWuaLJXZy8u+v1InJgshUGMpGNbiU9M6reP7KvmCG1GVuZON0VeiJD9ywTW mlDgAaAeJgOQxRhhI7fYJJuNWgb8z/8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-393-YAtBsCSNPYGjyrbVHzmwoA-1; Wed, 22 Sep 2021 13:27:06 -0400 X-MC-Unique: YAtBsCSNPYGjyrbVHzmwoA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0677010151F8; Wed, 22 Sep 2021 17:27:05 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F36519724; Wed, 22 Sep 2021 17:27:03 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Mat Martineau , Eric Dumazet , mptcp@lists.linux.dev Subject: [PATCH net-next 4/4] tcp: remove sk_{tr}x_skb_cache Date: Wed, 22 Sep 2021 19:26:43 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Type: text/plain; charset="utf-8" From: Eric Dumazet This reverts the following patches : - commit 2e05fcae83c4 ("tcp: fix compile error if !CONFIG_SYSCTL") - commit 4f661542a402 ("tcp: fix zerocopy and notsent_lowat issues") - commit 472c2e07eef0 ("tcp: add one skb cache for tx") - commit 8b27dae5a2e8 ("tcp: add one skb cache for rx") Having a cache of one skb (in each direction) per TCP socket is fragile, since it can cause a significant increase of memory needs, and not good enough for high speed flows anyway where more than one skb is needed. We want instead to add a generic infrastructure, with more flexible per-cpu caches, for alien NUMA nodes. Acked-by: Paolo Abeni Acked-by: Mat Martineau Signed-off-by: Eric Dumazet --- Documentation/networking/ip-sysctl.rst | 8 -------- include/net/sock.h | 19 ------------------- net/ipv4/af_inet.c | 4 ---- net/ipv4/sysctl_net_ipv4.c | 12 ------------ net/ipv4/tcp.c | 26 -------------------------- net/ipv4/tcp_ipv4.c | 6 ------ net/ipv6/tcp_ipv6.c | 6 ------ 7 files changed, 81 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/network= ing/ip-sysctl.rst index d91ab28718d4..16b8bf72feaf 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -989,14 +989,6 @@ tcp_challenge_ack_limit - INTEGER in RFC 5961 (Improving TCP's Robustness to Blind In-Window Attacks) Default: 1000 =20 -tcp_rx_skb_cache - BOOLEAN - Controls a per TCP socket cache of one skb, that might help - performance of some workloads. This might be dangerous - on systems with a lot of TCP sockets, since it increases - memory usage. - - Default: 0 (disabled) - UDP variables =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/include/net/sock.h b/include/net/sock.h index 66a9a90f9558..708b9de3cdbb 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -262,7 +262,6 @@ struct bpf_local_storage; * @sk_dst_cache: destination cache * @sk_dst_pending_confirm: need to confirm neighbour * @sk_policy: flow policy - * @sk_rx_skb_cache: cache copy of recently accessed RX skb * @sk_receive_queue: incoming packets * @sk_wmem_alloc: transmit queue bytes committed * @sk_tsq_flags: TCP Small Queues flags @@ -328,7 +327,6 @@ struct bpf_local_storage; * @sk_peek_off: current peek_offset value * @sk_send_head: front of stuff to transmit * @tcp_rtx_queue: TCP re-transmit queue [union with @sk_send_head] - * @sk_tx_skb_cache: cache copy of recently accessed TX skb * @sk_security: used by security modules * @sk_mark: generic packet mark * @sk_cgrp_data: cgroup data for this cgroup @@ -393,7 +391,6 @@ struct sock { atomic_t sk_drops; int sk_rcvlowat; struct sk_buff_head sk_error_queue; - struct sk_buff *sk_rx_skb_cache; struct sk_buff_head sk_receive_queue; /* * The backlog queue is special, it is always used with @@ -442,7 +439,6 @@ struct sock { struct sk_buff *sk_send_head; struct rb_root tcp_rtx_queue; }; - struct sk_buff *sk_tx_skb_cache; struct sk_buff_head sk_write_queue; __s32 sk_peek_off; int sk_write_pending; @@ -1555,18 +1551,10 @@ static inline void sk_mem_uncharge(struct sock *sk,= int size) __sk_mem_reclaim(sk, 1 << 20); } =20 -DECLARE_STATIC_KEY_FALSE(tcp_tx_skb_cache_key); static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) { sk_wmem_queued_add(sk, -skb->truesize); sk_mem_uncharge(sk, skb->truesize); - if (static_branch_unlikely(&tcp_tx_skb_cache_key) && - !sk->sk_tx_skb_cache && !skb_cloned(skb)) { - skb_ext_reset(skb); - skb_zcopy_clear(skb, true); - sk->sk_tx_skb_cache =3D skb; - return; - } __kfree_skb(skb); } =20 @@ -2575,7 +2563,6 @@ static inline void skb_setup_tx_timestamp(struct sk_b= uff *skb, __u16 tsflags) &skb_shinfo(skb)->tskey); } =20 -DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key); /** * sk_eat_skb - Release a skb if it is no longer needed * @sk: socket to eat this skb from @@ -2587,12 +2574,6 @@ DECLARE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key); static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb) { __skb_unlink(skb, &sk->sk_receive_queue); - if (static_branch_unlikely(&tcp_rx_skb_cache_key) && - !sk->sk_rx_skb_cache) { - sk->sk_rx_skb_cache =3D skb; - skb_orphan(skb); - return; - } __kfree_skb(skb); } =20 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1d816a5fd3eb..40558033f857 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -133,10 +133,6 @@ void inet_sock_destruct(struct sock *sk) struct inet_sock *inet =3D inet_sk(sk); =20 __skb_queue_purge(&sk->sk_receive_queue); - if (sk->sk_rx_skb_cache) { - __kfree_skb(sk->sk_rx_skb_cache); - sk->sk_rx_skb_cache =3D NULL; - } __skb_queue_purge(&sk->sk_error_queue); =20 sk_mem_reclaim(sk); diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 6f1e64d49232..6eb43dc91218 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -594,18 +594,6 @@ static struct ctl_table ipv4_table[] =3D { .extra1 =3D &sysctl_fib_sync_mem_min, .extra2 =3D &sysctl_fib_sync_mem_max, }, - { - .procname =3D "tcp_rx_skb_cache", - .data =3D &tcp_rx_skb_cache_key.key, - .mode =3D 0644, - .proc_handler =3D proc_do_static_key, - }, - { - .procname =3D "tcp_tx_skb_cache", - .data =3D &tcp_tx_skb_cache_key.key, - .mode =3D 0644, - .proc_handler =3D proc_do_static_key, - }, { } }; =20 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 29cb7bf9dc1c..414c179c28e0 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -325,11 +325,6 @@ struct tcp_splice_state { unsigned long tcp_memory_pressure __read_mostly; EXPORT_SYMBOL_GPL(tcp_memory_pressure); =20 -DEFINE_STATIC_KEY_FALSE(tcp_rx_skb_cache_key); -EXPORT_SYMBOL(tcp_rx_skb_cache_key); - -DEFINE_STATIC_KEY_FALSE(tcp_tx_skb_cache_key); - void tcp_enter_memory_pressure(struct sock *sk) { unsigned long val; @@ -866,18 +861,6 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, i= nt size, gfp_t gfp, { struct sk_buff *skb; =20 - if (likely(!size)) { - skb =3D sk->sk_tx_skb_cache; - if (skb) { - skb->truesize =3D SKB_TRUESIZE(skb_end_offset(skb)); - sk->sk_tx_skb_cache =3D NULL; - pskb_trim(skb, 0); - INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); - skb_shinfo(skb)->tx_flags =3D 0; - memset(TCP_SKB_CB(skb), 0, sizeof(struct tcp_skb_cb)); - return skb; - } - } /* The TCP header must be at least 32-bit aligned. */ size =3D ALIGN(size, 4); =20 @@ -2920,11 +2903,6 @@ void tcp_write_queue_purge(struct sock *sk) sk_wmem_free_skb(sk, skb); } tcp_rtx_queue_purge(sk); - skb =3D sk->sk_tx_skb_cache; - if (skb) { - __kfree_skb(skb); - sk->sk_tx_skb_cache =3D NULL; - } INIT_LIST_HEAD(&tcp_sk(sk)->tsorted_sent_queue); sk_mem_reclaim(sk); tcp_clear_all_retrans_hints(tcp_sk(sk)); @@ -2961,10 +2939,6 @@ int tcp_disconnect(struct sock *sk, int flags) =20 tcp_clear_xmit_timers(sk); __skb_queue_purge(&sk->sk_receive_queue); - if (sk->sk_rx_skb_cache) { - __kfree_skb(sk->sk_rx_skb_cache); - sk->sk_rx_skb_cache =3D NULL; - } WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); tp->urg_data =3D 0; tcp_write_queue_purge(sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 2e62e0d6373a..29a57bd159f0 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1941,7 +1941,6 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const= struct iphdr *iph, int tcp_v4_rcv(struct sk_buff *skb) { struct net *net =3D dev_net(skb->dev); - struct sk_buff *skb_to_free; int sdif =3D inet_sdif(skb); int dif =3D inet_iif(skb); const struct iphdr *iph; @@ -2082,17 +2081,12 @@ int tcp_v4_rcv(struct sk_buff *skb) tcp_segs_in(tcp_sk(sk), skb); ret =3D 0; if (!sock_owned_by_user(sk)) { - skb_to_free =3D sk->sk_rx_skb_cache; - sk->sk_rx_skb_cache =3D NULL; ret =3D tcp_v4_do_rcv(sk, skb); } else { if (tcp_add_backlog(sk, skb)) goto discard_and_relse; - skb_to_free =3D NULL; } bh_unlock_sock(sk); - if (skb_to_free) - __kfree_skb(skb_to_free); =20 put_and_return: if (refcounted) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 0ce52d46e4f8..8cf5ff2e9504 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1618,7 +1618,6 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const= struct ipv6hdr *hdr, =20 INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) { - struct sk_buff *skb_to_free; int sdif =3D inet6_sdif(skb); int dif =3D inet6_iif(skb); const struct tcphdr *th; @@ -1754,17 +1753,12 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_bu= ff *skb) tcp_segs_in(tcp_sk(sk), skb); ret =3D 0; if (!sock_owned_by_user(sk)) { - skb_to_free =3D sk->sk_rx_skb_cache; - sk->sk_rx_skb_cache =3D NULL; ret =3D tcp_v6_do_rcv(sk, skb); } else { if (tcp_add_backlog(sk, skb)) goto discard_and_relse; - skb_to_free =3D NULL; } bh_unlock_sock(sk); - if (skb_to_free) - __kfree_skb(skb_to_free); put_and_return: if (refcounted) sock_put(sk); --=20 2.26.3