|
|
Log in / Subscribe / Register

af_unix: Replace unix_table_lock with per-hash locks.

From:  Kuniyuki Iwashima <kuniyu-AT-amazon.co.jp>
To:  "David S. Miller" <davem-AT-davemloft.net>, Jakub Kicinski <kuba-AT-kernel.org>
Subject:  [PATCH v2 net-next 00/13] af_unix: Replace unix_table_lock with per-hash locks.
Date:  Sun, 14 Nov 2021 10:24:15 +0900
Message-ID:  <20211114012428.81743-1-kuniyu@amazon.co.jp>
Cc:  Eric Dumazet <eric.dumazet-AT-gmail.com>, Kuniyuki Iwashima <kuniyu-AT-amazon.co.jp>, Kuniyuki Iwashima <kuni1840-AT-gmail.com>, "Benjamin Herrenschmidt" <benh-AT-amazon.com>, <netdev-AT-vger.kernel.org>
Archive-link:  Article

The hash table of AF_UNIX sockets is protected by a single big lock,
unix_table_lock.  This series replaces it with small per-hash locks.

1st -  2nd : Misc refactoring
3rd -  8th : Separate BSD/abstract address logics
9th - 11th : Prep to save a hash in each socket
12th       : Replace the big lock
13th       : Speed up autobind()

After this series land in bpf-next, I will post another series to support
bpf batching iteration and bpf_(get|set)sockopt for AF_UNIX sockets.


Changelog:
  v2:
    12th: Use spin_lock_nested() (kernel test robot)
    13th: Avoid infinite loop (Eric Dumazet)
    13th: s/initnum/lastnum/

  v1:
  https://lore.kernel.org/netdev/20211106091712.15206-1-kun...


Kuniyuki Iwashima (13):
  af_unix: Use offsetof() instead of sizeof().
  af_unix: Pass struct sock to unix_autobind().
  af_unix: Factorise unix_find_other() based on address types.
  af_unix: Return an error as a pointer in unix_find_other().
  af_unix: Cut unix_validate_addr() out of unix_mkname().
  af_unix: Copy unix_mkname() into unix_find_(bsd|abstract)().
  af_unix: Remove unix_mkname().
  af_unix: Allocate unix_address in unix_bind_(bsd|abstract)().
  af_unix: Remove UNIX_ABSTRACT() macro and test sun_path[0] instead.
  af_unix: Add helpers to calculate hashes.
  af_unix: Save hash in sk_hash.
  af_unix: Replace the big lock with small locks.
  af_unix: Relax race in unix_autobind().

 include/net/af_unix.h                         |   3 +-
 net/unix/af_unix.c                            | 555 ++++++++++--------
 net/unix/diag.c                               |  23 +-
 .../selftests/bpf/progs/bpf_iter_unix.c       |   2 +-
 .../selftests/bpf/progs/bpf_tracing_net.h     |   2 -
 .../bpf/progs/test_skc_to_unix_sock.c         |   2 +-
 6 files changed, 333 insertions(+), 254 deletions(-)

-- 
2.30.2



Copyright © 2021, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds