Skip to content

af_unix: Remove spin_lock_nested() and convert to lock_cmp_fn.

Kuniyuki Iwashima netdev 4 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest11 patches 0 repliesApplied 11/11
  2. v311 patches 1 replySuperseded
  3. v211 patches 8 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v111 patches6 repliesSuperseded

Changes in v4 from the cover letter

* Patch 4
* Make unix_state_lock_cmp_fn() symmetric.

Patches in v4 All 11 applied

#Subject and filesSizeRepliesApplied
1/11af_unix: Define locking order for unix_table_double_lock().net/unix/af_unix.c+11 -10 repliesApplied
2/11af_unix: Define locking order for U_LOCK_SECOND in unix_state_double_lock().net/unix/af_unix.c+15 -10 repliesApplied
3/11af_unix: Don't retry after unix_state_lock_nested() in unix_stream_connect().net/unix/af_unix.c+9 -250 repliesApplied
4/11af_unix: Define locking order for U_LOCK_SECOND in unix_stream_connect().include/net/af_unix.h net/unix/af_unix.c+36 -20 repliesApplied
5/11af_unix: Don't acquire unix_state_lock() for sock_i_ino().net/unix/diag.c+10 -200 repliesApplied
6/11af_unix: Remove U_LOCK_DIAG.include/net/af_unix.h net/unix/diag.c+3 -150 repliesApplied
7/11af_unix: Remove U_LOCK_GC_LISTENER.include/net/af_unix.h+0 -120 repliesApplied
8/11af_unix: Define locking order for U_RECVQ_LOCK_EMBRYO in unix_collect_skb().net/unix/af_unix.c net/unix/garbage.c+22 -70 repliesApplied
9/11af_unix: Set sk_peer_pid/sk_peer_cred locklessly for new socket.net/unix/af_unix.c+8 -30 repliesApplied
10/11af_unix: Remove put_pid()/put_cred() in copy_peercred().net/unix/af_unix.c+1 -80 repliesApplied
11/11af_unix: Don't use spin_lock_nested() in copy_peercred().net/unix/af_unix.c+3 -100 repliesApplied

Reviews trailers per patch

2 of 11 patches have a Reviewed-by or Acked-by.

PatchKent Overstreet
1/11R-b
2/11R-b
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 net-next 00/11] af_unix: Remove spin_lock_nested() and convert to lock_cmp_fn.

This series removes spin_lock_nested() in AF_UNIX and instead defines the locking orders as functions tied to each lock by lockdep_set_lock_cmp_fn().

When the defined function returns a negative value, lockdep considers it will not cause deadlock. (See ->cmp_fn() in check_deadlock() and check_prev_add().)

When we cannot define the total ordering, we return -1 for the allowed ordering and otherwise 0 as undefined. [0]

[0]: https://lore.kernel.org/netdev/thzkgbuwuo3knevpipu4rzsh5qgmwhklihypdgziiruabvh46f@uwdkpcfxgloo/

Changes:
v4:
* Patch 4
* Make unix_state_lock_cmp_fn() symmetric.

v3: https://lore.kernel.org/netdev/[email protected]/
* Patch 3
* Cache sk->sk_state
* s/unix_state_lock()/unix_state_unlock()/
* Patch 8
* Add embryo -> listener locking order

v2: https://lore.kernel.org/netdev/[email protected]/
* Patch 1 & 2
* Use (((l) > (r)) - ((l) < (r))) for comparison

v1: https://lore.kernel.org/netdev/[email protected]/

Kuniyuki Iwashima (11):
af_unix: Define locking order for unix_table_double_lock().
af_unix: Define locking order for U_LOCK_SECOND in
unix_state_double_lock().
af_unix: Don't retry after unix_state_lock_nested() in
unix_stream_connect().
af_unix: Define locking order for U_LOCK_SECOND in
unix_stream_connect().
af_unix: Don't acquire unix_state_lock() for sock_i_ino().
af_unix: Remove U_LOCK_DIAG.
af_unix: Remove U_LOCK_GC_LISTENER.
af_unix: Define locking order for U_RECVQ_LOCK_EMBRYO in

    unix_collect_skb().

af_unix: Set sk_peer_pid/sk_peer_cred locklessly for new socket.
af_unix: Remove put_pid()/put_cred() in copy_peercred().
af_unix: Don't use spin_lock_nested() in copy_peercred().

 include/net/af_unix.h |  14 ----
 net/unix/af_unix.c    | 151 ++++++++++++++++++++++++++++--------------
 net/unix/diag.c       |  47 ++++---------
 net/unix/garbage.c    |   8 +--
 4 files changed, 117 insertions(+), 103 deletions(-)
Signature · 1 line
2.30.2