From 33e94ef1dd2678e28a5fbdb80f4ce35fd8c85974 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 10 Dec 2012 13:40:03 -0800 Subject: [PATCH] kmem-cache: Use a taskq for async allocations Shift the asynchronous allocations over to use the taskq interfaces. This allows us to abandon the kernels delayed work queue interface and all the compatibility code it requires. This code never actually used the delay functionality it was just done this way to leverage the existing compatibility code. All that is required is a thread context to perform the allocation in. The only thing clever in this change is that we take advantage of the preallocated task queue entries to avoid a memory allocation. Signed-off-by: Brian Behlendorf --- include/sys/kmem.h | 2 +- module/spl/spl-kmem.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/sys/kmem.h b/include/sys/kmem.h index e189922ef..6904bec3f 100644 --- a/include/sys/kmem.h +++ b/include/sys/kmem.h @@ -432,7 +432,7 @@ typedef struct spl_kmem_slab { typedef struct spl_kmem_alloc { struct spl_kmem_cache *ska_cache; /* Owned by cache */ int ska_flags; /* Allocation flags */ - struct delayed_work ska_work; /* Allocation work */ + taskq_ent_t ska_tqe; /* Task queue entry */ } spl_kmem_alloc_t; typedef struct spl_kmem_emergency { diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index 3900c9cf0..bc08a5598 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -1697,8 +1697,7 @@ spl_cache_obj(spl_kmem_cache_t *skc, spl_kmem_slab_t *sks) static void spl_cache_grow_work(void *data) { - spl_kmem_alloc_t *ska = - spl_get_work_data(data, spl_kmem_alloc_t, ska_work.work); + spl_kmem_alloc_t *ska = (spl_kmem_alloc_t *)data; spl_kmem_cache_t *skc = ska->ska_cache; spl_kmem_slab_t *sks; @@ -1777,8 +1776,9 @@ spl_cache_grow(spl_kmem_cache_t *skc, int flags, void **obj) atomic_inc(&skc->skc_ref); ska->ska_cache = skc; ska->ska_flags = flags & ~__GFP_FS; - spl_init_delayed_work(&ska->ska_work, spl_cache_grow_work, ska); - schedule_delayed_work(&ska->ska_work, 0); + taskq_init_ent(&ska->ska_tqe); + taskq_dispatch_ent(spl_kmem_cache_taskq, + spl_cache_grow_work, ska, 0, &ska->ska_tqe); } /*