Skip to content

Commit

Permalink
inet_diag: skip over empty buckets
Browse files Browse the repository at this point in the history
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 <edumazet@google.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Eric Dumazet authored and Paolo Abeni committed Jan 23, 2024
1 parent f44e649 commit 622a08e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
@@ -1045,6 +1045,10 @@ void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
num = 0;
ilb = &hashinfo->lhash2[i];

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

if (hlist_empty(&ibb->chain)) {
s_num = 0;
continue;
}
spin_lock_bh(&ibb->lock);
inet_bind_bucket_for_each(tb2, &ibb->chain) {
if (!net_eq(ib2_net(tb2), net))

0 comments on commit 622a08e

Please sign in to comment.