Module Name: src
Committed By: martin
Date: Thu Mar 22 11:03:51 UTC 2018
Modified Files:
src/external/cddl/osnet/sys/sys [netbsd-8]: kmem.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.38.1 src/external/cddl/osnet/sys/sys/kmem.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/cddl/osnet/sys/sys/kmem.h
diff -u src/external/cddl/osnet/sys/sys/kmem.h:1.6 src/external/cddl/osnet/sys/sys/kmem.h:1.6.38.1
--- src/external/cddl/osnet/sys/sys/kmem.h:1.6 Sun Feb 21 01:46:36 2010
+++ src/external/cddl/osnet/sys/sys/kmem.h Thu Mar 22 11:03:51 2018
@@ -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 @@ kmem_cache_create(char *name, size_t buf
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_ */