• Ryan Roberts's avatar
    mm: tidy up shmem mTHP controls and stats · 70e59a75
    Ryan Roberts authored
    Previously we had a situation where shmem mTHP controls and stats were not
    exposed for some supported sizes and were exposed for some unsupported
    sizes.  So let's clean that up.
    
    Anon mTHP can support all large orders [2, PMD_ORDER].  But shmem can
    support all large orders [1, MAX_PAGECACHE_ORDER].  However, per-size
    shmem controls and stats were previously being exposed for all the anon
    mTHP orders, meaning order-1 was not present, and for arm64 64K base
    pages, orders 12 and 13 were exposed but were not supported internally.
    
    Tidy this all up by defining ctrl and stats attribute groups for anon and
    file separately.  Anon ctrl and stats groups are populated for all orders
    in THP_ORDERS_ALL_ANON and file ctrl and stats groups are populated for
    all orders in THP_ORDERS_ALL_FILE_DEFAULT.
    
    Additionally, create "any" ctrl and stats attribute groups which are
    populated for all orders in (THP_ORDERS_ALL_ANON |
    THP_ORDERS_ALL_FILE_DEFAULT).  swpout stats use this since they apply to
    anon and shmem.
    
    The side-effect of all this is that different hugepage-*kB directories
    contain different sets of controls and stats, depending on which memory
    types support that size.  This approach is preferred over the alternative,
    which is to populate dummy controls and stats for memory types that do not
    support a given size.
    
    [ryan.roberts@arm.com: file pages and shmem can also be split]
      Link: https://lkml.kernel.org/r/f7ced14c-8bc5-405f-bee7-94f63980f525@arm.comLink: https://lkml.kernel.org/r/20240808111849.651867-3-ryan.roberts@arm.comSigned-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
    Tested-by: default avatarBarry Song <baohua@kernel.org>
    Reviewed-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Gavin Shan <gshan@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Lance Yang <ioworker0@gmail.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    70e59a75
huge_memory.c 108 KB