Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103071611
D33400.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D33400.diff
View Options
Index: share/man/man9/Makefile
===================================================================
--- share/man/man9/Makefile
+++ share/man/man9/Makefile
@@ -1367,6 +1367,7 @@
kqueue.9 knlist_init.9 \
kqueue.9 knlist_init_mtx.9 \
kqueue.9 knlist_init_rw_reader.9 \
+ kqueue.9 knlist_init_sx.9 \
kqueue.9 knlist_remove.9 \
kqueue.9 knlist_remove_inevent.9 \
kqueue.9 knote_fdclose.9 \
Index: share/man/man9/kqueue.9
===================================================================
--- share/man/man9/kqueue.9
+++ share/man/man9/kqueue.9
@@ -24,14 +24,14 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 12, 2021
+.Dd July 24, 2022
.Dt KQUEUE 9
.Os
.Sh NAME
.Nm kqueue_add_filteropts , kqueue_del_filteropts ,
.Nm kqfd_register ,
.Nm knote_fdclose ,
-.Nm knlist_init , knlist_init_mtx , knlist_init_rw_reader ,
+.Nm knlist_init , knlist_init_mtx , knlist_init_rw_reader , knlist_init_sx ,
.Nm knlist_add , knlist_remove , knlist_remove_inevent , knlist_empty ,
.Nm knlist_clear , knlist_delete , knlist_destroy ,
.Nm KNOTE_LOCKED , KNOTE_UNLOCKED
@@ -59,6 +59,8 @@
.Ft void
.Fn knlist_init_rw_reader "struct knlist *knl" "struct rwlock *lock"
.Ft void
+.Fn knlist_init_sx "struct knlist *knl" "struct sx *lock"
+.Ft void
.Fn knlist_add "struct knlist *knl" "struct knote *kn" "int islocked"
.Ft void
.Fn knlist_remove "struct knlist *knl" "struct knote *kn" "int islocked"
@@ -261,9 +263,10 @@
.Vt knlist
must be initialized with either
.Fn knlist_init ,
-.Fn knlist_init_mtx
+.Fn knlist_init_mtx ,
+.Fn knlist_init_rw_reader
or
-.Fn knlist_init_rw_reader .
+.Fn knlist_init_sx .
The
.Vt knlist
structure may be embedded into the object structure.
@@ -321,6 +324,16 @@
function.
.Pp
The function
+.Fn knlist_init_sx
+may be used to initialize a
+.Vt knlist
+when
+.Fa lock
+is a
+.Xr sx 9
+lock.
+.Pp
+The function
.Fn knlist_empty
returns true when there are no
.Vt knotes
Index: sys/kern/kern_event.c
===================================================================
--- sys/kern/kern_event.c
+++ sys/kern/kern_event.c
@@ -2535,6 +2535,30 @@
rw_assert((struct rwlock *)arg, RA_UNLOCKED);
}
+static void
+knlist_sx_xlock(void *arg)
+{
+
+ sx_xlock((struct sx *)arg);
+}
+
+static void
+knlist_sx_xunlock(void *arg)
+{
+
+ sx_xunlock((struct sx *)arg);
+}
+
+static void
+knlist_sx_assert_lock(void *arg, int what)
+{
+
+ if (what == LA_LOCKED)
+ sx_assert((struct sx *)arg, SX_LOCKED);
+ else
+ sx_assert((struct sx *)arg, SX_UNLOCKED);
+}
+
void
knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *),
void (*kl_unlock)(void *),
@@ -2588,6 +2612,14 @@
knlist_rw_assert_lock);
}
+void
+knlist_init_sx(struct knlist *knl, struct sx *lock)
+{
+
+ knlist_init(knl, lock, knlist_sx_xlock, knlist_sx_xunlock,
+ knlist_sx_assert_lock);
+}
+
void
knlist_destroy(struct knlist *knl)
{
Index: sys/sys/event.h
===================================================================
--- sys/sys/event.h
+++ sys/sys/event.h
@@ -326,6 +326,7 @@
struct knlist;
struct mtx;
struct rwlock;
+struct sx;
void knote(struct knlist *list, long hint, int lockflags);
void knote_fork(struct knlist *list, int pid);
@@ -338,6 +339,7 @@
void (*kl_unlock)(void *), void (*kl_assert_lock)(void *, int));
void knlist_init_mtx(struct knlist *knl, struct mtx *lock);
void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock);
+void knlist_init_sx(struct knlist *knl, struct sx *lock);
void knlist_destroy(struct knlist *knl);
void knlist_cleardel(struct knlist *knl, struct thread *td,
int islocked, int killkn);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 1:39 PM (22 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14762297
Default Alt Text
D33400.diff (3 KB)
Attached To
Mode
D33400: kqueue: add knlist_init_sx() for shared/exclusive locks
Attached
Detach File
Event Timeline
Log In to Comment