mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] mm: vmpressure: scale sampling window with machine size
@ 2026-07-15 14:36 deepakraog
  2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: deepakraog @ 2026-07-15 14:36 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kernel

The vmpressure window size was fixed at 512 pages (SWAP_CLUSTER_MAX * 16).
Scale it at boot from total memory and CPU count using the same fls-based
formula as vmstat per-zone thresholds, clamped between 128 and 2048 pages.

Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
---
 mm/vmpressure.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index f053554e5..8925d4ad3 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -33,9 +33,29 @@
  * SWAP_CLUSTER_MAX, it makes sense to use it for the window size as well.
  *
  * TODO: Make the window size depend on machine size, as we do for vmstat
- * thresholds. Currently we set it to 512 pages (2MB for 4KB pages).
+ * thresholds. Scales with CPU count and total memory at boot.
  */
-static const unsigned long vmpressure_win = SWAP_CLUSTER_MAX * 16;
+static unsigned long vmpressure_win;
+
+static unsigned long __init vmpressure_window_size(void)
+{
+	unsigned long win;
+	int mem;
+
+	mem = totalram_pages() >> (27 - PAGE_SHIFT);
+	win = SWAP_CLUSTER_MAX * (unsigned long)fls(num_online_cpus()) *
+	      (1 + fls(mem));
+	win = max(win, SWAP_CLUSTER_MAX * 4UL);
+	win = min(win, SWAP_CLUSTER_MAX * 64UL);
+	return win;
+}
+
+static int __init vmpressure_win_init(void)
+{
+	vmpressure_win = vmpressure_window_size();
+	return 0;
+}
+core_initcall(vmpressure_win_init);
 
 /*
  * These thresholds are used when we account memory pressure through
-- 
Deepak Rao Gaikwad


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS
  2026-07-15 14:36 [PATCH 1/4] mm: vmpressure: scale sampling window with machine size deepakraog
@ 2026-07-15 14:36 ` deepakraog
  2026-07-15 14:36 ` [PATCH 3/4] mm: vrealloc: grow vm_area mappings in place deepakraog
  2026-07-15 14:36 ` [PATCH 4/4] ceph: release unused cap reservation on readdir error deepakraog
  2 siblings, 0 replies; 5+ messages in thread
From: deepakraog @ 2026-07-15 14:36 UTC (permalink / raw)
  To: Shuah Khan, linux-kernel, linux-fsdevel, linux-kselftest

Gate the test on CONFIG_TMPFS in the selftest config file. Assert
Private_Clean, Private_Dirty, Swap, and SwapPss fields are present in
/proc/$PID/smaps output for the mapped executable page.

Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
---
 tools/testing/selftests/proc/config        | 1 +
 tools/testing/selftests/proc/proc-pid-vm.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/proc/config b/tools/testing/selftests/proc/config
index 68fbd2b35..7dfc3d381 100644
--- a/tools/testing/selftests/proc/config
+++ b/tools/testing/selftests/proc/config
@@ -1 +1,2 @@
 CONFIG_PROC_FS=y
+CONFIG_TMPFS=y
diff --git a/tools/testing/selftests/proc/proc-pid-vm.c b/tools/testing/selftests/proc/proc-pid-vm.c
index 4e6a3e53f..59535bb3a 100644
--- a/tools/testing/selftests/proc/proc-pid-vm.c
+++ b/tools/testing/selftests/proc/proc-pid-vm.c
@@ -20,7 +20,6 @@
  * Test /proc/$PID/smaps_rollup
  * Test /proc/$PID/statm
  *
- * FIXME require CONFIG_TMPFS which can be disabled
  * FIXME test other values from "smaps"
  * FIXME support other archs
  */
@@ -409,6 +408,10 @@ int main(void)
 			"AnonHugePages:         0 kB\n",
 			"Shared_Hugetlb:        0 kB\n",
 			"Private_Hugetlb:       0 kB\n",
+			"Private_Clean:         4 kB\n",
+			"Private_Dirty:         0 kB\n",
+			"Swap:                  0 kB\n",
+			"SwapPss:               0 kB\n",
 			"Locked:                0 kB\n",
 		};
 		int i;
-- 
Deepak Rao Gaikwad


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/4] mm: vrealloc: grow vm_area mappings in place
  2026-07-15 14:36 [PATCH 1/4] mm: vmpressure: scale sampling window with machine size deepakraog
  2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
@ 2026-07-15 14:36 ` deepakraog
  2026-07-15 14:36 ` [PATCH 4/4] ceph: release unused cap reservation on readdir error deepakraog
  2 siblings, 0 replies; 5+ messages in thread
From: deepakraog @ 2026-07-15 14:36 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel

When vrealloc() needs more pages than are currently mapped, allocate and
map additional pages at the end of the existing vm_area instead of
always allocating a new area and memcpy()'ing. Fall back to the
existing realloc path when in-place grow is not possible.

Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
---
 mm/vmalloc.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1afca3568..46cf10c62 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -4426,8 +4426,56 @@ void *vrealloc_node_align_noprof(const void *p, size_t size, unsigned long align
 		return (void *)p;
 	}
 
+	{
+		unsigned int new_nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+		unsigned int old_nr_pages = vm->nr_pages;
+
+		if (new_nr_pages > old_nr_pages && !vm_area_page_order(vm) &&
+		    !(vm->flags & (VM_FLUSH_RESET_PERMS | VM_USERMAP)) &&
+		    gfp_has_io_fs(flags)) {
+			unsigned int extra = new_nr_pages - old_nr_pages;
+			unsigned long addr = (unsigned long)kasan_reset_tag(p);
+			struct vmap_node *vn = addr_to_node(addr);
+			struct page **pages;
+			int ret;
+
+			pages = kvmalloc_array(extra, sizeof(struct page *), gfp);
+			if (!pages)
+				goto need_realloc;
+
+			if (vm_area_alloc_pages(vmalloc_gfp_adjust(gfp, 0), nid,
+						0, extra, pages) != extra) {
+				kvfree(pages);
+				goto need_realloc;
+			}
+
+			spin_lock(&vn->busy.lock);
+			ret = vmap_pages_range(addr + ((unsigned long)old_nr_pages
+						       << PAGE_SHIFT),
+					       addr + ((unsigned long)new_nr_pages
+						       << PAGE_SHIFT),
+					       PAGE_KERNEL, pages, PAGE_SHIFT);
+			spin_unlock(&vn->busy.lock);
+			if (ret < 0) {
+				free_pages_bulk(pages, extra);
+				kvfree(pages);
+				goto need_realloc;
+			}
+
+			memcpy(&vm->pages[old_nr_pages], pages,
+			       extra * sizeof(struct page *));
+			kvfree(pages);
+			vm->nr_pages = new_nr_pages;
+			vm->requested_size = size;
+			kasan_vrealloc(p, old_size, size);
+			if (want_init_on_alloc(flags))
+				memset((void *)p + old_size, 0, size - old_size);
+			return (void *)p;
+		}
+	}
+
 need_realloc:
-	/* TODO: Grow the vm_area, i.e. allocate and map additional pages. */
+	/* Fall back to a fresh vm_area when in-place grow is not possible. */
 	n = __vmalloc_node_noprof(size, align, flags, nid, __builtin_return_address(0));
 
 	if (!n)
-- 
Deepak Rao Gaikwad


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 4/4] ceph: release unused cap reservation on readdir error
  2026-07-15 14:36 [PATCH 1/4] mm: vmpressure: scale sampling window with machine size deepakraog
  2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
  2026-07-15 14:36 ` [PATCH 3/4] mm: vrealloc: grow vm_area mappings in place deepakraog
@ 2026-07-15 14:36 ` deepakraog
  2026-07-15 17:51   ` Viacheslav Dubeyko
  2 siblings, 1 reply; 5+ messages in thread
From: deepakraog @ 2026-07-15 14:36 UTC (permalink / raw)
  To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, ceph-devel, linux-kernel

ceph_readdir_prepopulate() can exit with an error after partially
consuming the request's cap reservation. Return unused reserved caps to
the MDS client pool on the error path so they are not held until request
teardown.

Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
---
 fs/ceph/inode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 61d7c0b81..2d6a80054 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2188,6 +2188,8 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
 		dput(dn);
 	}
 out:
+	if (err)
+		ceph_unreserve_caps(req->r_mdsc, &req->r_caps_reservation);
 	if (err == 0 && skipped == 0) {
 		set_bit(CEPH_MDS_R_DID_PREPOPULATE, &req->r_req_flags);
 		req->r_readdir_cache_idx = cache_ctl.index;
-- 
Deepak Rao Gaikwad


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 4/4] ceph: release unused cap reservation on readdir error
  2026-07-15 14:36 ` [PATCH 4/4] ceph: release unused cap reservation on readdir error deepakraog
@ 2026-07-15 17:51   ` Viacheslav Dubeyko
  0 siblings, 0 replies; 5+ messages in thread
From: Viacheslav Dubeyko @ 2026-07-15 17:51 UTC (permalink / raw)
  To: deepakraog, Ilya Dryomov, Alex Markuze, ceph-devel, linux-kernel

On Wed, 2026-07-15 at 20:06 +0530, deepakraog wrote:
> ceph_readdir_prepopulate() can exit with an error after partially
> consuming the request's cap reservation. Return unused reserved caps
> to
> the MDS client pool on the error path so they are not held until
> request
> teardown.

The ceph-devel list has received only 4/4 patch. Is it some patchset?
If so, then why we haven't received the rest patches in series?

Do you have any issue related to the fix? How have you encountered the
issue? Could you please explain more about the issue?

Thanks,
Slava.

> 
> Signed-off-by: deepakraog <gaikwad.dcg@gmail.com>
> ---
>  fs/ceph/inode.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 61d7c0b81..2d6a80054 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2188,6 +2188,8 @@ int ceph_readdir_prepopulate(struct
> ceph_mds_request *req,
>  		dput(dn);
>  	}
>  out:
> +	if (err)
> +		ceph_unreserve_caps(req->r_mdsc, &req-
> >r_caps_reservation);
>  	if (err == 0 && skipped == 0) {
>  		set_bit(CEPH_MDS_R_DID_PREPOPULATE, &req-
> >r_req_flags);
>  		req->r_readdir_cache_idx = cache_ctl.index;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-15 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 14:36 [PATCH 1/4] mm: vmpressure: scale sampling window with machine size deepakraog
2026-07-15 14:36 ` [PATCH 2/4] selftests/proc: expand smaps field coverage and require TMPFS deepakraog
2026-07-15 14:36 ` [PATCH 3/4] mm: vrealloc: grow vm_area mappings in place deepakraog
2026-07-15 14:36 ` [PATCH 4/4] ceph: release unused cap reservation on readdir error deepakraog
2026-07-15 17:51   ` Viacheslav Dubeyko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox