Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Add a radix_tree_await_memory(), for kernel use.



details:   https://anonhg.NetBSD.org/src/rev/62ed107f5f0c
branches:  trunk
changeset: 1006814:62ed107f5f0c
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Jan 28 16:33:34 2020 +0000

description:
Add a radix_tree_await_memory(), for kernel use.

diffstat:

 common/lib/libc/gen/radixtree.c |  23 ++++++++++++++++++++---
 sys/sys/radixtree.h             |   3 ++-
 2 files changed, 22 insertions(+), 4 deletions(-)

diffs (68 lines):

diff -r ae8e770a86e1 -r 62ed107f5f0c common/lib/libc/gen/radixtree.c
--- a/common/lib/libc/gen/radixtree.c   Tue Jan 28 13:08:40 2020 +0000
+++ b/common/lib/libc/gen/radixtree.c   Tue Jan 28 16:33:34 2020 +0000
@@ -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 @@
 #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_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
diff -r ae8e770a86e1 -r 62ed107f5f0c sys/sys/radixtree.h
--- a/sys/sys/radixtree.h       Tue Jan 28 13:08:40 2020 +0000
+++ b/sys/sys/radixtree.h       Tue Jan 28 16:33:34 2020 +0000
@@ -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 @@
 
 #if defined(_KERNEL)
 void radix_tree_init(void);
+void radix_tree_await_memory(void);
 #endif /* defined(_KERNEL) */
 
 /*



Home | Main Index | Thread Index | Old Index