]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/smc: add sysctl for autocorking
authorDust Li <dust.li@linux.alibaba.com>
Tue, 1 Mar 2022 09:43:58 +0000 (17:43 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Mar 2022 14:25:12 +0000 (14:25 +0000)
This add a new sysctl: net.smc.autocorking_size

We can dynamically change the behaviour of autocorking
by change the value of autocorking_size.
Setting to 0 disables autocorking in SMC

Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/smc-sysctl.rst [new file with mode: 0644]
include/net/netns/smc.h
net/smc/smc_sysctl.c
net/smc/smc_tx.c

diff --git a/Documentation/networking/smc-sysctl.rst b/Documentation/networking/smc-sysctl.rst
new file mode 100644 (file)
index 0000000..c53f8c6
--- /dev/null
@@ -0,0 +1,23 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=========
+SMC Sysctl
+=========
+
+/proc/sys/net/smc/* Variables
+==============================
+
+autocorking_size - INTEGER
+       Setting SMC auto corking size:
+       SMC auto corking is like TCP auto corking from the application's
+       perspective of view. When applications do consecutive small
+       write()/sendmsg() system calls, we try to coalesce these small writes
+       as much as possible, to lower total amount of CDC and RDMA Write been
+       sent.
+       autocorking_size limits the maximum corked bytes that can be sent to
+       the under device in 1 single sending. If set to 0, the SMC auto corking
+       is disabled.
+       Applications can still use TCP_CORK for optimal behavior when they
+       know how/when to uncork their sockets.
+
+       Default: 64K
index 1682eae50579cce7bcdec20ffd0eff1a1285b6ad..e5389eeaf8bd6cb8df28fc71fbd9157fa0380880 100644 (file)
@@ -17,5 +17,6 @@ struct netns_smc {
 #ifdef CONFIG_SYSCTL
        struct ctl_table_header         *smc_hdr;
 #endif
+       unsigned int                    sysctl_autocorking_size;
 };
 #endif
index 8a3a8e145976c887ebb23725411d266e0fadf13b..3b59876aaac9fd7fc7d2c0ae63482a5851149acb 100644 (file)
 #include <linux/sysctl.h>
 #include <net/net_namespace.h>
 
+#include "smc.h"
 #include "smc_sysctl.h"
 
 static struct ctl_table smc_table[] = {
+       {
+               .procname       = "autocorking_size",
+               .data           = &init_net.smc.sysctl_autocorking_size,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_douintvec,
+       },
        {  }
 };
 
@@ -40,6 +48,8 @@ static __net_init int smc_sysctl_init_net(struct net *net)
        if (!net->smc.smc_hdr)
                goto err_reg;
 
+       net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
+
        return 0;
 
 err_reg:
index 062c6b1535e30702dabec0e3cb4979464b3d5090..257dc0d0aeb1ffd9bb87b89880346362f7cca0a6 100644 (file)
@@ -147,7 +147,7 @@ static bool smc_should_autocork(struct smc_sock *smc)
        struct smc_connection *conn = &smc->conn;
        int corking_size;
 
-       corking_size = min(SMC_AUTOCORKING_DEFAULT_SIZE,
+       corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
                           conn->sndbuf_desc->len >> 1);
 
        if (atomic_read(&conn->cdc_pend_tx_wr) == 0 ||