Re: [RFC PATCH] fs: introduce ST_HUGE flag and set it to tmpfs and hugetlbfs

From: Yang Shi
Date: Tue Apr 17 2018 - 19:37:29 EST




On 4/17/18 4:22 PM, Matthew Wilcox wrote:
On Wed, Apr 18, 2018 at 05:08:13AM +0800, Yang Shi wrote:
When applications use huge page on hugetlbfs, it just need check the
filesystem magic number, but it is not enough for tmpfs. So, introduce
ST_HUGE flag to statfs if super block has SB_HUGE set which indicates
huge page is supported on the specific filesystem.
Hm. What's the plan for communicating support for page sizes other
than PMD page sizes? I know ARM has several different page sizes,
as do PA-RISC and ia64. Even x86 might support 1G page sizes through
tmpfs one day.

For THP page size, we already have /sys/kernel/mm/transparent_hugepage/hpage_pmd_size exported. The applications could read this to get the THP size. If PUD size THP supported is added later, we can export hpage_pud_size.

Please see the below commit log for more details:

commit 49920d28781dcced10cd30cb9a938e7d045a1c94
Author: Hugh Dickins <hughd@xxxxxxxxxx>
Date:ÂÂ Mon Dec 12 16:44:50 2016 -0800

ÂÂÂ mm: make transparent hugepage size public

ÂÂÂ Test programs want to know the size of a transparent hugepage. While it
ÂÂÂ is commonly the same as the size of a hugetlbfs page (shown as
ÂÂÂ Hugepagesize in /proc/meminfo), that is not always so: powerpc
ÂÂÂ implements transparent hugepages in a different way from hugetlbfs
ÂÂÂ pages, so it's coincidence when their sizes are the same; and x86 and
ÂÂÂ others can support more than one hugetlbfs page size.

ÂÂÂ Add /sys/kernel/mm/transparent_hugepage/hpage_pmd_size to show the THP
 size in bytes - it's the same for Anonymous and Shmem hugepages. Call
ÂÂÂ it hpage_pmd_size (after HPAGE_PMD_SIZE) rather than hpage_size, in case
ÂÂÂ some transparent support for pud and pgd pages is added later.


Thanks,
Yang