All of lore.kernel.org
 help / color / mirror / Atom feed
* [to-be-updated] mm-shmem-fix-too-little-space-for-tmpfs-only-fallback-4kb.patch removed from -mm tree
@ 2025-09-22 22:33 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2025-09-22 22:33 UTC (permalink / raw)
  To: mm-commits, hughd, da.gomez, baolin.wang, yanglincheng, akpm


The quilt patch titled
     Subject: mm: shmem: fix too little space for tmpfs only fallback 4KB
has been removed from the -mm tree.  Its filename was
     mm-shmem-fix-too-little-space-for-tmpfs-only-fallback-4kb.patch

This patch was dropped because an updated version will be issued

------------------------------------------------------
From: Vernon Yang <yanglincheng@kylinos.cn>
Subject: mm: shmem: fix too little space for tmpfs only fallback 4KB
Date: Mon, 8 Sep 2025 20:31:28 +0800

When the system memory is sufficient, allocating memory is always
successful, but when tmpfs size is low (e.g.  1MB), it falls back directly
from 2MB to 4KB, and other small granularity (8KB ~ 1024KB) will not be
tried.

Therefore add check whether the remaining space of tmpfs is sufficient for
allocation.  If there is too little space left, try smaller large folio.

Link: https://lkml.kernel.org/r/20250908123128.900254-1-vernon2gm@gmail.com
Fixes: acd7ccb284b8 ("mm: shmem: add large folio support for tmpfs")
Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/shmem.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/mm/shmem.c~mm-shmem-fix-too-little-space-for-tmpfs-only-fallback-4kb
+++ a/mm/shmem.c
@@ -1820,6 +1820,7 @@ static unsigned long shmem_suitable_orde
 					   unsigned long orders)
 {
 	struct vm_area_struct *vma = vmf ? vmf->vma : NULL;
+	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 	pgoff_t aligned_index;
 	unsigned long pages;
 	int order;
@@ -1835,6 +1836,18 @@ static unsigned long shmem_suitable_orde
 	while (orders) {
 		pages = 1UL << order;
 		aligned_index = round_down(index, pages);
+
+		/*
+		 * Check whether the remaining space of tmpfs is sufficient for
+		 * allocation. If there is too little space left, try smaller
+		 * large folio.
+		 */
+		if (sbinfo->max_blocks && percpu_counter_read(&sbinfo->used_blocks)
+						+ pages > sbinfo->max_blocks) {
+			order = next_order(&orders, order);
+			continue;
+		}
+
 		/*
 		 * Check for conflict before waiting on a huge allocation.
 		 * Conflict might be that a huge page has just been allocated
_

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



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

only message in thread, other threads:[~2025-09-22 22:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 22:33 [to-be-updated] mm-shmem-fix-too-little-space-for-tmpfs-only-fallback-4kb.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.