net: Reduce size of rps_sock_flow_sysctl
Subsystems (2)
PATCH 1/1 net: Reduce size of rps_sock_flow_sysctl
Reduce size of rps_sock_flow_sysctl to improve readability.
Signed-off-by Johanna Abrahamsson <[email protected]>
--- net/core/sysctl_net_core.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
net/core/sysctl_net_core.c +22 -22
@@ -53,29 +53,29 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, ret =proc_dointvec (&tmp, write, buffer, lenp, ppos);if (write) { -if (size) { -if (size >1 <<29 ) { -/* Enforce limit to prevent overflow */ -mutex_unlock (&sock_flow_mutex); -return -EINVAL ; +if (!size) + goto exit_unlock; +if (size >1 <<29 ) { +/* Enforce limit to prevent overflow */ + ret = -EINVAL ; + goto exit_unlock; + } + + size =roundup_pow_of_two (size); +if (size != orig_size) { + sock_table =vmalloc (RPS_SOCK_FLOW_TABLE_SIZE (size)); +if (!sock_table) { + ret = -ENOMEM ; + goto exit_unlock; } - size =roundup_pow_of_two (size); -if (size != orig_size) { - sock_table = -vmalloc (RPS_SOCK_FLOW_TABLE_SIZE (size)); -if (!sock_table) { -mutex_unlock (&sock_flow_mutex); -return -ENOMEM ; - } - rps_cpu_mask =roundup_pow_of_two (nr_cpu_ids) -1 ; - sock_table->mask = size -1 ; - }else - sock_table = orig_sock_table; + rps_cpu_mask =roundup_pow_of_two (nr_cpu_ids) -1 ; + sock_table->mask = size -1 ; + }else { + sock_table = orig_sock_table; + } -for (i =0 ; i < size; i++) - sock_table->ents[i] =RPS_NO_CPU ; - }else - sock_table =NULL ; +for (i =0 ; i < size; i++) + sock_table->ents[i] =RPS_NO_CPU ;if (sock_table != orig_sock_table) {rcu_assign_pointer (rps_sock_flow_table, sock_table);
@@ -89,8 +89,8 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, } } +exit_unlock:mutex_unlock (&sock_flow_mutex); -return ret; }#endif /* CONFIG_RPS */
Signature · 1 line
2.1.4
Quoted 12 lines · Johanna Abrahamsson
Reduce size of
rps_sock_flow_sysctlto improve readability.Signed-off-by Johanna Abrahamsson <[email protected]>--- net/core/sysctl_net_core.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)net/core/sysctl_net_core.c +0
-0
net/core/sysctl_net_core.c static int rps_sock_flow_sysctl(struct ctl_table *table, int write, · line 57
Quoted 10 lines
net/core/sysctl_net_core.c +2
-5@@ -53,29 +53,29 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, ret =proc_dointvec (&tmp, write, buffer, lenp, ppos);if (write) { -if (size) { -if (size >1 <<29 ) { -/* Enforce limit to prevent overflow */ -mutex_unlock (&sock_flow_mutex); -return -EINVAL ; +if (!size) + goto exit_unlock;
Hi Johanna
Unfortunately this would break the following action :
lpaa24:~# cat /proc/sys/net/core/rps_sock_flow_entries 65536 lpaa24:~# echo 0 >/proc/sys/net/core/rps_sock_flow_entries lpaa24:~# cat /proc/sys/net/core/rps_sock_flow_entries 0
If you resubmit a V2, please include a 'Tested:' section showing how you have tested your (first linux ?) patch ;)
Thanks !