All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Reduce size of rps_sock_flow_sysctl
@ 2016-09-01 20:37 Johanna Abrahamsson
  2016-09-01 21:13 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Johanna Abrahamsson @ 2016-09-01 20:37 UTC (permalink / raw)
  To: David S. Miller, Håkon Bugge, Alexei Starovoitov,
	Daniel Borkmann, Hans Westgaard Ry
  Cc: open list:NETWORKING [GENERAL]

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: Reduce size of rps_sock_flow_sysctl
  2016-09-01 20:37 [PATCH] net: Reduce size of rps_sock_flow_sysctl Johanna Abrahamsson
@ 2016-09-01 21:13 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2016-09-01 21:13 UTC (permalink / raw)
  To: Johanna Abrahamsson
  Cc: David S. Miller, Håkon Bugge, Alexei Starovoitov,
	Daniel Borkmann, Hans Westgaard Ry,
	open list:NETWORKING [GENERAL]

On Thu, 2016-09-01 at 22:37 +0200, Johanna Abrahamsson wrote:
> 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;

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 !

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-01 21:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01 20:37 [PATCH] net: Reduce size of rps_sock_flow_sysctl Johanna Abrahamsson
2016-09-01 21:13 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.