From patchwork Fri Nov 13 15:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 11903881 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 470FAC388F7 for ; Fri, 13 Nov 2020 15:08:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C25122242 for ; Fri, 13 Nov 2020 15:08:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KV96KiM2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbgKMPIS (ORCPT ); Fri, 13 Nov 2020 10:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbgKMPIR (ORCPT ); Fri, 13 Nov 2020 10:08:17 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B0BC0613D1 for ; Fri, 13 Nov 2020 07:08:17 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id g7so7866956pfc.2 for ; Fri, 13 Nov 2020 07:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZFVWd/LOOt3S/uFBqVU9M39PkBZOlcIBTXV9AwJvqxw=; b=KV96KiM2K9korWXiIvG2dQHRMvanvp72V5299ncO1UqKLsmTQWc9l2KtsHnEpcboNj CaW0XtdtZaPnYrV5dpuHScga4/iu7q/9OtYbYkGDYoTbXX1KhJIYBrA2b/4WDrzuu02C sfFcocfpYlpTWp5kX0rDNRZZnug6GaFBAX/ZwMZL0IIhoxV0GyEmcqEY/wKoL/mqLjV4 hNbxADPXmrowe/gsaNDA83jdBGryv4jeocXkmGz8R/wxU9+9YH20YiGnzXILbXcKQ8eI E8IDbkTVmQSemr2fIrYY6s8bldchle6fBYx2OcHHlnGMQgvJ9cUxtKjui69dDtuX/mMm +VdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZFVWd/LOOt3S/uFBqVU9M39PkBZOlcIBTXV9AwJvqxw=; b=olvqA45MWRXea95khjjP5bXFQSTCS+AczVMbk5RmLMBkbkxNS1IpzdvNYsMSWM9szL OvwI0jLfchyQ3eej7CcmVRq173psi3FBF8zRp5j7K7vbzHHsPJasPLXr5SdoFGXVh++d qa3KBosLFrMlBJ8rgaMOg1IqcUDtMjCoW1MrSZHTa7Ug0322aRPK5pF0Z6f6naFuBp5X ydp2SVPYR77eBfgq8jTfBbt8/nEHGAws2XJ/6HiEmAHj2yoT//6jkj38KNfjvg43Cmrs vfmHIP0H5sT33E6Qcpx5lvVnkhOWJUg5dRQ1ZWdppGbB4VeVVusRLP40SiU1Y/EXsu/1 jwaQ== X-Gm-Message-State: AOAM5321M1KYAl4J8YU936dbXIl0y5UmThfLECogj6OPf719lG35kWUl NCPsVMRvL9ct3B0euF21ZJc= X-Google-Smtp-Source: ABdhPJy/FWua3tQMk8JAcoTWqb/h58IcJk+CX3B9r70oSNOERsJ4w9IzYPMQqBOf3nj7Ggtzy9jkrg== X-Received: by 2002:a63:4648:: with SMTP id v8mr2471979pgk.248.1605280097237; Fri, 13 Nov 2020 07:08:17 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:7220:84ff:fe09:1424]) by smtp.gmail.com with ESMTPSA id k17sm12043834pji.50.2020.11.13.07.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 07:08:16 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 1/2] tcp: uninline tcp_stream_memory_free() Date: Fri, 13 Nov 2020 07:08:08 -0800 Message-Id: <20201113150809.3443527-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201113150809.3443527-1-eric.dumazet@gmail.com> References: <20201113150809.3443527-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Both IPv4 and IPv6 needs it via a function pointer. Following patch will avoid the indirect call. Signed-off-by: Eric Dumazet --- include/net/tcp.h | 13 +------------ net/ipv4/tcp_ipv4.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 4aba0f069b05d68b2595ec9a3bf8da7786437fde..d643ee4e42495f0b28c87e79d6192c23f8cdba7f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1965,18 +1965,7 @@ static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp) return tp->notsent_lowat ?: net->ipv4.sysctl_tcp_notsent_lowat; } -/* @wake is one when sk_stream_write_space() calls us. - * This sends EPOLLOUT only if notsent_bytes is half the limit. - * This mimics the strategy used in sock_def_write_space(). - */ -static inline bool tcp_stream_memory_free(const struct sock *sk, int wake) -{ - const struct tcp_sock *tp = tcp_sk(sk); - u32 notsent_bytes = READ_ONCE(tp->write_seq) - - READ_ONCE(tp->snd_nxt); - - return (notsent_bytes << wake) < tcp_notsent_lowat(tp); -} +bool tcp_stream_memory_free(const struct sock *sk, int wake); #ifdef CONFIG_PROC_FS int tcp4_proc_init(void); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 7352c097ae48f7df6caba1ae5b98dccfecd79d1a..c2d5132c523c8d4258e407c4cc5112840b07805e 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2740,6 +2740,20 @@ void tcp4_proc_exit(void) } #endif /* CONFIG_PROC_FS */ +/* @wake is one when sk_stream_write_space() calls us. + * This sends EPOLLOUT only if notsent_bytes is half the limit. + * This mimics the strategy used in sock_def_write_space(). + */ +bool tcp_stream_memory_free(const struct sock *sk, int wake) +{ + const struct tcp_sock *tp = tcp_sk(sk); + u32 notsent_bytes = READ_ONCE(tp->write_seq) - + READ_ONCE(tp->snd_nxt); + + return (notsent_bytes << wake) < tcp_notsent_lowat(tp); +} +EXPORT_SYMBOL(tcp_stream_memory_free); + struct proto tcp_prot = { .name = "TCP", .owner = THIS_MODULE, From patchwork Fri Nov 13 15:08:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 11903879 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F0B8C55ABD for ; Fri, 13 Nov 2020 15:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E142D22240 for ; Fri, 13 Nov 2020 15:08:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PeCyei/n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726901AbgKMPIV (ORCPT ); Fri, 13 Nov 2020 10:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbgKMPIT (ORCPT ); Fri, 13 Nov 2020 10:08:19 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71617C0613D1 for ; Fri, 13 Nov 2020 07:08:19 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id j19so487439pgg.5 for ; Fri, 13 Nov 2020 07:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IYRMHQo/0TotVSboDZgb2XPRzlLB7yUez+sJ4ytUiLI=; b=PeCyei/nipKyR7ADEKy6RlfNc9op6oxY5ODv7uYg8pTXLsbLWuc6qzn+L5MnRPXv8a QuObolzqqN4djmp7YM0GPhCeQRwIme5WVR6kkCZNAeQ0VAje9QXrY6xNwW9kZ1dPEvY7 9tQF/HArGaz8efItznZDQXcRR42uE6Ek2uk5KwMf3CIT+IG85fOlTjKJGJct+BwwACUx xW6KQD7ORimU0YdOA0BQpMUuur88UU2YOrFu9hPNHb+LEtzcCGwjYrdjGF27741SR++J tLmC8DrUyA99WThw6/OQm6jzA5Y1l74k3uOjcB2ODrVvNaMvzj6F4X7sIP5OOVZP9Qup +78A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IYRMHQo/0TotVSboDZgb2XPRzlLB7yUez+sJ4ytUiLI=; b=WPvZe75zfYBubQnuSBod4S7LiHJJkZh+yldR7A3up8HcOPdZo+KloN2b84KASWdoHB qc4MdfQpaHYT8Bhn17S4leGEAPbJmBmGXdTmm6Yi2Q19CMON2Q/CtfJNGi8IDua8fnBP Fi8quH5V3tyCUQy89iMF4v8jsHDapK+yT0fN0rq8oP5GLRQTibeWmRnx6U9XqE5zbv4c estHgNbji0YpGqPNrv53jSU5W15tlShazvGe6RUV4W+1Zm7BrrA9akUwGc1x3EK4tORx 7uSE/CITh5lZuCxi8LqEsMaPFbSdlB7TlOyUx8S8ANtwT8loNKF85HXrExiVCh+zPBsD +NvA== X-Gm-Message-State: AOAM531fS92DE9sEJCg95B4y062hfVGwNvgiy/6QyfiLHBsV93qc+epo /05TptuEQM5zODSDejpJReL1DKx1O/0= X-Google-Smtp-Source: ABdhPJyZ1vflD+z7mPpc1KoesngD3NOKz6NNxzlQSGdmR3dmx1t6r5ddeV7UjFKZOG+sL+IRIQZp2w== X-Received: by 2002:a17:90b:180f:: with SMTP id lw15mr3457995pjb.119.1605280099126; Fri, 13 Nov 2020 07:08:19 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:7220:84ff:fe09:1424]) by smtp.gmail.com with ESMTPSA id k17sm12043834pji.50.2020.11.13.07.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 07:08:18 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 2/2] tcp: avoid indirect call to tcp_stream_memory_free() Date: Fri, 13 Nov 2020 07:08:09 -0800 Message-Id: <20201113150809.3443527-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201113150809.3443527-1-eric.dumazet@gmail.com> References: <20201113150809.3443527-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Signed-off-by: Eric Dumazet --- include/net/sock.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index a5c6ae78df77d08e4b65e634e93040446486bdc2..1d29aeae74fdbbae3410def33ebc66758e034205 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -60,7 +60,7 @@ #include #include #include - +#include #include #include #include @@ -1264,13 +1264,17 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) #define sk_refcnt_debug_release(sk) do { } while (0) #endif /* SOCK_REFCNT_DEBUG */ +INDIRECT_CALLABLE_DECLARE(bool tcp_stream_memory_free(const struct sock *sk, int wake)); + static inline bool __sk_stream_memory_free(const struct sock *sk, int wake) { if (READ_ONCE(sk->sk_wmem_queued) >= READ_ONCE(sk->sk_sndbuf)) return false; return sk->sk_prot->stream_memory_free ? - sk->sk_prot->stream_memory_free(sk, wake) : true; + INDIRECT_CALL_1(sk->sk_prot->stream_memory_free, + tcp_stream_memory_free, + sk, wake) : true; } static inline bool sk_stream_memory_free(const struct sock *sk)