[RH7] ploop: Use kmem_cache for iocb allocation

Submitted by Kirill Tkhai on June 1, 2020, 3:31 p.m.

Details

Message ID 159102547454.197279.784920630896515807.stgit@localhost.localdomain
State New
Series "ploop: Use kmem_cache for iocb allocation"
Headers show

Commit Message

Kirill Tkhai June 1, 2020, 3:31 p.m.
This should work better in memory pressure.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    2 +-
 fs/aio.c                      |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 7ca3374cce3b..855c1c601eaa 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -810,7 +810,7 @@  kaio_sync_io(struct ploop_io * io, int op, struct page **pages,
 	else
 		bvec = kmalloc(sizeof(*bvec) * nr_pages, GFP_NOIO);
 	if (!bvec) {
-		kfree(iocb);
+		aio_kernel_free(iocb);
 		return -ENOMEM;
 	}
 
diff --git a/fs/aio.c b/fs/aio.c
index 96bebbfb5e58..e260710f8d91 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1546,7 +1546,9 @@  static ssize_t aio_run_iocb(struct kiocb *req, bool compat)
  */
 struct kiocb *aio_kernel_alloc(gfp_t gfp)
 {
-	struct kiocb *iocb = kzalloc(sizeof(struct kiocb), gfp);
+	struct kiocb *iocb;
+
+	iocb = kmem_cache_alloc(kiocb_cachep, gfp);
 	if (iocb)
 		iocb->ki_ctx = (void *)-1;
 	return iocb;
@@ -1555,7 +1557,7 @@  EXPORT_SYMBOL_GPL(aio_kernel_alloc);
 
 void aio_kernel_free(struct kiocb *iocb)
 {
-	kfree(iocb);
+	kmem_cache_free(kiocb_cachep, iocb);
 }
 EXPORT_SYMBOL_GPL(aio_kernel_free);