Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Sep 2023 15:04:16 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a87dddf39e86 - stable/14 - timerfd: convert timerfd_list_lock from sx to mtx
Message-ID:  <202309171504.38HF4G6T072197@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a87dddf39e866015341003eeac76d736d993514a

commit a87dddf39e866015341003eeac76d736d993514a
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-09-17 15:01:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-09-17 15:01:33 +0000

    timerfd: convert timerfd_list_lock from sx to mtx
    
    There was no good reason to use the former. This should prevent some
    head-scratching by an interested and qualified reader.
    
    (cherry picked from commit f4296cfb409a48de00bfa60e76f686c2b031876f)
---
 sys/kern/sys_timerfd.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sys/kern/sys_timerfd.c b/sys/kern/sys_timerfd.c
index c8b45a926b02..e4d2f10f28ef 100644
--- a/sys/kern/sys_timerfd.c
+++ b/sys/kern/sys_timerfd.c
@@ -61,9 +61,9 @@
 
 static MALLOC_DEFINE(M_TIMERFD, "timerfd", "timerfd structures");
 
-static struct sx timerfd_list_lock;
+static struct mtx timerfd_list_lock;
 static LIST_HEAD(, timerfd) timerfd_list;
-SX_SYSINIT(timerfd, &timerfd_list_lock, "timerfd_list_lock");
+MTX_SYSINIT(timerfd, &timerfd_list_lock, "timerfd_list_lock", MTX_DEF);
 
 static struct unrhdr64 tfdino_unr;
 
@@ -133,7 +133,7 @@ timerfd_jumped(void)
 		return;
 
 	timerfd_getboottime(&boottime);
-	sx_xlock(&timerfd_list_lock);
+	mtx_lock(&timerfd_list_lock);
 	LIST_FOREACH(tfd, &timerfd_list, entry) {
 		mtx_lock(&tfd->tfd_lock);
 		if (tfd->tfd_clockid != CLOCK_REALTIME ||
@@ -169,7 +169,7 @@ timerfd_jumped(void)
 		tfd->tfd_boottim = boottime;
 		mtx_unlock(&tfd->tfd_lock);
 	}
-	sx_xunlock(&timerfd_list_lock);
+	mtx_unlock(&timerfd_list_lock);
 }
 
 static int
@@ -324,9 +324,9 @@ timerfd_close(struct file *fp, struct thread *td)
 {
 	struct timerfd *tfd = fp->f_data;
 
-	sx_xlock(&timerfd_list_lock);
+	mtx_lock(&timerfd_list_lock);
 	LIST_REMOVE(tfd, entry);
-	sx_xunlock(&timerfd_list_lock);
+	mtx_unlock(&timerfd_list_lock);
 
 	callout_drain(&tfd->tfd_callout);
 	seldrain(&tfd->tfd_sel);
@@ -450,9 +450,9 @@ kern_timerfd_create(struct thread *td, int clockid, int flags)
 	knlist_init_mtx(&tfd->tfd_sel.si_note, &tfd->tfd_lock);
 	timerfd_getboottime(&tfd->tfd_boottim);
 	getnanotime(&tfd->tfd_birthtim);
-	sx_xlock(&timerfd_list_lock);
+	mtx_lock(&timerfd_list_lock);
 	LIST_INSERT_HEAD(&timerfd_list, tfd, entry);
-	sx_xunlock(&timerfd_list_lock);
+	mtx_unlock(&timerfd_list_lock);
 
 	finit(fp, fflags, DTYPE_TIMERFD, tfd, &timerfdops);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309171504.38HF4G6T072197>