]> git.proxmox.com Git - mirror_spl.git/commitdiff
kmem-cache: Use a taskq for async allocations
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 10 Dec 2012 21:40:03 +0000 (13:40 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 12 Dec 2012 17:56:54 +0000 (09:56 -0800)
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 <behlendorf1@llnl.gov>
include/sys/kmem.h
module/spl/spl-kmem.c

index e189922efe7ae58d1c2fed783a8c423c0a5932c2..6904bec3f18a3da7e232585ca7d803e19157eed7 100644 (file)
@@ -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 {
index 3900c9cf0568fe45f20b01cd3020efea28de0149..bc08a559824d7ddca63d8b7e80643a63aca42d1b 100644 (file)
@@ -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);
        }
 
        /*