#include <linux/export.h>
#include <linux/syscalls.h>
#include <linux/backing-dev.h>
+#include <linux/pcpu_cache.h>
#include <linux/uio.h>
#include <linux/sched/signal.h>
static const struct file_operations aio_ring_fops;
static const struct address_space_operations aio_ctx_aops;
+static struct pcpu_alloc_cache alloc_cache;
+static DEFINE_PER_CPU(struct pcpu_cache, req_alloc_cache);
+
static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
{
struct qstr this = QSTR_INIT("[aio]", 5);
kiocb_cachep = KMEM_CACHE(aio_kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
+ pcpu_cache_init(&alloc_cache, &req_alloc_cache, kiocb_cachep);
+
pr_debug("sizeof(struct page) = %zu\n", sizeof(struct page));
return 0;
return NULL;
}
- req = kmem_cache_alloc(kiocb_cachep, GFP_KERNEL|__GFP_ZERO);
+ req = pcpu_cache_alloc(&alloc_cache, GFP_KERNEL|__GFP_ZERO);
if (unlikely(!req))
goto out_put;
fput(req->common.ki_filp);
if (req->ki_eventfd != NULL)
eventfd_ctx_put(req->ki_eventfd);
- kmem_cache_free(kiocb_cachep, req);
+ pcpu_cache_free(&alloc_cache, req);
}
static struct kioctx *lookup_ioctx(unsigned long ctx_id)