* [PATCH v2 1/3] feat: scale vmpressure window with machine size [not found] <20260716115734.80909-1-gaikwad.dcg@gmail.com> @ 2026-07-16 11:57 ` deepakroag 2026-07-16 13:24 ` Lorenzo Stoakes (ARM) 2026-07-16 11:57 ` [PATCH v2 3/3] feat: grow vrealloc vm_area mappings in place deepakroag 1 sibling, 1 reply; 4+ messages in thread From: deepakroag @ 2026-07-16 11:57 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 Replace the fixed 512-page vmpressure window with a boot-time value derived from total memory and CPU count, clamped between 128 and 2048 pages. Signed-off-by: deepakroag <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 related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] feat: scale vmpressure window with machine size 2026-07-16 11:57 ` [PATCH v2 1/3] feat: scale vmpressure window with machine size deepakroag @ 2026-07-16 13:24 ` Lorenzo Stoakes (ARM) 2026-07-16 13:49 ` deepakroag 0 siblings, 1 reply; 4+ messages in thread From: Lorenzo Stoakes (ARM) @ 2026-07-16 13:24 UTC (permalink / raw) To: deepakroag Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kernel NAK. I'm not sure what you're doing here but this looks suspiciously like you're taking somebody else's (previously rejected) work and putting your name to it? And you're sending a v2 without having sent a v1? What? You're also getting basic process wrong here. We don't prefix with 'feat'. You only cc'd key people on 1/3 patches. There doesn't appear to be a cover letter. You are sending random vmalloc changes along with this too? On Thu, Jul 16, 2026 at 05:27:30PM +0530, deepakroag wrote: > Replace the fixed 512-page vmpressure window with a boot-time value > derived from total memory and CPU count, clamped between 128 and 2048 pages. So you're just making stuff up here? Clamp between 128 and 2048 because why not I guess? And no mention about the rest of the logic? > > Signed-off-by: deepakroag <gaikwad.dcg@gmail.com> > --- There was already a patch for this in [0] which looks suspiciously close to what you're doing here (modulo clamping without using a clamp macro), unacknowledged. I hope you understand plagiarism is completely unacceptable? In any case it was rejected then for various reasons, you re-sending the same idea without crediting that changes nothing. Cheers, Lorenzo [0]:https://lore.kernel.org/all/20260227221555.29969-1-mcq@disroot.org/ > 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] 4+ messages in thread
* Re: [PATCH v2 1/3] feat: scale vmpressure window with machine size 2026-07-16 13:24 ` Lorenzo Stoakes (ARM) @ 2026-07-16 13:49 ` deepakroag 0 siblings, 0 replies; 4+ messages in thread From: deepakroag @ 2026-07-16 13:49 UTC (permalink / raw) To: Lorenzo Stoakes (ARM) Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kselftest, linux-kernel Hi Lorenzo, Thank you for the review. I withdraw the entire [PATCH v2 0/3] series. You are right that the vmpressure change closely follows Benjamin Lee McQueen's earlier rejected thread without proper attribution or an RFC. That was a serious mistake on my part, and I am sorry for the confusion and for wasting your time. I will not resubmit the vmpressure or vrealloc changes. I also understand that bundling unrelated mm, selftest, and vmalloc work in one series, using non-kernel subject prefixes, and sending v2 without a proper v1 review cycle were process errors on my side. Going forward I will stick to small, original fixes, search lore before proposing mm changes, and follow the normal RFC/review process for anything touching vmpressure or vmalloc. Thank you, Deepak Rao Gaikwad ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] feat: grow vrealloc vm_area mappings in place [not found] <20260716115734.80909-1-gaikwad.dcg@gmail.com> 2026-07-16 11:57 ` [PATCH v2 1/3] feat: scale vmpressure window with machine size deepakroag @ 2026-07-16 11:57 ` deepakroag 1 sibling, 0 replies; 4+ messages in thread From: deepakroag @ 2026-07-16 11:57 UTC (permalink / raw) To: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel Allocate and map additional pages at the end of an existing vm_area when vrealloc() grows past mapped pages, falling back to the memcpy path otherwise. Use flags (not gfp) in the in-place grow path for kvmalloc_array and vm_area_alloc_pages. Signed-off-by: deepakroag <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..1eff71240 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 *), flags); + if (!pages) + goto need_realloc; + + if (vm_area_alloc_pages(vmalloc_gfp_adjust(flags, 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 related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-16 15:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260716115734.80909-1-gaikwad.dcg@gmail.com>
2026-07-16 11:57 ` [PATCH v2 1/3] feat: scale vmpressure window with machine size deepakroag
2026-07-16 13:24 ` Lorenzo Stoakes (ARM)
2026-07-16 13:49 ` deepakroag
2026-07-16 11:57 ` [PATCH v2 3/3] feat: grow vrealloc vm_area mappings in place deepakroag
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox