From: Dust Li <dust.li@linux.alibaba.com>
Date: Tue, 1 Mar 2022 17:43:58 +0800
Subject: net/smc: add sysctl for autocorking
Patch-mainline: v5.18-rc1
Git-commit: 12bbb0d163a90d81a2677cf7808d364697290207
References: jsc#PED-612
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>
Acked-by: Lee, Chun-Yi <jlee@suse.com>
---
Documentation/networking/smc-sysctl.rst | 23 +++++++++++++++++++++++
include/net/netns/smc.h | 1 +
net/smc/smc_sysctl.c | 10 ++++++++++
net/smc/smc_tx.c | 2 +-
4 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 Documentation/networking/smc-sysctl.rst
--- /dev/null
+++ b/Documentation/networking/smc-sysctl.rst
@@ -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
--- a/include/net/netns/smc.h
+++ b/include/net/netns/smc.h
@@ -17,5 +17,6 @@ struct netns_smc {
#ifdef CONFIG_SYSCTL
struct ctl_table_header *smc_hdr;
#endif
+ unsigned int sysctl_autocorking_size;
};
#endif
--- a/net/smc/smc_sysctl.c
+++ b/net/smc/smc_sysctl.c
@@ -14,9 +14,17 @@
#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_ne
if (!net->smc.smc_hdr)
goto err_reg;
+ net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
+
return 0;
err_reg:
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -147,7 +147,7 @@ static bool smc_should_autocork(struct s
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 ||