• Baolin Wang's avatar
    mm: shmem: add mTHP support for anonymous shmem · e7a2ab7b
    Baolin Wang authored
    Commit 19eaf449 adds multi-size THP (mTHP) for anonymous pages, 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.  Users expect to apply the mTHP rule for all
    anonymous pages, including the anonymous shmem, 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.  In addition, the mTHP interfaces can be extended to
    support all shmem/tmpfs scenarios in the future, especially for the shmem
    mmap() case.
    
    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.
    
    Link: https://lkml.kernel.org/r/65796c1e72e51e15f3410195b5c2d5b6c160d411.1718090413.git.baolin.wang@linux.alibaba.comSigned-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
    Cc: Barry Song <v-songbaohua@oppo.com>
    Cc: Daniel Gomez <da.gomez@samsung.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
    Cc: Lance Yang <ioworker0@gmail.com>
    Cc: Pankaj Raghav <p.raghav@samsung.com>
    Cc: Ryan Roberts <ryan.roberts@arm.com>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    e7a2ab7b
shmem.c 137 KB