Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/cddl/osnet/sys/sys Update the kmem_cache emulation ...
details: https://anonhg.NetBSD.org/src/rev/af3f15ef4e7f
branches: trunk
changeset: 999173:af3f15ef4e7f
user: hannken <hannken%NetBSD.org@localhost>
date: Thu May 23 08:32:30 2019 +0000
description:
Update the kmem_cache emulation to run its callbacks with
Solaris argument order.
No functional change intended.
diffstat:
external/cddl/osnet/dist/uts/common/fs/zfs/arc.c | 9 -
external/cddl/osnet/dist/uts/common/fs/zfs/dbuf.c | 3 -
external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c | 3 -
external/cddl/osnet/dist/uts/common/fs/zfs/sa.c | 3 -
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c | 3 -
external/cddl/osnet/sys/kern/kmem.c | 98 +++++++++++++++++-
external/cddl/osnet/sys/sys/kmem.h | 49 ++------
7 files changed, 111 insertions(+), 57 deletions(-)
diffs (269 lines):
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/dist/uts/common/fs/zfs/arc.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/arc.c Thu May 23 08:32:30 2019 +0000
@@ -1578,9 +1578,6 @@
{
arc_buf_hdr_t *hdr = vbuf;
-#ifdef __NetBSD__
- hdr = unused;
-#endif
bzero(hdr, HDR_FULL_SIZE);
cv_init(&hdr->b_l1hdr.b_cv, NULL, CV_DEFAULT, NULL);
refcount_create(&hdr->b_l1hdr.b_refcnt);
@@ -1597,9 +1594,6 @@
{
arc_buf_hdr_t *hdr = vbuf;
-#ifdef __NetBSD__
- hdr = unused;
-#endif
bzero(hdr, HDR_L2ONLY_SIZE);
arc_space_consume(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS);
@@ -1612,9 +1606,6 @@
{
arc_buf_t *buf = vbuf;
-#ifdef __NetBSD__
- buf = unused;
-#endif
bzero(buf, sizeof (arc_buf_t));
mutex_init(&buf->b_evict_lock, NULL, MUTEX_DEFAULT, NULL);
arc_space_consume(sizeof (arc_buf_t), ARC_SPACE_HDRS);
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/dist/uts/common/fs/zfs/dbuf.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/dbuf.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/dbuf.c Thu May 23 08:32:30 2019 +0000
@@ -138,9 +138,6 @@
{
dmu_buf_impl_t *db = vdb;
-#ifdef __NetBSD__
- db = unused;
-#endif
bzero(db, sizeof (dmu_buf_impl_t));
mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL);
cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL);
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/dnode.c Thu May 23 08:32:30 2019 +0000
@@ -107,9 +107,6 @@
dnode_t *dn = arg;
int i;
-#ifdef __NetBSD__
- dn = unused;
-#endif
rw_init(&dn->dn_struct_rwlock, NULL, RW_DEFAULT, NULL);
mutex_init(&dn->dn_mtx, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&dn->dn_dbufs_mtx, NULL, MUTEX_DEFAULT, NULL);
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/dist/uts/common/fs/zfs/sa.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/sa.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/sa.c Thu May 23 08:32:30 2019 +0000
@@ -212,9 +212,6 @@
{
sa_handle_t *hdl = buf;
-#ifdef __NetBSD__
- hdl = unused;
-#endif
mutex_init(&hdl->sa_lock, NULL, MUTEX_DEFAULT, NULL);
return (0);
}
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c Thu May 23 08:32:30 2019 +0000
@@ -130,9 +130,6 @@
{
znode_t *zp = buf;
-#ifdef __NetBSD__
- zp = arg;
-#endif
POINTER_INVALIDATE(&zp->z_zfsvfs);
list_link_init(&zp->z_link_node);
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/sys/kern/kmem.c
--- a/external/cddl/osnet/sys/kern/kmem.c Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/sys/kern/kmem.c Thu May 23 08:32:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kmem.c,v 1.1 2018/05/28 21:05:09 chs Exp $ */
+/* $NetBSD: kmem.c,v 1.2 2019/05/23 08:32:30 hannken Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -28,6 +28,102 @@
#include <sys/kmem.h>
+struct kmem_cache {
+ pool_cache_t km_pool;
+ void *km_private;
+ int (*km_constructor)(void *, void *, int);
+ void (*km_destructor)(void *, void *);
+ void (*km_reclaim)(void *);
+};
+
+static int
+solaris_constructor(void *private, void *object, int flag)
+{
+ kmem_cache_t *km = private;
+
+ if (km->km_constructor)
+ return (*km->km_constructor)(object, km->km_private, flag);
+
+ return 0;
+}
+
+static void
+solaris_destructor(void *private, void *object)
+{
+ kmem_cache_t *km = private;
+
+ if (km->km_destructor)
+ (*km->km_destructor)(object, km->km_private);
+}
+
+static void
+solaris_reclaim(void *private, int flag)
+{
+
+ kmem_cache_t *km = private;
+
+ if (km->km_reclaim)
+ (*km->km_reclaim)(km->km_private);
+}
+
+kmem_cache_t *
+kmem_cache_create(char *name, size_t bufsize, size_t align,
+ int (*constructor)(void *, void *, int), void (*destructor)(void *, void *),
+ void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int flags)
+{
+ kmem_cache_t *km;
+
+ KASSERT(ISSET(flags, ~(KMC_NOTOUCH | KMC_NODEBUG)) == 0);
+ KASSERT(private == NULL);
+ KASSERT(vmp == NULL);
+
+ km = kmem_zalloc(sizeof(*km), KM_SLEEP);
+ km->km_private = private;
+ km->km_constructor = constructor;
+ km->km_destructor = destructor;
+ km->km_reclaim = reclaim;
+ km->km_pool = pool_cache_init(bufsize, align, 0, 0, name, NULL,
+ IPL_NONE, solaris_constructor, solaris_destructor, km);
+ if (km->km_pool == NULL) {
+ kmem_free(km, sizeof(*km));
+ return NULL;
+ }
+ if (reclaim)
+ pool_cache_set_drain_hook(km->km_pool, solaris_reclaim, km);
+
+ return km;
+}
+void
+kmem_cache_destroy(kmem_cache_t *km)
+{
+
+ pool_cache_destroy(km->km_pool);
+ kmem_free(km, sizeof(*km));
+}
+
+void *
+kmem_cache_alloc(kmem_cache_t *km, int flags)
+{
+
+ KASSERT(ISSET(flags, ~(KM_SLEEP | KM_NOSLEEP | KM_PUSHPAGE)) == 0);
+
+ return pool_cache_get(km->km_pool, flags);
+}
+
+void
+kmem_cache_free(kmem_cache_t *km, void *object)
+{
+
+ pool_cache_put(km->km_pool, object);
+}
+
+void
+kmem_cache_reap_now(kmem_cache_t *km)
+{
+
+ pool_cache_invalidate(km->km_pool);
+}
+
#undef kmem_alloc
#undef kmem_zalloc
#undef kmem_free
diff -r 9a16dabcaedb -r af3f15ef4e7f external/cddl/osnet/sys/sys/kmem.h
--- a/external/cddl/osnet/sys/sys/kmem.h Thu May 23 04:44:49 2019 +0000
+++ b/external/cddl/osnet/sys/sys/kmem.h Thu May 23 08:32:30 2019 +0000
@@ -1,5 +1,5 @@
-/* $NetBSD: kmem.h,v 1.10 2018/05/28 21:05:10 chs Exp $ */
+/* $NetBSD: kmem.h,v 1.11 2019/05/23 08:32:31 hannken Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -41,48 +41,27 @@
#define KM_NORMALPRI 0
#define KM_NODEBUG 0
-#define KMC_NODEBUG 0
-#define KMC_NOTOUCH 0
+#define KMC_NOTOUCH 0x00010000
+#define KMC_NODEBUG 0x00020000
-typedef void kmem_cache_t;
+struct kmem_cache;
+
+typedef struct kmem_cache kmem_cache_t;
#define POINTER_IS_VALID(p) (!((uintptr_t)(p) & 0x3))
#define POINTER_INVALIDATE(pp) (*(pp) = (void *)((uintptr_t)(*(pp)) | 0x1))
-void kmem_reap(void);
-
-static inline kmem_cache_t *
-kmem_cache_create(char *name, size_t bufsize, size_t align,
- int (*constructor)(void *, void *, int), void (*destructor)(void *, void *),
- void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags)
-{
- pool_cache_t pc;
- int flags = bufsize > PAGESIZE ? PR_NOALIGN : 0;
-
- KASSERT(vmp == NULL);
-
- pc = pool_cache_init(bufsize, align, 0, flags, name, NULL, IPL_NONE,
- constructor, destructor, private);
- if (pc != NULL && reclaim != NULL) {
- pool_cache_set_drain_hook(pc, (void *)reclaim, private);
- }
- return pc;
-}
-
-static inline void *
-kmem_cache_alloc(kmem_cache_t *cache, int flags)
-{
- return pool_cache_get(cache, flags);
-}
-
-#define kmem_cache_destroy(cache) pool_cache_destroy(cache)
-#define kmem_cache_free(cache, buf) pool_cache_put(cache, buf)
-#define kmem_cache_reap_now(cache) pool_cache_invalidate(cache)
+kmem_cache_t *kmem_cache_create(char *, size_t, size_t,
+ int (*)(void *, void *, int), void (*)(void *, void *),
+ void (*)(void *), void *, vmem_t *, int);
+void kmem_cache_destroy(kmem_cache_t *);
+void *kmem_cache_alloc(kmem_cache_t *, int);
+void kmem_cache_free(kmem_cache_t *, void *);
+void kmem_cache_reap_now(kmem_cache_t *);
+#define kmem_cache_set_move(cache, movefunc) do { } while (0)
#define heap_arena kmem_arena
-#define kmem_cache_set_move(cache, movefunc) do { } while (0)
-
#define kmem_alloc solaris_kmem_alloc
#define kmem_zalloc solaris_kmem_zalloc
#define kmem_free solaris_kmem_free
Home |
Main Index |
Thread Index |
Old Index