On Tue, Jun 11, 2024 at 06:11:04PM +0800, Baolin Wang wrote: > Anonymous pages have already been supported for multi-size (mTHP) allocation > through commit 19eaf44954df, that can allow THP to be configured through the > sysfs interface located at '/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled'. > > However, the anonymous shmem will ignore the anonymous mTHP rule configured > through the sysfs interface, and can only use the PMD-mapped THP, that is not > reasonable. Many implement anonymous page sharing through mmap(MAP_SHARED | > MAP_ANONYMOUS), especially in database usage scenarios, therefore, users expect > to apply an unified mTHP strategy for anonymous pages, also including the > anonymous shared pages, in order to enjoy the benefits of mTHP. For example, > lower latency than PMD-mapped THP, smaller memory bloat than PMD-mapped THP, > contiguous PTEs on ARM architecture to reduce TLB miss etc. OK, this makes sense. > As discussed in the bi-weekly MM meeting[1], the mTHP controls should control > all of shmem, not only anonymous shmem, but support will be added iteratively. > Therefore, this patch set starts with support for anonymous shmem. But then this doesn't. You say first that users want the same controls to control all anonymous memory, then you introduce a completely separate set of controls for shared anonymous memory. shmem has two uses: - MAP_ANONYMOUS | MAP_SHARED (this patch set) - tmpfs For the second use case we don't want controls *at all*, we want the same heiristics used for all other filesystems to apply to tmpfs. There's no reason to have separate controls for choosing folio size in shmem. > The primary strategy is similar to supporting anonymous mTHP. Introduce > a new interface '/mm/transparent_hugepage/hugepage-XXkb/shmem_enabled', > which can have almost the same values as the top-level > '/sys/kernel/mm/transparent_hugepage/shmem_enabled', with adding a new > additional "inherit" option and dropping the testing options 'force' and > 'deny'. By default all sizes will be set to "never" except PMD size, which > is set to "inherit". This ensures backward compatibility with the anonymous > shmem enabled of the top level, meanwhile also allows independent control of > anonymous shmem enabled for each mTHP.