Source-Changes-HG archive

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

[src/netbsd-8]: src/external/cddl/osnet/sys/sys Pull up following revision(s)...



details:   https://anonhg.NetBSD.org/src/rev/ed45a1590217
branches:  netbsd-8
changeset: 434771:ed45a1590217
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 22 11:03:51 2018 +0000

description:
Pull up following revision(s) (requested by maya in ticket #651):
        external/cddl/osnet/sys/sys/kmem.h: revision 1.8
        external/cddl/osnet/sys/sys/kmem.h: revision 1.9
        external/cddl/osnet/sys/sys/kmem.h: revision 1.7

our pool code needs either PR_SLEEP or PR_NOWAIT; arrange for that explaining
the current choice :-)

use symbolic constant for 0

Let's define symbols before using them.

diffstat:

 external/cddl/osnet/sys/sys/kmem.h |  33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r 1799a7c6e263 -r ed45a1590217 external/cddl/osnet/sys/sys/kmem.h
--- a/external/cddl/osnet/sys/sys/kmem.h        Wed Mar 21 10:52:15 2018 +0000
+++ b/external/cddl/osnet/sys/sys/kmem.h        Thu Mar 22 11:03:51 2018 +0000
@@ -1,5 +1,5 @@
 
-/*     $NetBSD: kmem.h,v 1.6 2010/02/21 01:46:36 darran Exp $  */
+/*     $NetBSD: kmem.h,v 1.6.38.1 2018/03/22 11:03:51 martin Exp $     */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -37,13 +37,16 @@
 #include_next <sys/pool.h>
 #include_next <sys/vmem.h>
 
+#define        KM_PUSHPAGE     0x00    /* XXXNETBSD */
+#define        KMC_NODEBUG     0x00
+
 typedef void kmem_cache_t;
 
 u_long kmem_size(void);
 u_long kmem_used(void);
 void   kmem_reap(void);
 
-void   *calloc(size_t n, size_t s);
+void   *calloc(size_t, size_t);
 
 static inline kmem_cache_t *
 kmem_cache_create(char *name, size_t bufsize, size_t align,
@@ -62,12 +65,30 @@
        return pc;
 }
 
+static inline void *
+kmem_cache_alloc(kmem_cache_t *cache, int flags)
+{
+       /*
+        * This happens when we specify KM_PUSHPAGE by itself.
+        *
+        * According to kmem_cache_create(9) KM_PUSHPAGE can be used
+        * together with KM_SLEEP and in that case the code will not
+        * cause a deadlock. It does not say if KM_PUSHPAGE can be
+        * used with KM_NOSLEEP. In our case, we don't have a pool
+        * of emergency pages, so we prefer to KM_SLEEP instead of
+        * using KM_NOSLEEP and potentially returning NULL, under the
+        * assumption that the code wants to use the emergency pool
+        * because it does not want the allocation to fail. If that
+        * causes a deadlock we either need to provide an emergency
+        * pool or handle the failure.
+        */
+       if (flags == KM_PUSHPAGE)
+               flags |= KM_SLEEP;
+       return pool_cache_get(cache, flags);
+}
+
 #define        kmem_cache_destroy(cache)               pool_cache_destroy(cache)
-#define        kmem_cache_alloc(cache, flags)          pool_cache_get(cache, flags)
 #define        kmem_cache_free(cache, buf)             pool_cache_put(cache, buf)
 #define        kmem_cache_reap_now(cache)              pool_cache_invalidate(cache)
 
-#define        KM_PUSHPAGE     0x00    /* XXXNETBSD */
-#define        KMC_NODEBUG     0x00
-
 #endif /* _OPENSOLARIS_SYS_KMEM_H_ */



Home | Main Index | Thread Index | Old Index