Commit 5d0a661d authored by Mel Gorman's avatar Mel Gorman Committed by akpm

mm/page_alloc: use only one PCP list for THP-sized allocations

The per_cpu_pages is cache-aligned on a standard x86-64 distribution
configuration but a later patch will add a new field which would push the
structure into the next cache line.  Use only one list to store THP-sized
pages on the per-cpu list.  This assumes that the vast majority of
THP-sized allocations are GFP_MOVABLE but even if it was another type, it
would not contribute to serious fragmentation that potentially causes a
later THP allocation failure.  Align per_cpu_pages on the cacheline
boundary to ensure there is no false cache sharing.

After this patch, the structure sizing is;

struct per_cpu_pages {
        int                        count;                /*     0     4 */
        int                        high;                 /*     4     4 */
        int                        batch;                /*     8     4 */
        short int                  free_factor;          /*    12     2 */
        short int                  expire;               /*    14     2 */
        struct list_head           lists[13];            /*    16   208 */

        /* size: 256, cachelines: 4, members: 6 */
        /* padding: 32 */
} __attribute__((__aligned__(64)));

Link: https://lkml.kernel.org/r/20220624125423.6126-3-mgorman@techsingularity.netSigned-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
Tested-by: default avatarMinchan Kim <minchan@kernel.org>
Acked-by: default avatarMinchan Kim <minchan@kernel.org>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Tested-by: default avatarYu Zhao <yuzhao@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent bf75f200
...@@ -355,15 +355,18 @@ enum zone_watermarks { ...@@ -355,15 +355,18 @@ enum zone_watermarks {
}; };
/* /*
* One per migratetype for each PAGE_ALLOC_COSTLY_ORDER plus one additional * One per migratetype for each PAGE_ALLOC_COSTLY_ORDER. One additional list
* for pageblock size for THP if configured. * for THP which will usually be GFP_MOVABLE. Even if it is another type,
* it should not contribute to serious fragmentation causing THP allocation
* failures.
*/ */
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
#define NR_PCP_THP 1 #define NR_PCP_THP 1
#else #else
#define NR_PCP_THP 0 #define NR_PCP_THP 0
#endif #endif
#define NR_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1 + NR_PCP_THP)) #define NR_LOWORDER_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1))
#define NR_PCP_LISTS (NR_LOWORDER_PCP_LISTS + NR_PCP_THP)
/* /*
* Shift to encode migratetype and order in the same integer, with order * Shift to encode migratetype and order in the same integer, with order
...@@ -389,7 +392,7 @@ struct per_cpu_pages { ...@@ -389,7 +392,7 @@ struct per_cpu_pages {
/* Lists of pages, one per migrate type stored on the pcp-lists */ /* Lists of pages, one per migrate type stored on the pcp-lists */
struct list_head lists[NR_PCP_LISTS]; struct list_head lists[NR_PCP_LISTS];
}; } ____cacheline_aligned_in_smp;
struct per_cpu_zonestat { struct per_cpu_zonestat {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
...@@ -653,7 +653,7 @@ static inline unsigned int order_to_pindex(int migratetype, int order) ...@@ -653,7 +653,7 @@ static inline unsigned int order_to_pindex(int migratetype, int order)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (order > PAGE_ALLOC_COSTLY_ORDER) { if (order > PAGE_ALLOC_COSTLY_ORDER) {
VM_BUG_ON(order != pageblock_order); VM_BUG_ON(order != pageblock_order);
base = PAGE_ALLOC_COSTLY_ORDER + 1; return NR_LOWORDER_PCP_LISTS;
} }
#else #else
VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
...@@ -667,7 +667,7 @@ static inline int pindex_to_order(unsigned int pindex) ...@@ -667,7 +667,7 @@ static inline int pindex_to_order(unsigned int pindex)
int order = pindex / MIGRATE_PCPTYPES; int order = pindex / MIGRATE_PCPTYPES;
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (order > PAGE_ALLOC_COSTLY_ORDER) if (pindex == NR_LOWORDER_PCP_LISTS)
order = pageblock_order; order = pageblock_order;
#else #else
VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment