diff options
author | Jeff Layton <jlayton@redhat.com> | 2013-01-28 14:41:10 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-02-04 09:16:21 -0500 |
commit | 8a8bc40d9ba0890f88dbf7a7c8fa81ddc77c08e3 (patch) | |
tree | 30c6c2dcfeaa727bad2aa73738da8c5c871d0703 /fs/nfsd | |
parent | 09662d58d5a2d75c8c29558dda4fc5134ef14b25 (diff) |
nfsd: create a dedicated slabcache for DRC entries
Currently we use kmalloc() which wastes a little bit of memory on each
allocation since it's a power of 2 allocator. Since we're allocating a
1024 of these now, and may need even more later, let's create a new
slabcache for them.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfscache.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 972c14a033ee..4aad9e4a6161 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
@@ -26,6 +26,7 @@ | |||
26 | static struct hlist_head * cache_hash; | 26 | static struct hlist_head * cache_hash; |
27 | static struct list_head lru_head; | 27 | static struct list_head lru_head; |
28 | static int cache_disabled = 1; | 28 | static int cache_disabled = 1; |
29 | static struct kmem_cache *drc_slab; | ||
29 | 30 | ||
30 | /* | 31 | /* |
31 | * Calculate the hash index from an XID. | 32 | * Calculate the hash index from an XID. |
@@ -51,10 +52,15 @@ int nfsd_reply_cache_init(void) | |||
51 | struct svc_cacherep *rp; | 52 | struct svc_cacherep *rp; |
52 | int i; | 53 | int i; |
53 | 54 | ||
55 | drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep), | ||
56 | 0, 0, NULL); | ||
57 | if (!drc_slab) | ||
58 | goto out_nomem; | ||
59 | |||
54 | INIT_LIST_HEAD(&lru_head); | 60 | INIT_LIST_HEAD(&lru_head); |
55 | i = CACHESIZE; | 61 | i = CACHESIZE; |
56 | while (i) { | 62 | while (i) { |
57 | rp = kmalloc(sizeof(*rp), GFP_KERNEL); | 63 | rp = kmem_cache_alloc(drc_slab, GFP_KERNEL); |
58 | if (!rp) | 64 | if (!rp) |
59 | goto out_nomem; | 65 | goto out_nomem; |
60 | list_add(&rp->c_lru, &lru_head); | 66 | list_add(&rp->c_lru, &lru_head); |
@@ -85,13 +91,18 @@ void nfsd_reply_cache_shutdown(void) | |||
85 | if (rp->c_state == RC_DONE && rp->c_type == RC_REPLBUFF) | 91 | if (rp->c_state == RC_DONE && rp->c_type == RC_REPLBUFF) |
86 | kfree(rp->c_replvec.iov_base); | 92 | kfree(rp->c_replvec.iov_base); |
87 | list_del(&rp->c_lru); | 93 | list_del(&rp->c_lru); |
88 | kfree(rp); | 94 | kmem_cache_free(drc_slab, rp); |
89 | } | 95 | } |
90 | 96 | ||
91 | cache_disabled = 1; | 97 | cache_disabled = 1; |
92 | 98 | ||
93 | kfree (cache_hash); | 99 | kfree (cache_hash); |
94 | cache_hash = NULL; | 100 | cache_hash = NULL; |
101 | |||
102 | if (drc_slab) { | ||
103 | kmem_cache_destroy(drc_slab); | ||
104 | drc_slab = NULL; | ||
105 | } | ||
95 | } | 106 | } |
96 | 107 | ||
97 | /* | 108 | /* |