Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108606675
D34452.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D34452.diff
View Options
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -3494,6 +3494,9 @@
#endif
#if defined(INVARIANTS) || defined(DEBUG_MEMGUARD) || defined(WITNESS)
+#if defined(INVARIANTS) && (defined(DDB) || defined(STACK))
+#include <sys/stack.h>
+#endif
#define UMA_ZALLOC_DEBUG
static int
uma_zalloc_debug(uma_zone_t zone, void **itemp, void *udata, int flags)
@@ -3515,6 +3518,31 @@
("uma_zalloc_debug: called within spinlock or critical section"));
KASSERT((zone->uz_flags & UMA_ZONE_PCPU) == 0 || (flags & M_ZERO) == 0,
("uma_zalloc_debug: allocating from a pcpu zone with M_ZERO"));
+
+ _Static_assert(M_NOWAIT != 0 && M_WAITOK != 0,
+ "M_NOWAIT and M_WAITOK must be non-zero for this assertion:");
+#if 0
+ /*
+ * Give the #elif clause time to find problems, then remove it
+ * and enable this. (Remove <sys/stack.h> above, too.)
+ */
+ KASSERT((flags & (M_NOWAIT|M_WAITOK)) == M_NOWAIT ||
+ (flags & (M_NOWAIT|M_WAITOK)) == M_WAITOK,
+ ("uma_zalloc_debug: must pass one of M_NOWAIT or M_WAITOK"));
+#elif defined(DDB) || defined(STACK)
+ if (__predict_false((flags & (M_NOWAIT|M_WAITOK)) != M_NOWAIT &&
+ (flags & (M_NOWAIT|M_WAITOK)) != M_WAITOK)) {
+ static int stack_count;
+ struct stack st;
+
+ if (stack_count < 10) {
+ ++stack_count;
+ printf("uma_zalloc* called with bad WAIT flags:\n");
+ stack_save(&st);
+ stack_print(&st);
+ }
+ }
+#endif
#endif
#ifdef DEBUG_MEMGUARD
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 8:20 PM (8 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16210635
Default Alt Text
D34452.diff (1 KB)
Attached To
Mode
D34452: uma_zalloc: assert M_NOWAIT ^ M_WAITOK
Attached
Detach File
Event Timeline
Log In to Comment