From nobody Sat Apr 20 11:22:29 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6638:d02:0:0:0:0 with SMTP id q2csp100886jaj; Thu, 2 Sep 2021 07:21:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTDbNrOKcsKE6+DiQHfbVxelXDInuDlsbxtJrVbxN9s4AN8R01ap/eJhJ+stZnlb9nAzoB X-Received: by 2002:a9f:3e4c:: with SMTP id c12mr1933765uaj.75.1630592509533; Thu, 02 Sep 2021 07:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630592509; cv=none; d=google.com; s=arc-20160816; b=eMLeM3/MkpF5ctyLUd9l1fZ3Hwa6UAaTITPimI5npa8Sfi0UXqGlu20FLblAlVZssd SCLHwozTdSroFsvqpn9jgR6/TjSmz2jptCirJkUV1HWq2QXenney5bQPbcppjC3ooVqo E780Kl1Kw6pZ99bQwwnmFef0KxSDJJsfyK8IkSCGW1MeaCSFTGJNR+q3rP6G+wMW8xF2 pmE8E9jWvuH/UrES0iV6mF+72kyjPC6zO2j5U6BPi6HSs06tBHOLymBpDv5sjHur16VJ s0KwZdTJwKZIyTC7xC/w7x9jOepOTixv85StcTDkJVl85Jj575+pFeGIklb98vS7bXQ5 bRvA== 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:to:from:dkim-signature; bh=0sXuSGNUZPcTS2HU99UWlUvle8o+zTUPolerURfGs60=; b=RixvjaNGgf1GJ8sQSQd6uRMwusLvXF9IzcbNoOyKZJhBFKTfWL0k2PNjXAIGu0ZIua i+5Lm87rhHYkQMd+EpRzORDuY+cc2XV5UZGorIns6Wdsk/ztZDrFBc28R1c0PmqlQrn3 6fpthcDTigj+4+iI4NOvwOZXEJhrVMgWuZ+IHE/LsLUYVlNM+plujxbFIprMrk1cQQnz HDUHmZVa61PSOz1/K6Mo4EsVHyKJWVCWvYfzXNKmhc+0LGUYuw0C4MHLJUQ8mLSe+2dT L8u95Ej5gcgm6M3uKkjy8hNOB5uN+Iaoelz0bOMbhALiPMjsVvU2kSRLMY0Qf1I+/r3d X4bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d3U8y5w6; spf=pass (google.com: domain of mptcp+bounces-1814-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-1814-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 k7si687923uad.52.2021.09.02.07.21.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Sep 2021 07:21:49 -0700 (PDT) Received-SPF: pass (google.com: domain of mptcp+bounces-1814-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=d3U8y5w6; spf=pass (google.com: domain of mptcp+bounces-1814-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-1814-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 9E0833E0E38 for ; Thu, 2 Sep 2021 14:21:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F6813FD5; Thu, 2 Sep 2021 14:21:47 +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 295E93FD3 for ; Thu, 2 Sep 2021 14:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630592502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0sXuSGNUZPcTS2HU99UWlUvle8o+zTUPolerURfGs60=; b=d3U8y5w6gkz2QHRJ5+vvttrl0TSz8i6xiSZuD5FxBgboGVp7l1wnoQ9Rzap+3GG74b4ruK 0EpRq5NuWMJbuWGmLWZhTeR2tVm9rKkk1u+9lEs6Y+k4eIDtlp1okMf57etjz/7MkaWem7 GuE41tQ/Po9g1BDC8UcGWfN9zMwUpYk= 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-447-j28Li_q0PwG8ltVVQz9uvA-1; Thu, 02 Sep 2021 10:21:32 -0400 X-MC-Unique: j28Li_q0PwG8ltVVQz9uvA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30DCBDF8AE for ; Thu, 2 Sep 2021 14:20:47 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.194.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E6661042A40 for ; Thu, 2 Sep 2021 14:20:46 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 4/4] tcp: remove sk_{tr}x_skb_cache Date: Thu, 2 Sep 2021 16:20:32 +0200 Message-Id: <481fab3d20248bb78d959c8e9445c091c1c14e6b.1630591985.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 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pabeni@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet This reverts the following patches : 2e05fcae83c41eb2df10558338dc600dc783af47 ("tcp: fix compile error if !CONFI= G_SYSCTL") 4f661542a40217713f2cee0bb6678fbb30d9d367 ("tcp: fix zerocopy and notsent_lo= wat issues") 472c2e07eef045145bc1493cc94a01c87140780a ("tcp: add one skb cache for tx") 8b27dae5a2e89a61c46c6dbc76c040c0e6d0ed4c ("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. 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 9dc7613e589d..63eda8cb0d26 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 caf0c50d86bc..cbb0f807be46 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 @@ -2905,11 +2888,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)); @@ -2946,10 +2924,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