summaryrefslogtreecommitdiffstats
path: root/net/unix/diag.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2022-06-21 10:19:13 -0700
committerDavid S. Miller <davem@davemloft.net>2022-06-22 12:59:43 +0100
commit2f7ca90a0188b57a54d3b1159eb7874427a7e07a (patch)
treed1eec229ee1d66c1a9265f4fc411062b5f9f749b /net/unix/diag.c
parentcf2f225e2653734e66e91c09e1cbe004bfd3d4a7 (diff)
downloadlinux-stable-2f7ca90a0188b57a54d3b1159eb7874427a7e07a.tar.gz
linux-stable-2f7ca90a0188b57a54d3b1159eb7874427a7e07a.tar.bz2
linux-stable-2f7ca90a0188b57a54d3b1159eb7874427a7e07a.zip
af_unix: Remove unix_table_locks.
unix_table_locks are to protect the global hash table, unix_socket_table. The previous commit removed it, so let's clean up the unnecessary locks. Here is a test result on EC2 c5.9xlarge where 10 processes run concurrently in different netns and bind 100,000 sockets for each. without this series : 1m 38s with this series : 11s It is ~10x faster because the global hash table is split into 10 netns in this case. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/unix/diag.c')
-rw-r--r--net/unix/diag.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c
index 4d0f0ca6a1eb..105f522a89fe 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
@@ -13,7 +13,7 @@
static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb)
{
- /* might or might not have unix_table_locks */
+ /* might or might not have a hash table lock */
struct unix_address *addr = smp_load_acquire(&unix_sk(sk)->addr);
if (!addr)
@@ -208,7 +208,6 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct sock *sk;
num = 0;
- spin_lock(&unix_table_locks[slot]);
spin_lock(&net->unx.table.locks[slot]);
sk_for_each(sk, &net->unx.table.buckets[slot]) {
if (num < s_num)
@@ -220,14 +219,12 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
cb->nlh->nlmsg_seq,
NLM_F_MULTI) < 0) {
spin_unlock(&net->unx.table.locks[slot]);
- spin_unlock(&unix_table_locks[slot]);
goto done;
}
next:
num++;
}
spin_unlock(&net->unx.table.locks[slot]);
- spin_unlock(&unix_table_locks[slot]);
}
done:
cb->args[0] = slot;
@@ -242,18 +239,15 @@ static struct sock *unix_lookup_by_ino(struct net *net, unsigned int ino)
int i;
for (i = 0; i < UNIX_HASH_SIZE; i++) {
- spin_lock(&unix_table_locks[i]);
spin_lock(&net->unx.table.locks[i]);
sk_for_each(sk, &net->unx.table.buckets[i]) {
if (ino == sock_i_ino(sk)) {
sock_hold(sk);
spin_unlock(&net->unx.table.locks[i]);
- spin_unlock(&unix_table_locks[i]);
return sk;
}
}
spin_unlock(&net->unx.table.locks[i]);
- spin_unlock(&unix_table_locks[i]);
}
return NULL;
}