Thread (13 messages) 13 messages, 2 authors, 2022-08-30

Re: [PATCH v2 net-next 5/5] tcp: Introduce optional per-netns ehash.

From: Eric Dumazet <edumazet@google.com>
Date: 2022-08-29 22:59:20

On Mon, Aug 29, 2022 at 9:21 AM Kuniyuki Iwashima [off-list ref] wrote:
The more sockets we have in the hash table, the longer we spend looking
up the socket.  While running a number of small workloads on the same
host, they penalise each other and cause performance degradation.>
...
+static int proc_tcp_child_ehash_entries(struct ctl_table *table, int write,
+                                       void *buffer, size_t *lenp, loff_t *ppos)
+{
+       unsigned int tcp_child_ehash_entries;
+       int ret;
+
+       ret = proc_douintvec_minmax(table, write, buffer, lenp, ppos);
+       if (!write || ret)
+               return ret;
+
+       tcp_child_ehash_entries = READ_ONCE(*(unsigned int *)table->data);
+       if (tcp_child_ehash_entries)
+               tcp_child_ehash_entries = roundup_pow_of_two(tcp_child_ehash_entries);
This is not thread safe.

You could simply perform the roundup_pow_of_two() elsewhere,
eg in tcp_set_hashinfo() (and leave the sysctl as set by the user)
+
+       WRITE_ONCE(*(unsigned int *)table->data, tcp_child_ehash_entries);
+
+       return 0;
+}
+
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help