Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd - For kmem_cache_create_dtor(), use a pre-d...



details:   https://anonhg.NetBSD.org/src/rev/f33f35f79d52
branches:  trunk
changeset: 1029106:f33f35f79d52
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Dec 21 19:07:09 2021 +0000

description:
- For kmem_cache_create_dtor(), use a pre-destructor to issue the
  synchronize_rcu() if the caller uses SLAB_TYPESAFE_BY_RCU.  A
  special pool allocator is not required in this case.
- Now that SLAB_TYPESAFE_BY_RCU does the right thing, no need to
  call synchronize_rcu() in __i915_request_dtor().

diffstat:

 sys/external/bsd/common/include/linux/slab.h       |  18 +++++++++++++++---
 sys/external/bsd/drm2/dist/drm/i915/i915_request.c |   9 ++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

diffs (76 lines):

diff -r f2a523effa0b -r f33f35f79d52 sys/external/bsd/common/include/linux/slab.h
--- a/sys/external/bsd/common/include/linux/slab.h      Tue Dec 21 19:00:37 2021 +0000
+++ b/sys/external/bsd/common/include/linux/slab.h      Tue Dec 21 19:07:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: slab.h,v 1.10 2021/12/19 12:20:46 riastradh Exp $      */
+/*     $NetBSD: slab.h,v 1.11 2021/12/21 19:07:09 thorpej Exp $        */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -212,6 +212,12 @@
                (*kc->kc_dtor)(ptr);
 }
 
+static void
+kmem_cache_pre_dtor(void *cookie)
+{
+       synchronize_rcu();
+}
+
 static inline struct kmem_cache *
 kmem_cache_create(const char *name, size_t size, size_t align,
     unsigned long flags, void (*ctor)(void *))
@@ -243,8 +249,10 @@
 
        if (ISSET(flags, SLAB_HWCACHE_ALIGN))
                align = roundup(MAX(1, align), CACHE_LINE_SIZE);
-       if (ISSET(flags, SLAB_TYPESAFE_BY_RCU))
-               palloc = &pool_allocator_kmem_rcu;
+       /*
+        * No need to use pool_allocator_kmem_rcu here; RCU synchronization
+        * will be handled by the pre-destructor hook.
+        */
 
        kc = kmem_alloc(sizeof(*kc), KM_SLEEP);
        kc->kc_pool_cache = pool_cache_init(size, align, 0, 0, name, palloc,
@@ -252,6 +260,10 @@
        kc->kc_size = size;
        kc->kc_ctor = ctor;
        kc->kc_dtor = dtor;
+       if (ISSET(flags, SLAB_TYPESAFE_BY_RCU)) {
+               pool_cache_setpredestruct(kc->kc_pool_cache,
+                   kmem_cache_pre_dtor);
+       }
 
        return kc;
 }
diff -r f2a523effa0b -r f33f35f79d52 sys/external/bsd/drm2/dist/drm/i915/i915_request.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_request.c        Tue Dec 21 19:00:37 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_request.c        Tue Dec 21 19:07:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_request.c,v 1.12 2021/12/19 12:34:34 riastradh Exp $      */
+/*     $NetBSD: i915_request.c,v 1.13 2021/12/21 19:07:09 thorpej Exp $        */
 
 /*
  * Copyright © 2008-2015 Intel Corporation
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_request.c,v 1.12 2021/12/19 12:34:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_request.c,v 1.13 2021/12/21 19:07:09 thorpej Exp $");
 
 #include <linux/dma-fence-array.h>
 #include <linux/irq_work.h>
@@ -614,11 +614,6 @@
 {
        struct i915_request *rq = arg;
 
-#ifdef __NetBSD__
-       /* XXX pool cache does not guarantee this for us.  */
-       synchronize_rcu();
-#endif
-
        dma_fence_destroy(&rq->fence);
 #ifdef __NetBSD__
        i915_sw_fence_fini(&rq->submit);



Home | Main Index | Thread Index | Old Index