Module Name: src Committed By: thorpej Date: Tue Dec 21 19:07:09 UTC 2021
Modified Files: src/sys/external/bsd/common/include/linux: slab.h src/sys/external/bsd/drm2/dist/drm/i915: i915_request.c Log Message: - 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(). To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/common/include/linux/slab.h cvs rdiff -u -r1.12 -r1.13 \ src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/common/include/linux/slab.h diff -u src/sys/external/bsd/common/include/linux/slab.h:1.10 src/sys/external/bsd/common/include/linux/slab.h:1.11 --- src/sys/external/bsd/common/include/linux/slab.h:1.10 Sun Dec 19 12:20:46 2021 +++ src/sys/external/bsd/common/include/linux/slab.h Tue Dec 21 19:07:09 2021 @@ -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 @@ kmem_cache_dtor(void *cookie, void *ptr) (*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 @@ kmem_cache_create_dtor(const char *name, 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 @@ kmem_cache_create_dtor(const char *name, 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; } Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c:1.12 src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c:1.13 --- src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c:1.12 Sun Dec 19 12:34:34 2021 +++ src/sys/external/bsd/drm2/dist/drm/i915/i915_request.c Tue Dec 21 19:07:09 2021 @@ -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 @@ static void __i915_request_dtor(void *ar { 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);