Clean up the SYSINIT_FLAGS definitions for rwlock(9) and rmlock(9).
Avoid duplication in their macro definitions, and document them. No functional change intended. MFC after: 1 week
This commit is contained in:
parent
2b378326f8
commit
755230eb9f
@ -1548,6 +1548,7 @@ MLINKS+=rmlock.9 rm_assert.9 \
|
||||
rmlock.9 rm_runlock.9 \
|
||||
rmlock.9 rm_sleep.9 \
|
||||
rmlock.9 RM_SYSINIT.9 \
|
||||
rmlock.9 RM_SYSINIT_FLAGS.9 \
|
||||
rmlock.9 rm_try_rlock.9 \
|
||||
rmlock.9 rm_wlock.9 \
|
||||
rmlock.9 rm_wowned.9 \
|
||||
@ -1580,6 +1581,7 @@ MLINKS+=rwlock.9 rw_assert.9 \
|
||||
rwlock.9 rw_unlock.9 \
|
||||
rwlock.9 rw_sleep.9 \
|
||||
rwlock.9 RW_SYSINIT.9 \
|
||||
rwlock.9 RW_SYSINIT_FLAGS.9 \
|
||||
rwlock.9 rw_try_rlock.9 \
|
||||
rwlock.9 rw_try_upgrade.9 \
|
||||
rwlock.9 rw_try_wlock.9 \
|
||||
@ -1788,6 +1790,7 @@ MLINKS+=sx.9 sx_assert.9 \
|
||||
sx.9 sx_slock_sig.9 \
|
||||
sx.9 sx_sunlock.9 \
|
||||
sx.9 SX_SYSINIT.9 \
|
||||
sx.9 SX_SYSINIT_FLAGS.9 \
|
||||
sx.9 sx_try_slock.9 \
|
||||
sx.9 sx_try_upgrade.9 \
|
||||
sx.9 sx_try_xlock.9 \
|
||||
|
@ -26,7 +26,7 @@
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.\" Based on rwlock.9 man page
|
||||
.Dd December 13, 2014
|
||||
.Dd November 11, 2017
|
||||
.Dt RMLOCK 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -42,7 +42,8 @@
|
||||
.Nm rm_wowned ,
|
||||
.Nm rm_sleep ,
|
||||
.Nm rm_assert ,
|
||||
.Nm RM_SYSINIT
|
||||
.Nm RM_SYSINIT ,
|
||||
.Nm RM_SYSINIT_FLAGS
|
||||
.Nd kernel reader/writer lock optimized for read-mostly access patterns
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
@ -74,7 +75,8 @@
|
||||
.Ft void
|
||||
.Fn rm_assert "struct rmlock *rm" "int what"
|
||||
.In sys/kernel.h
|
||||
.Fn RM_SYSINIT "name" "struct rmlock *rm" "const char *desc" "int opts"
|
||||
.Fn RM_SYSINIT "name" "struct rmlock *rm" "const char *desc"
|
||||
.Fn RM_SYSINIT_FLAGS "name" "struct rmlock *rm" "const char *desc" "int flags"
|
||||
.Sh DESCRIPTION
|
||||
Read-mostly locks allow shared access to protected data by multiple threads,
|
||||
or exclusive access by a single thread.
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 28, 2016
|
||||
.Dd November 11, 2017
|
||||
.Dt RWLOCK 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -45,7 +45,8 @@
|
||||
.Nm rw_initialized ,
|
||||
.Nm rw_wowned ,
|
||||
.Nm rw_assert ,
|
||||
.Nm RW_SYSINIT
|
||||
.Nm RW_SYSINIT ,
|
||||
.Nm RW_SYSINIT_FLAGS
|
||||
.Nd kernel reader/writer lock
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
@ -88,6 +89,7 @@
|
||||
.Fn rw_assert "const struct rwlock *rw" "int what"
|
||||
.In sys/kernel.h
|
||||
.Fn RW_SYSINIT "name" "struct rwlock *rw" "const char *desc"
|
||||
.Fn RW_SYSINIT_FLAGS "name" "struct rwlock *rw" "const char *desc" "int flags"
|
||||
.Sh DESCRIPTION
|
||||
Reader/writer locks allow shared access to protected data by multiple threads,
|
||||
or exclusive access by a single thread.
|
||||
|
@ -26,7 +26,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 28, 2016
|
||||
.Dd November 11, 2017
|
||||
.Dt SX 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -49,7 +49,8 @@
|
||||
.Nm sx_xholder ,
|
||||
.Nm sx_xlocked ,
|
||||
.Nm sx_assert ,
|
||||
.Nm SX_SYSINIT
|
||||
.Nm SX_SYSINIT ,
|
||||
.Nm SX_SYSINIT_FLAGS
|
||||
.Nd kernel shared/exclusive lock
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
@ -95,7 +96,8 @@
|
||||
.Ft void
|
||||
.Fn sx_assert "const struct sx *sx" "int what"
|
||||
.In sys/kernel.h
|
||||
.Fn SX_SYSINIT "name" "struct sx *sx" "const char *description"
|
||||
.Fn SX_SYSINIT "name" "struct sx *sx" "const char *desc"
|
||||
.Fn SX_SYSINIT_FLAGS "name" "struct sx *sx" "const char *desc" "int flags"
|
||||
.Sh DESCRIPTION
|
||||
Shared/exclusive locks are used to protect data that are read far more often
|
||||
than they are written.
|
||||
@ -295,6 +297,12 @@ but with an additional argument,
|
||||
.Fa name ,
|
||||
that is used in generating unique variable names for the related
|
||||
structures associated with the lock and the sysinit routine.
|
||||
The
|
||||
.Fn SX_SYSINIT_FLAGS
|
||||
macro can similarly be used to initialize a given
|
||||
.Fa sx
|
||||
lock using
|
||||
.Fn sx_init_flags .
|
||||
.Pp
|
||||
A thread may not hold both a shared lock and an exclusive lock on the same
|
||||
lock simultaneously;
|
||||
|
@ -338,17 +338,10 @@ rm_wowned(const struct rmlock *rm)
|
||||
void
|
||||
rm_sysinit(void *arg)
|
||||
{
|
||||
struct rm_args *args = arg;
|
||||
struct rm_args *args;
|
||||
|
||||
rm_init(args->ra_rm, args->ra_desc);
|
||||
}
|
||||
|
||||
void
|
||||
rm_sysinit_flags(void *arg)
|
||||
{
|
||||
struct rm_args_flags *args = arg;
|
||||
|
||||
rm_init_flags(args->ra_rm, args->ra_desc, args->ra_opts);
|
||||
args = arg;
|
||||
rm_init_flags(args->ra_rm, args->ra_desc, args->ra_flags);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -240,16 +240,9 @@ _rw_destroy(volatile uintptr_t *c)
|
||||
void
|
||||
rw_sysinit(void *arg)
|
||||
{
|
||||
struct rw_args *args = arg;
|
||||
|
||||
rw_init((struct rwlock *)args->ra_rw, args->ra_desc);
|
||||
}
|
||||
|
||||
void
|
||||
rw_sysinit_flags(void *arg)
|
||||
{
|
||||
struct rw_args_flags *args = arg;
|
||||
struct rw_args *args;
|
||||
|
||||
args = arg;
|
||||
rw_init_flags((struct rwlock *)args->ra_rw, args->ra_desc,
|
||||
args->ra_flags);
|
||||
}
|
||||
|
@ -103,35 +103,21 @@ void _rm_assert(const struct rmlock *rm, int what, const char *file,
|
||||
struct rm_args {
|
||||
struct rmlock *ra_rm;
|
||||
const char *ra_desc;
|
||||
int ra_flags;
|
||||
};
|
||||
|
||||
struct rm_args_flags {
|
||||
struct rmlock *ra_rm;
|
||||
const char *ra_desc;
|
||||
int ra_opts;
|
||||
};
|
||||
|
||||
#define RM_SYSINIT(name, rm, desc) \
|
||||
#define RM_SYSINIT_FLAGS(name, rm, desc, flags) \
|
||||
static struct rm_args name##_args = { \
|
||||
(rm), \
|
||||
(desc), \
|
||||
(flags), \
|
||||
}; \
|
||||
SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rm_sysinit, &name##_args); \
|
||||
SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rm_destroy, (rm))
|
||||
|
||||
|
||||
#define RM_SYSINIT_FLAGS(name, rm, desc, opts) \
|
||||
static struct rm_args name##_args = { \
|
||||
(rm), \
|
||||
(desc), \
|
||||
(opts), \
|
||||
}; \
|
||||
SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rm_sysinit_flags, &name##_args); \
|
||||
SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rm_destroy, (rm))
|
||||
#define RM_SYSINIT(name, rm, desc) RM_SYSINIT_FLAGS(name, rm, desc, 0)
|
||||
|
||||
#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
|
||||
#define RA_LOCKED LA_LOCKED
|
||||
|
@ -220,35 +220,21 @@ void __rw_assert(const volatile uintptr_t *c, int what, const char *file,
|
||||
struct rw_args {
|
||||
void *ra_rw;
|
||||
const char *ra_desc;
|
||||
};
|
||||
|
||||
struct rw_args_flags {
|
||||
void *ra_rw;
|
||||
const char *ra_desc;
|
||||
int ra_flags;
|
||||
};
|
||||
|
||||
#define RW_SYSINIT(name, rw, desc) \
|
||||
#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \
|
||||
static struct rw_args name##_args = { \
|
||||
(rw), \
|
||||
(desc), \
|
||||
(flags), \
|
||||
}; \
|
||||
SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rw_sysinit, &name##_args); \
|
||||
SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
_rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock))
|
||||
|
||||
|
||||
#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \
|
||||
static struct rw_args_flags name##_args = { \
|
||||
(rw), \
|
||||
(desc), \
|
||||
(flags), \
|
||||
}; \
|
||||
SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
rw_sysinit_flags, &name##_args); \
|
||||
SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
|
||||
_rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock))
|
||||
#define RW_SYSINIT(name, rw, desc) RW_SYSINIT_FLAGS(name, rw, desc, 0)
|
||||
|
||||
/*
|
||||
* Options passed to rw_init_flags().
|
||||
|
Loading…
Reference in New Issue
Block a user