Module Name:    src
Committed By:   ad
Date:           Tue Jan 28 16:33:34 UTC 2020

Modified Files:
        src/common/lib/libc/gen: radixtree.c
        src/sys/sys: radixtree.h

Log Message:
Add a radix_tree_await_memory(), for kernel use.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/common/lib/libc/gen/radixtree.c
cvs rdiff -u -r1.6 -r1.7 src/sys/sys/radixtree.h

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

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.21 src/common/lib/libc/gen/radixtree.c:1.22
--- src/common/lib/libc/gen/radixtree.c:1.21	Sun Jan 12 20:00:41 2020
+++ src/common/lib/libc/gen/radixtree.c	Tue Jan 28 16:33:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $	*/
 
 /*-
  * Copyright (c)2011,2012,2013 YAMAMOTO Takashi,
@@ -112,7 +112,7 @@
 #include <sys/cdefs.h>
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $");
 #include <sys/param.h>
 #include <sys/errno.h>
 #include <sys/pool.h>
@@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c,
 #include <lib/libsa/stand.h>
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.21 2020/01/12 20:00:41 para Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.22 2020/01/28 16:33:34 ad Exp $");
 #include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -349,6 +349,23 @@ radix_tree_init(void)
 	    radix_tree_node_ctor, NULL, NULL);
 	KASSERT(radix_tree_node_cache != NULL);
 }
+
+/*
+ * radix_tree_await_memory:
+ *
+ * after an insert has failed with ENOMEM, wait for memory to become
+ * available, so the caller can retry.
+ */
+
+void
+radix_tree_await_memory(void)
+{
+	struct radix_tree_node *n;
+
+	n = pool_cache_get(radix_tree_node_cache, PR_WAITOK);
+	pool_cache_put(radix_tree_node_cache, n);
+}
+
 #endif /* defined(_KERNEL) */
 
 static bool __unused

Index: src/sys/sys/radixtree.h
diff -u src/sys/sys/radixtree.h:1.6 src/sys/sys/radixtree.h:1.7
--- src/sys/sys/radixtree.h:1.6	Thu Dec  5 18:32:25 2019
+++ src/sys/sys/radixtree.h	Tue Jan 28 16:33:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.h,v 1.6 2019/12/05 18:32:25 ad Exp $	*/
+/*	$NetBSD: radixtree.h,v 1.7 2020/01/28 16:33:34 ad Exp $	*/
 
 /*-
  * Copyright (c)2011 YAMAMOTO Takashi,
@@ -47,6 +47,7 @@ struct radix_tree {
 
 #if defined(_KERNEL)
 void radix_tree_init(void);
+void radix_tree_await_memory(void);
 #endif /* defined(_KERNEL) */
 
 /*

Reply via email to