forked from torvalds/linux
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
net/smc: Unbind buffer size from clcsock and make it tunable
SMC uses smc->sk.sk_{rcv|snd}buf to create buffer for send buffer or
RMB. And the values of buffer size inherits from clcsock. The clcsock is
a TCP sock which is initiated during SMC connection startup.
The inherited buffer size doesn't fit SMC well. TCP provides two sysctl
knobs to tune r/w buffers, net.ipv4.tcp_{r|w}mem, and SMC use the default
value from TCP. The buffer size is tuned for TCP, but not fit SMC well
in some scenarios. For example, we need larger buffer of SMC for high
throughput applications, and smaller buffer of SMC for saving contiguous
memory. We need to adjust the buffer size apart from TCP and not to
disturb TCP.
This unbinds buffer size which inherits from clcsock, and provides
sysctl knobs to adjust buffer size independently. These knobs can be
tuned with different values for different net namespaces for performance
and flexibility.
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
Reviewed-by: Wen Gu <guwen@linux.alibaba.com>- Loading branch information
1 parent
89f9711
commit f8b865aff3164098137794ac439371b2391c836b
Showing
6 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| .. SPDX-License-Identifier: GPL-2.0 | ||
| ========= | ||
| SMC Sysctl | ||
| ========= | ||
|
|
||
| /proc/sys/net/smc/* Variables | ||
| ============================== | ||
|
|
||
| wmem_default - INTEGER | ||
| Initial size of send buffer used by SMC sockets. | ||
| The default value inherits from net.ipv4.tcp_wmem[1]. | ||
|
|
||
| Default: 16K | ||
|
|
||
| rmem_default - INTEGER | ||
| Initial size of receive buffer (RMB) used by SMC sockets. | ||
| The default value inherits from net.ipv4.tcp_rmem[1]. | ||
|
|
||
| Default: 131072 bytes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // SPDX-License-Identifier: GPL-2.0 | ||
|
|
||
| #include <linux/module.h> | ||
| #include <linux/init.h> | ||
| #include <linux/sysctl.h> | ||
| #include <net/sock.h> | ||
| #include <net/net_namespace.h> | ||
|
|
||
| #include "smc_core.h" | ||
|
|
||
| static int min_sndbuf = SMC_BUF_MIN_SIZE; | ||
| static int min_rcvbuf = SMC_BUF_MIN_SIZE; | ||
|
|
||
| static struct ctl_table smc_table[] = { | ||
| { | ||
| .procname = "wmem_default", | ||
| .data = &init_net.smc.sysctl_wmem_default, | ||
| .maxlen = sizeof(init_net.smc.sysctl_wmem_default), | ||
| .mode = 0644, | ||
| .proc_handler = proc_dointvec_minmax, | ||
| .extra1 = &min_sndbuf, | ||
| }, | ||
| { | ||
| .procname = "rmem_default", | ||
| .data = &init_net.smc.sysctl_rmem_default, | ||
| .maxlen = sizeof(init_net.smc.sysctl_rmem_default), | ||
| .mode = 0644, | ||
| .proc_handler = proc_dointvec_minmax, | ||
| .extra1 = &min_rcvbuf, | ||
| }, | ||
| { } | ||
| }; | ||
|
|
||
| static __net_init int smc_sysctl_init_net(struct net *net) | ||
| { | ||
| struct ctl_table *table; | ||
|
|
||
| table = smc_table; | ||
| if (!net_eq(net, &init_net)) { | ||
| int i; | ||
|
|
||
| table = kmemdup(table, sizeof(smc_table), GFP_KERNEL); | ||
| if (!table) | ||
| goto err_alloc; | ||
|
|
||
| for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++) | ||
| table[i].data += (void *)net - (void *)&init_net; | ||
| } | ||
|
|
||
| net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table); | ||
| if (!net->smc.smc_hdr) | ||
| goto err_reg; | ||
|
|
||
| return 0; | ||
|
|
||
| err_reg: | ||
| if (!net_eq(net, &init_net)) | ||
| kfree(table); | ||
| err_alloc: | ||
| return -ENOMEM; | ||
| } | ||
|
|
||
| static __net_exit void smc_sysctl_exit_net(struct net *net) | ||
| { | ||
| unregister_net_sysctl_table(net->smc.smc_hdr); | ||
| } | ||
|
|
||
| static struct pernet_operations smc_sysctl_ops __net_initdata = { | ||
| .init = smc_sysctl_init_net, | ||
| .exit = smc_sysctl_exit_net, | ||
| }; | ||
|
|
||
| int __init smc_sysctl_init(void) | ||
| { | ||
| return register_pernet_subsys(&smc_sysctl_ops); | ||
| } | ||
|
|
||
| void smc_sysctl_exit(void) | ||
| { | ||
| unregister_pernet_subsys(&smc_sysctl_ops); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
|
|
||
| #ifndef _SMC_SYSCTL_H | ||
| #define _SMC_SYSCTL_H | ||
|
|
||
| #ifdef CONFIG_SYSCTL | ||
|
|
||
| int smc_sysctl_init(void); | ||
| void smc_sysctl_exit(void); | ||
|
|
||
| #else | ||
|
|
||
| int smc_sysctl_init(void) | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| void smc_sysctl_exit(void) { } | ||
|
|
||
| #endif /* CONFIG_SYSCTL */ | ||
|
|
||
| #endif /* _SMC_SYSCTL_H */ |