Re: [DISCUSSION] proposed mctl() API
From: David Hildenbrand <hidden>
Date: 2025-07-04 10:34:53
Also in:
linux-arch, linux-mm, lkml
On 02.07.25 19:38, SeongJae Park wrote:
On Wed, 2 Jul 2025 15:15:01 +0100 Usama Arif [off-list ref] wrote: [...]quoted
In terms of the approach of doing this, IMHO, I dont think the way to do this is controversial. After the great feedback from Lorenzo on the prctl series, the approach would be for userpsace to make a call that just does for_each_vma of the process, madvises the VMAs,One dirty hack that I can think off the top of my head for doing this without new kernel changes is, unsurprisingly, using DAMOS. Using DAMOS, users can do madvise(MADV_HUGEPAGE) to virtual address ranges of specific access patterns. It is aimed to be used for hot regions, while using similar one of MADV_NOHUGEPAGE for cold regions. An experiment with a prototype[1] showed it eliminates about 80% of internal fragmentation caused memory overhead while keeping 46% of performance improvement under a constrained situation. If you set the access pattern as any pattern, hence, you can do madvise(MADV_HUGEPAGE) for effectively entire virtual address space of the process. DAMON user-space tool supports periodically tracking childs and applying same DAMOS scheme to those. So, for example, below hack could be tried. # damo start $(pidof XXX) --damos_action hugepage --include_child_tasks
IIRC, setting MADV_HUGEPAGE on arbitrary VMAs from arbitrary processes has the potential of breaking applications. Just imagine them deliberately setting MADV_NOHUGEPAGE and are intending of using userfaultfd, where it is crucial that we don't over-allocate memory even before userfaultdf is actually registered. (QEMU does that) -- Cheers, David / dhildenb