Skip to content

Commit 622a08e

Browse files
edumazetPaolo Abeni
authored andcommitted
inet_diag: skip over empty buckets
After the removal of inet_diag_table_mutex, sock_diag_table_mutex and sock_diag_mutex, I was able so see spinlock contention from inet_diag_dump_icsk() when running 100 parallel invocations. It is time to skip over empty buckets. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Guillaume Nault <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent f44e649 commit 622a08e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

net/ipv4/inet_diag.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,10 @@ void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
10451045
num = 0;
10461046
ilb = &hashinfo->lhash2[i];
10471047

1048+
if (hlist_nulls_empty(&ilb->nulls_head)) {
1049+
s_num = 0;
1050+
continue;
1051+
}
10481052
spin_lock(&ilb->lock);
10491053
sk_nulls_for_each(sk, node, &ilb->nulls_head) {
10501054
struct inet_sock *inet = inet_sk(sk);
@@ -1109,6 +1113,10 @@ void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
11091113
accum = 0;
11101114
ibb = &hashinfo->bhash2[i];
11111115

1116+
if (hlist_empty(&ibb->chain)) {
1117+
s_num = 0;
1118+
continue;
1119+
}
11121120
spin_lock_bh(&ibb->lock);
11131121
inet_bind_bucket_for_each(tb2, &ibb->chain) {
11141122
if (!net_eq(ib2_net(tb2), net))

0 commit comments

Comments
 (0)