[RHEL7,COMMIT] ploop: Use kmem_cache for iocb allocation

Submitted by Konstantin Khorenko on June 1, 2020, 4:01 p.m.

Details

Message ID 202006011601.051G1NCI026068@finist-ce7.sw.ru
State New
Series "ploop: Use kmem_cache for iocb allocation"
Headers show

Commit Message

Konstantin Khorenko June 1, 2020, 4:01 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.4
------>
commit 5671c342ee694f51ef6bdff9f8c00908e17f63dc
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Mon Jun 1 19:01:23 2020 +0300

    ploop: Use kmem_cache for iocb allocation
    
    This should work better under 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 7ca3374cce3b5..855c1c601eaa7 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 96bebbfb5e586..e260710f8d910 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);