From: Johanna Abrahamsson <johanna@mjao.org>
To: "David S. Miller" <davem@davemloft.net>,
"Håkon Bugge" <haakon.bugge@oracle.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Hans Westgaard Ry" <hans.westgaard.ry@oracle.com>
Cc: "open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>
Subject: [PATCH] net: Reduce size of rps_sock_flow_sysctl
Date: Thu, 1 Sep 2016 22:37:01 +0200 [thread overview]
Message-ID: <20160901203658.GA4828@fedora-21-dvm> (raw)
Reduce size of rps_sock_flow_sysctl to improve readability.
Signed-off-by: Johanna Abrahamsson <johanna@mjao.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
next reply other threads:[~2016-09-01 20:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 20:37 Johanna Abrahamsson [this message]
2016-09-01 21:13 ` [PATCH] net: Reduce size of rps_sock_flow_sysctl Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160901203658.GA4828@fedora-21-dvm \
--to=johanna@mjao.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=haakon.bugge@oracle.com \
--cc=hans.westgaard.ry@oracle.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox