Module Name:    src
Committed By:   riastradh
Date:           Fri Sep  8 23:25:39 UTC 2023

Modified Files:
        src/sys/sys: once.h systm.h

Log Message:
once(9): Assert sleepable in RUN_ONCE, unconditionally.

Otherwise there's a good chance we'll never exercise many paths that
call RUN_ONCE when it's not sleepable, just because it's already been
done in a sleepable context before.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/sys/once.h
cvs rdiff -u -r1.302 -r1.303 src/sys/sys/systm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/once.h
diff -u src/sys/sys/once.h:1.7 src/sys/sys/once.h:1.8
--- src/sys/sys/once.h:1.7	Tue Mar 19 08:16:51 2019
+++ src/sys/sys/once.h	Fri Sep  8 23:25:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: once.h,v 1.7 2019/03/19 08:16:51 ryo Exp $	*/
+/*	$NetBSD: once.h,v 1.8 2023/09/08 23:25:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -30,6 +30,9 @@
 #ifndef _SYS_ONCE_H_
 #define	_SYS_ONCE_H_
 
+#include <sys/stdint.h>
+#include <sys/systm.h>
+
 typedef struct {
 	int o_error;
 	uint16_t o_refcnt;
@@ -50,7 +53,7 @@ void _fini_once(once_t *, void (*)(void)
 	};
 
 #define	RUN_ONCE(o, fn) \
-    (__predict_true((o)->o_status == ONCE_DONE) ? \
+    (ASSERT_SLEEPABLE(), __predict_true((o)->o_status == ONCE_DONE) ? \
       ((o)->o_error) : _init_once((o), (fn)))
 
 #define	INIT_ONCE(o, fn)	_init_once((o), (fn))

Index: src/sys/sys/systm.h
diff -u src/sys/sys/systm.h:1.302 src/sys/sys/systm.h:1.303
--- src/sys/sys/systm.h:1.302	Mon May 22 14:07:24 2023
+++ src/sys/sys/systm.h	Fri Sep  8 23:25:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: systm.h,v 1.302 2023/05/22 14:07:24 riastradh Exp $	*/
+/*	$NetBSD: systm.h,v 1.303 2023/09/08 23:25:39 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1988, 1991, 1993
@@ -762,7 +762,7 @@ void assert_sleepable(void);
 #if defined(DEBUG)
 #define	ASSERT_SLEEPABLE()	assert_sleepable()
 #else /* defined(DEBUG) */
-#define	ASSERT_SLEEPABLE()	do {} while (0)
+#define	ASSERT_SLEEPABLE()	__nothing
 #endif /* defined(DEBUG) */
 
 

Reply via email to