All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-stable] mm-memfd_luo-optimize-shmem_recalc_inode-calls-in-retrieve-path.patch removed from -mm tree
@ 2026-04-18  7:56 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-04-18  7:56 UTC (permalink / raw)
  To: mm-commits, rppt, pratyush, pasha.tatashin, jianghaoran,
	duanchenghao, akpm


The quilt patch titled
     Subject: mm/memfd_luo: optimize shmem_recalc_inode calls in retrieve path
has been removed from the -mm tree.  Its filename was
     mm-memfd_luo-optimize-shmem_recalc_inode-calls-in-retrieve-path.patch

This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Chenghao Duan <duanchenghao@kylinos.cn>
Subject: mm/memfd_luo: optimize shmem_recalc_inode calls in retrieve path
Date: Thu, 26 Mar 2026 16:47:22 +0800

Move shmem_recalc_inode() out of the loop in memfd_luo_retrieve_folios()
to improve performance when restoring large memfds.

Currently, shmem_recalc_inode() is called for each folio during restore,
which is O(n) expensive operations.  This patch collects the number of
successfully added folios and calls shmem_recalc_inode() once after the
loop completes, reducing complexity to O(1).

Additionally, fix the error path to also call shmem_recalc_inode() for the
folios that were successfully added before the error occurred.

Link: https://lore.kernel.org/20260326084727.118437-3-duanchenghao@kylinos.cn
Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Haoran Jiang <jianghaoran@kylinos.cn>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memfd_luo.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/mm/memfd_luo.c~mm-memfd_luo-optimize-shmem_recalc_inode-calls-in-retrieve-path
+++ a/mm/memfd_luo.c
@@ -410,7 +410,7 @@ static int memfd_luo_retrieve_folios(str
 	struct inode *inode = file_inode(file);
 	struct address_space *mapping = inode->i_mapping;
 	struct folio *folio;
-	long npages;
+	long npages, nr_added_pages = 0;
 	int err = -EIO;
 	long i;
 
@@ -465,12 +465,14 @@ static int memfd_luo_retrieve_folios(str
 			goto unlock_folio;
 		}
 
-		shmem_recalc_inode(inode, npages, 0);
+		nr_added_pages += npages;
 		folio_add_lru(folio);
 		folio_unlock(folio);
 		folio_put(folio);
 	}
 
+	shmem_recalc_inode(inode, nr_added_pages, 0);
+
 	return 0;
 
 unlock_folio:
@@ -489,6 +491,8 @@ put_folios:
 			folio_put(folio);
 	}
 
+	shmem_recalc_inode(inode, nr_added_pages, 0);
+
 	return err;
 }
 
_

Patches currently in -mm which might be from duanchenghao@kylinos.cn are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-18  7:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18  7:56 [merged mm-stable] mm-memfd_luo-optimize-shmem_recalc_inode-calls-in-retrieve-path.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.