aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/unpcb.h
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-09-15 19:21:33 +0000
committerMark Johnston <markj@FreeBSD.org>2020-09-15 19:21:33 +0000
commitd5cbccecd857bfc520cd3859391167e6f7beea05 (patch)
tree143efb1781c5afb9000a3359d664060f2dabfd55 /sys/sys/unpcb.h
parent9e9d3e134bf29e307e788db52ca9bf1ed080fd36 (diff)
downloadsrc-d5cbccecd857bfc520cd3859391167e6f7beea05.tar.gz
src-d5cbccecd857bfc520cd3859391167e6f7beea05.zip
Update unix domain socket locking comments.
- Define a locking key for unpcb members. - Rewrite some of the locking protocol description to make it less verbose and avoid referencing some subroutines which will be renamed. - Reorder includes. Reviewed by: glebius, kevans, kib Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26294
Notes
Notes: svn path=/head/; revision=365759
Diffstat (limited to 'sys/sys/unpcb.h')
-rw-r--r--sys/sys/unpcb.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h
index 217cd7016505..abc8586b4e69 100644
--- a/sys/sys/unpcb.h
+++ b/sys/sys/unpcb.h
@@ -65,30 +65,37 @@ typedef uint64_t unp_gen_t;
* Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
* so that changes in the sockbuf may be computed to modify
* back pressure on the sender accordingly.
+ *
+ * Locking key:
+ * (a) Atomic
+ * (c) Constant
+ * (g) Locked using linkage lock
+ * (l) Locked using list lock
+ * (p) Locked using pcb lock
*/
LIST_HEAD(unp_head, unpcb);
struct unpcb {
/* Cache line 1 */
- struct mtx unp_mtx; /* mutex */
- struct unpcb *unp_conn; /* control block of connected socket */
- volatile u_int unp_refcount;
- short unp_flags; /* flags */
- short unp_gcflag; /* Garbage collector flags. */
- struct sockaddr_un *unp_addr; /* bound address of socket */
- struct socket *unp_socket; /* pointer back to socket */
+ struct mtx unp_mtx; /* PCB mutex */
+ struct unpcb *unp_conn; /* (p) connected socket */
+ volatile u_int unp_refcount; /* (a, p) atomic refcount */
+ short unp_flags; /* (p) PCB flags */
+ short unp_gcflag; /* (g) Garbage collector flags */
+ struct sockaddr_un *unp_addr; /* (p) bound address of socket */
+ struct socket *unp_socket; /* (c) pointer back to socket */
/* Cache line 2 */
- struct vnode *unp_vnode; /* if associated with file */
- struct xucred unp_peercred; /* peer credentials, if applicable */
- LIST_ENTRY(unpcb) unp_reflink; /* link in unp_refs list */
- LIST_ENTRY(unpcb) unp_link; /* glue on list of all PCBs */
- struct unp_head unp_refs; /* referencing socket linked list */
- unp_gen_t unp_gencnt; /* generation count of this instance */
- struct file *unp_file; /* back-pointer to file for gc. */
- u_int unp_msgcount; /* references from message queue */
- u_int unp_gcrefs; /* garbage collector refcount */
- ino_t unp_ino; /* fake inode number */
- LIST_ENTRY(unpcb) unp_dead; /* link in dead list */
+ struct vnode *unp_vnode; /* (p) associated file if applicable */
+ struct xucred unp_peercred; /* (p) peer credentials if applicable */
+ LIST_ENTRY(unpcb) unp_reflink; /* (l) link in unp_refs list */
+ LIST_ENTRY(unpcb) unp_link; /* (g) glue on list of all PCBs */
+ struct unp_head unp_refs; /* (l) referencing socket linked list */
+ unp_gen_t unp_gencnt; /* (g) generation count of this item */
+ struct file *unp_file; /* (g) back-pointer to file for gc */
+ u_int unp_msgcount; /* (g) references from message queue */
+ u_int unp_gcrefs; /* (g) garbage collector refcount */
+ ino_t unp_ino; /* (g) fake inode number */
+ LIST_ENTRY(unpcb) unp_dead; /* (g) link in dead list */
} __aligned(CACHE_LINE_SIZE);
/*