Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Dec 2025 15:59:54 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a35eae89cbdd - main - rman: Simplify initialization of internal globals
Message-ID:  <6938477a.355ef.423ec863@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help

The branch main has been updated by jhb:

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

commit a35eae89cbddaac73d3b6c2b5c1b90e3a0c00997
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-12-09 15:59:19 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-12-09 15:59:19 +0000

    rman: Simplify initialization of internal globals
    
    Use TAILQ_HEAD_INITIALIZER and MTX_SYSINIT to remove the 'once' code
    from rman_init.
    
    Reviewed by:    des
    Differential Revision:  https://reviews.freebsd.org/D54142
---
 sys/kern/subr_rman.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index dbb09850d049..b8528104ba28 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -102,8 +102,10 @@ SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RWTUN,
 
 static MALLOC_DEFINE(M_RMAN, "rman", "Resource manager");
 
-struct rman_head rman_head;
+struct rman_head rman_head = TAILQ_HEAD_INITIALIZER(rman_head);
 static struct mtx rman_mtx; /* mutex to protect rman_head */
+MTX_SYSINIT(rman_mtx, &rman_mtx, "rman head", MTX_DEF);
+
 static int int_rman_release_resource(struct rman *rm, struct resource_i *r);
 
 static __inline struct resource_i *
@@ -121,14 +123,6 @@ int_alloc_resource(int malloc_flag)
 int
 rman_init(struct rman *rm)
 {
-	static int once = 0;
-
-	if (once == 0) {
-		once = 1;
-		TAILQ_INIT(&rman_head);
-		mtx_init(&rman_mtx, "rman head", NULL, MTX_DEF);
-	}
-
 	if (rm->rm_start == 0 && rm->rm_end == 0)
 		rm->rm_end = ~0;
 	if (rm->rm_type == RMAN_UNINIT)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6938477a.355ef.423ec863>