[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160901203658.GA4828@fedora-21-dvm>
Date: Thu, 1 Sep 2016 22:37:01 +0200
From: Johanna Abrahamsson <johanna@...o.org>
To: "David S. Miller" <davem@...emloft.net>,
HÃ¥kon Bugge <haakon.bugge@...cle.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Hans Westgaard Ry <hans.westgaard.ry@...cle.com>
Cc: "open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>
Subject: [PATCH] net: Reduce size of rps_sock_flow_sysctl
Reduce size of rps_sock_flow_sysctl to improve readability.
Signed-off-by: Johanna Abrahamsson <johanna@...o.org>
---
net/core/sysctl_net_core.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 0df2aa6..d0be2ce 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -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 */
--
2.1.4
Powered by blists - more mailing lists