mm: place pages to the freelist tail when onling and undoing isolation
Subsystems (7)
cover mm: place pages to the freelist tail when onling and undoing isolation
When adding separate memory blocks via add_memory*() and onlining them immediately, the metadata (especially the memmap) of the next block will be placed onto one of the just added+onlined block. This creates a chain of unmovable allocations: If the last memory block cannot get offlined+removed() so will all dependent ones. We directly have unmovable allocations all over the place.
This can be observed quite easily using virtio-mem, however, it can also be observed when using DIMMs. The freshly onlined pages will usually be placed to the head of the freelists, meaning they will be allocated next, turning the just-added memory usually immediately un-removable. The fresh pages are cold, prefering to allocate others (that might be hot) also feels to be the natural thing to do.
It also applies to the hyper-v balloon xen-balloon, and ppc64 dlpar: when adding separate, successive memory blocks, each memory block will have unmovable allocations on them - for example gigantic pages will fail to allocate.
While the ZONE_NORMAL doesn't provide any guarantees that memory can get offlined+removed again (any kind of fragmentation with unmovable allocations is possible), there are many scenarios (hotplugging a lot of memory, running workload, hotunplug some memory/as much as possible) where we can offline+remove quite a lot with this patchset.
a) To visualize the problem, a very simple example:
Start a VM with 4GB and 8GB of virtio-mem memory:
[root@localhost ~]# lsmem
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x00000000bfffffff 3G online yes 0-23 0x0000000100000000-0x000000033fffffff 9G online yes 32-103
Memory block size: 128M
Total online memory: 12G
Total offline memory: 0B
Then try to unplug as much as possible using virtio-mem. Observe which memory blocks are still around. Without this patch set:
[root@localhost ~]# lsmem
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x00000000bfffffff 3G online yes 0-23 0x0000000100000000-0x000000013fffffff 1G online yes 32-39 0x0000000148000000-0x000000014fffffff 128M online yes 41 0x0000000158000000-0x000000015fffffff 128M online yes 43 0x0000000168000000-0x000000016fffffff 128M online yes 45 0x0000000178000000-0x000000017fffffff 128M online yes 47 0x0000000188000000-0x0000000197ffffff 256M online yes 49-50 0x00000001a0000000-0x00000001a7ffffff 128M online yes 52 0x00000001b0000000-0x00000001b7ffffff 128M online yes 54 0x00000001c0000000-0x00000001c7ffffff 128M online yes 56 0x00000001d0000000-0x00000001d7ffffff 128M online yes 58 0x00000001e0000000-0x00000001e7ffffff 128M online yes 60 0x00000001f0000000-0x00000001f7ffffff 128M online yes 62 0x0000000200000000-0x0000000207ffffff 128M online yes 64 0x0000000210000000-0x0000000217ffffff 128M online yes 66 0x0000000220000000-0x0000000227ffffff 128M online yes 68 0x0000000230000000-0x0000000237ffffff 128M online yes 70 0x0000000240000000-0x0000000247ffffff 128M online yes 72 0x0000000250000000-0x0000000257ffffff 128M online yes 74 0x0000000260000000-0x0000000267ffffff 128M online yes 76 0x0000000270000000-0x0000000277ffffff 128M online yes 78 0x0000000280000000-0x0000000287ffffff 128M online yes 80 0x0000000290000000-0x0000000297ffffff 128M online yes 82 0x00000002a0000000-0x00000002a7ffffff 128M online yes 84 0x00000002b0000000-0x00000002b7ffffff 128M online yes 86 0x00000002c0000000-0x00000002c7ffffff 128M online yes 88 0x00000002d0000000-0x00000002d7ffffff 128M online yes 90 0x00000002e0000000-0x00000002e7ffffff 128M online yes 92 0x00000002f0000000-0x00000002f7ffffff 128M online yes 94 0x0000000300000000-0x0000000307ffffff 128M online yes 96 0x0000000310000000-0x0000000317ffffff 128M online yes 98 0x0000000320000000-0x0000000327ffffff 128M online yes 100 0x0000000330000000-0x000000033fffffff 256M online yes 102-103
Memory block size: 128M
Total online memory: 8.1G
Total offline memory: 0B
With this patch set:
[root@localhost ~]# lsmem
RANGE SIZE STATE REMOVABLE BLOCK
0x0000000000000000-0x00000000bfffffff 3G online yes 0-23 0x0000000100000000-0x000000013fffffff 1G online yes 32-39
Memory block size: 128M
Total online memory: 4G
Total offline memory: 0B
All memory can get unplugged, all memory block can get removed. Of course, no workload ran and the system was basically idle, but it highlights the issue - the fairly deterministic chain of unmovable allocations. When a huge page for the 2MB memmap is needed, a just-onlined 4MB page will be split. The remaining 2MB page will be used for the memmap of the next memory block. So one memory block will hold the memmap of the two following memory blocks. Finally the pages of the last-onlined memory block will get used for the next bigger allocations - if any allocation is unmovable, all dependent memory blocks cannot get unplugged and removed until that allocation is gone.
Note that with bigger memory blocks (e.g., 256MB), *all* memory blocks are dependent and none can get unplugged again!
b) Experiment with memory intensive workload
I performed an experiment with an older version of this patch set (before we used undo_isolate_page_range() in online_pages():
Hotplug 56GB to a VM with an initial 4GB, onlining all memory to ZONE_NORMAL right from the kernel when adding it. I then run various memory intensive workloads that consume most system memory for a total of 45 minutes. Once finished, I try to unplug as much memory as possible.
With this change, I am able to remove via virtio-mem (adding individual 128MB memory blocks) 413 out of 448 added memory blocks. Via individual (256MB) DIMMs 380 out of 448 added memory blocks. (I don't have any numbers without this patchset, but looking at the above example, it's at most half of the 448 memory blocks for virtio-mem, and most probably none for DIMMs).
Again, there are workloads that might behave very differently due to the nature of ZONE_NORMAL.
This change also affects (besodes memory onlining):
- Other users of undo_isolate_page_range(): Pages are always placed to the tail.
-- When memory offlining fails
-- When memory isolation fails after having isolated some pageblocks -- When alloc_contig_range() either succeeds or fails
- Other users of __putback_isolated_page(): Pages are always placed to the tail.
-- Free page reporting
- Other users of __free_pages_core()
-- AFAIKs, any memory that is getting exposed to the buddy during boot.
IIUC we will now usually allocate memory from lower addresses within a zone first (especially during boot).
- Other users of generic_online_page()
-- Hyper-V balloon
RFC -> v1:
- Tweak some patch descriptions
- "mm/page_alloc: place pages to tail in __putback_isolated_page()" -- FOP_TO_TAIL now has higher precedence than page shuffling -- Add a note that nothing should rely on FOP_TO_TAIL for correctness
- "mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()"
-- Use "bool" parameter for move_freepages_block() as requested
- "mm/page_alloc: place pages to tail in __free_pages_core()" -- Eliminate set_page_refcounted() + page_ref_dec() and add a comment
- "mm/memory_hotplug: update comment regarding zone shuffling" -- Added
David Hildenbrand (5):
mm/page_alloc: convert "report" flag of __free_one_page() to a proper
flag
mm/page_alloc: place pages to tail in __putback_isolated_page() mm/page_alloc: always move pages to the tail of the freelist in
unset_migratetype_isolate()
mm/page_alloc: place pages to tail in __free_pages_core() mm/memory_hotplug: update comment regarding zone shuffling
include/linux/page-isolation.h | 4 +- mm/memory_hotplug.c | 11 ++-- mm/page_alloc.c | 114 ++++++++++++++++++++++++--------- mm/page_isolation.c | 12 +++- 4 files changed, 97 insertions(+), 44 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/5 mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in __free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.
--- mm/page_alloc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
mm/page_alloc.c +20 -8
@@ -77,6 +77,18 @@#include "shuffle.h" #include "page_reporting.h" +/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ; + +/* No special request */ +#define FOP_NONE ((__force fop_t)0) + +/* +* Skip free page reporting notification for the (possibly merged) page. (will +* *not* mark the page reported, only skip the notification). +*/ +#define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)
@@ -948,10 +960,9 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,* -- nyc */ -static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags) {struct capture_control *capc =task_capc (zone);unsigned long buddy_pfn;
@@ -1038,7 +1049,7 @@ static inline void __free_one_page(struct page *page,add_to_free_list (page, zone, order, migratetype);/* Notify page reporting subsystem of freed page */ -if (report) +if (!(fop_flags &FOP_SKIP_REPORT_NOTIFY ))page_reporting_notify_free (order); }
@@ -1379,7 +1390,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,if (unlikely (isolated_pageblocks)) mt =get_pageblock_migratetype (page); -__free_one_page (page,page_to_pfn (page), zone,0 , mt, true); +__free_one_page (page,page_to_pfn (page), zone,0 , mt,FOP_NONE );trace_mm_page_pcpu_drain (page,0 , mt); }spin_unlock (&zone->lock);
@@ -1395,7 +1406,7 @@ static void free_one_page(struct zone *zone, is_migrate_isolate(migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype, true); +__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE );spin_unlock (&zone->lock); }
@@ -3288,7 +3299,8 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)lockdep_assert_held (&zone->lock);/* Return isolated page to tail of freelist. */ -__free_one_page (page,page_to_pfn (page), zone, order, mt, false); +__free_one_page (page,page_to_pfn (page), zone, order, mt, +FOP_SKIP_REPORT_NOTIFY ); }/*
Signature · 1 line
2.26.2
PATCH 2/5 mm/page_alloc: place pages to tail in __putback_isolated_page()
In reply to David Hildenbrand__putback_isolated_page() already documents that pages will be placed to the tail of the freelist - this is, however, not the case for "order >= MAX_ORDER - 2" (see buddy_merge_likely()) - which should be the case for all existing users.
This change affects two users:
- free page reporting
- page isolation, when undoing the isolation (including memory onlining).
This behavior is desireable for pages that haven't really been touched lately, so exactly the two users that don't actually read/write page content, but rather move untouched pages.
The new behavior is especially desirable for memory onlining, where we allow allocation of newly onlined pages via undo_isolate_page_range() in online_pages(). Right now, we always place them to the head of the free list, resulting in undesireable behavior: Assume we add individual memory chunks via add_memory() and online them right away to the NORMAL zone. We create a dependency chain of unmovable allocations e.g., via the memmap. The memmap of the next chunk will be placed onto previous chunks - if the last block cannot get offlined+removed, all dependent ones cannot get offlined+removed. While this can already be observed with individual DIMMs, it's more of an issue for virtio-mem (and I suspect also ppc DLPAR).
Document that this should only be used for optimizations, and no code should realy on this for correction (if the order of freepage lists ever changes).
We won't care about page shuffling: memory onlining already properly shuffles after onlining. free page reporting doesn't care about physically contiguous ranges, and there are already cases where page isolation will simply move (physically close) free pages to (currently) the head of the freelists via move_freepages_block() instead of shuffling. If this becomes ever relevant, we should shuffle the whole zone when undoing isolation of larger ranges, and after free_contig_range().
--- mm/page_alloc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
mm/page_alloc.c +16 -2
@@ -89,6 +89,18 @@ typedef int __bitwise fop_t;*/ #define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* +* Place the (possibly merged) page to the tail of the freelist. Will ignore +* page shuffling (relevant code - e.g., memory onlining - is expected to +* shuffle the whole zone). +* +* Note: No code should rely onto this flag for correctness - it's purely +* to allow for optimizations when handing back either fresh pages +* (memory onlining) or untouched pages (page isolation, free page +* reporting). +*/ +#define FOP_TO_TAIL ((__force fop_t)BIT(1)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)
@@ -1038,7 +1050,9 @@ static inline void __free_one_page(struct page *page, unsigned long pfn, done_merging:set_page_order (page, order); -if (is_shuffle_order (order)) +if (fop_flags &FOP_TO_TAIL ) + to_tail = true; +else if (is_shuffle_order (order)) to_tail =shuffle_pick_tail ();else to_tail =buddy_merge_likely (pfn, buddy_pfn, page, order);
@@ -3300,7 +3314,7 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)/* Return isolated page to tail of freelist. */ __free_one_page (page,page_to_pfn (page), zone, order, mt, -FOP_SKIP_REPORT_NOTIFY ); +FOP_SKIP_REPORT_NOTIFY |FOP_TO_TAIL ); }/*
Signature · 1 line
2.26.2
PATCH 3/5 mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to David HildenbrandPage isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the MIGRATE_ISOLATE freelist.
We already place pages to the tail of the freelists when undoing isolation via __putback_isolated_page(), let's do it in any case (e.g., if order <= pageblock_order) and document the behavior.
Add a "to_tail" parameter to move_freepages_block() but introduce a a new move_to_free_list_tail() - similar to add_to_free_list_tail().
This change results in all pages getting onlined via online_pages() to be placed to the tail of the freelist.
--- include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)
include/linux/page-isolation.h +2 -2
@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE.
mm/page_alloc.c +24 -11
@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); } +/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +static inline void del_page_from_free_list (struct page *page,struct zone *zone,unsigned int order) {
@@ -2338,9 +2347,9 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone,* Note that start_page and end_pages are not aligned on a pageblock * boundary. If alignment is required, use move_freepages_block() */ -static int move_freepages (struct zone *zone, -struct page *start_page,struct page *end_page, -int migratetype,int *num_movable) +static int move_freepages (struct zone *zone,struct page *start_page, +struct page *end_page,int migratetype, +bool to_tail,int *num_movable) {struct page *page;unsigned int order;
@@ -2371,7 +2380,10 @@ static int move_freepages(struct zone *zone,VM_BUG_ON_PAGE (page_zone (page) != zone, page); order =page_order (page); -move_to_free_list (page, zone, order, migratetype); +if (to_tail) +move_to_free_list_tail (page, zone, order, migratetype); +else +move_to_free_list (page, zone, order, migratetype); page +=1 << order; pages_moved +=1 << order; }
@@ -2379,8 +2391,8 @@ static int move_freepages(struct zone *zone,return pages_moved; } -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable) +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable) {unsigned long start_pfn, end_pfn;struct page *start_page, *end_page;
@@ -2401,7 +2413,7 @@ int move_freepages_block(struct zone *zone, struct page *page,return 0 ;return move_freepages (zone, start_page, end_page, migratetype, - num_movable); + to_tail, num_movable); } static void change_pageblock_range(struct page *pageblock_page,
@@ -2526,8 +2538,8 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,if (!whole_block) goto single_page; - free_pages =move_freepages_block (zone, page, start_type, - &movable_pages); + free_pages =move_freepages_block (zone, page, start_type, false, + &movable_pages);/* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which
@@ -2635,7 +2647,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone, && !is_migrate_cma(mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC ); -move_freepages_block (zone, page,MIGRATE_HIGHATOMIC ,NULL ); +move_freepages_block (zone, page,MIGRATE_HIGHATOMIC , false, +NULL ); } out_unlock:
@@ -2711,7 +2724,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,*/ set_pageblock_migratetype (page, ac->migratetype); ret =move_freepages_block (zone, page, ac->migratetype, -NULL ); + false,NULL );if (ret) {spin_unlock_irqrestore (&zone->lock, flags);return ret;
mm/page_isolation.c +9 -3
@@ -45,7 +45,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_set_pageblock_migratetype (page,MIGRATE_ISOLATE ); zone->nr_isolate_pageblock++; nr_pages =move_freepages_block (zone, page,MIGRATE_ISOLATE , -NULL ); + false,NULL );__mod_zone_freepage_state (zone, -nr_pages, mt);spin_unlock_irqrestore (&zone->lock, flags);
@@ -83,7 +83,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* Because freepage with more than pageblock_order on isolated * pageblock is restricted to merge due to freepage counting problem, * it is possible that there is free buddy page. -* move_freepages_block() doesn't care of merge so we need other +* move_freepages_block() don't care about merging, so we need another * approach in order to merge them. Isolation and free will make * these pages to be merged. */
@@ -106,9 +106,15 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* If we isolate freepage with more than pageblock_order, there * should be no freepage in the range, so we could avoid costly * pageblock scanning for freepage moving. +* +* We didn't actually touch any of the isolated pages, so place them +* to the tail of the freelist. This is an optimization for memory +* onlining - just onlined memory won't immediately be considered for +* allocation. */ if (!isolated_page) { - nr_pages =move_freepages_block (zone, page, migratetype,NULL ); + nr_pages =move_freepages_block (zone, page, migratetype, true, +NULL );__mod_zone_freepage_state (zone, nr_pages, migratetype); }set_pageblock_migratetype (page, migratetype);
Signature · 1 line
2.26.2
PATCH 4/5 mm/page_alloc: place pages to tail in __free_pages_core()
In reply to David Hildenbrand__free_pages_core() is used when exposing fresh memory to the buddy during system boot and when onlining memory in generic_online_page().
generic_online_page() is used in two cases:
1. Direct memory onlining in online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.
In 1, we already place pages to the tail of the freelist. Pages will be freed to MIGRATE_ISOLATE lists first and moved to the tail of the freelists via undo_isolate_page_range().
In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online MAX_ORDER - 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon calls generic_online_page() with single pages, usually it will call it on successive single pages in a larger block.
The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In __free_pages_core(), remove the now superflouos call to set_page_refcounted() and add a comment regarding page initialization and the refcount.
Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of generic_online_page() calls in the relevant callers.
--- mm/page_alloc.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)
mm/page_alloc.c +24 -13
@@ -270,7 +270,8 @@ bool pm_suspended_storage(void)unsigned int pageblock_order__read_mostly ;#endif -static void __free_pages_ok (struct page *page,unsigned int order); +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags);/* * results with 256, 32 in the lowmem_reserve sysctl:
@@ -682,7 +683,7 @@ static void bad_page(struct page *page, const char *reason)void free_compound_page (struct page *page) {mem_cgroup_uncharge (page); -__free_pages_ok (page,compound_order (page)); +__free_pages_ok (page,compound_order (page),FOP_NONE ); }void prep_compound_page (struct page *page,unsigned int order)
@@ -1419,17 +1420,15 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_unlock (&zone->lock); } -static void free_one_page (struct zone *zone, -struct page *page,unsigned long pfn, -unsigned int order, -int migratetype) +static void free_one_page (struct zone *zone,struct page *page,unsigned long pfn, +unsigned int order,int migratetype,fop_t fop_flags) {spin_lock (&zone->lock);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE ); +__free_one_page (page, pfn, zone, order, migratetype, fop_flags);spin_unlock (&zone->lock); }
@@ -1507,7 +1506,8 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) } } -static void __free_pages_ok (struct page *page,unsigned int order) +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags) {unsigned long flags;int migratetype;
@@ -1519,7 +1519,8 @@ static void __free_pages_ok(struct page *page, unsigned int order) migratetype =get_pfnblock_migratetype (page, pfn);local_irq_save (flags);__count_vm_events (PGFREE ,1 << order); -free_one_page (page_zone (page), page, pfn, order, migratetype); +free_one_page (page_zone (page), page, pfn, order, migratetype, + fop_flags);local_irq_restore (flags); }
@@ -1529,6 +1530,11 @@ void __free_pages_core(struct page *page, unsigned int order)struct page *p = page;unsigned int loop; +/* +* When initializing the memmap, init_single_page() sets the refcount +* of all pages to 1 ("allocated"/"not free"). We have to set the +* refcount of all involved pages to 0. +*/ prefetchw (p);for (loop =0 ; loop < (nr_pages -1 ); loop++, p++) {prefetchw (p +1 );
@@ -1539,8 +1545,12 @@ void __free_pages_core(struct page *page, unsigned int order)set_page_count (p,0 );atomic_long_add (nr_pages, &page_zone (page)->managed_pages); -set_page_refcounted (page); -__free_pages (page, order); + +/* +* Bypass PCP and place fresh pages right to the tail, primarily +* relevant for memory onlining. +*/ +__free_pages_ok (page, order,FOP_TO_TAIL ); }#ifdef CONFIG_NEED_MULTIPLE_NODES
@@ -3171,7 +3181,8 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn)*/ if (migratetype >=MIGRATE_PCPTYPES ) {if (unlikely (is_migrate_isolate (migratetype))) { -free_one_page (zone, page, pfn,0 , migratetype); +free_one_page (zone, page, pfn,0 , migratetype, +FOP_NONE );return ; } migratetype =MIGRATE_MOVABLE ;
@@ -5063,7 +5074,7 @@ static inline void free_the_page(struct page *page, unsigned int order)if (order ==0 )/* Via pcp? */ free_unref_page (page);else -__free_pages_ok (page, order); +__free_pages_ok (page, order,FOP_NONE ); }void __free_pages (struct page *page,unsigned int order)
Signature · 1 line
2.26.2
PATCH 5/5 mm/memory_hotplug: update comment regarding zone shuffling
In reply to David HildenbrandAs we no longer shuffle via generic_online_page() and when undoing isolation, we can simplify the comment.
We now effectively shuffle only once (properly) when onlining new memory.
--- mm/memory_hotplug.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
mm/memory_hotplug.c +4 -7
@@ -859,13 +859,10 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,undo_isolate_page_range (pfn, pfn + nr_pages,MIGRATE_MOVABLE );/* -* When exposing larger, physically contiguous memory areas to the -* buddy, shuffling in the buddy (when freeing onlined pages, putting -* them either to the head or the tail of the freelist) is only helpful -* for maintaining the shuffle, but not for creating the initial -* shuffle. Shuffle the whole zone to make sure the just onlined pages -* are properly distributed across the whole freelist. Make sure to -* shuffle once pageblocks are no longer isolated. +* Freshly onlined pages aren't shuffled (e.g., all pages are placed to +* the tail of the freelist when undoing isolation). Shuffle the whole +* zone to make sure the just onlined pages are properly distributed +* across the whole freelist - to create an initial shuffle. */ shuffle_zone (zone);
Signature · 1 line
2.26.2
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
In reply to David HildenbrandQuoted 87 lines
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- mm/page_alloc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)mm/page_alloc.c +18
-7@@ -77,6 +77,18 @@#include "shuffle.h" #include "page_reporting.h" +/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ; + +/* No special request */ +#define FOP_NONE ((__force fop_t)0) + +/* +* Skip free page reporting notification for the (possibly merged) page. (will +* *not* mark the page reported, only skip the notification). +*/ +#define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -948,10 +960,9 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,* -- nyc */ -static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags) {struct capture_control *capc =task_capc (zone);unsigned long buddy_pfn;@@ -1038,7 +1049,7 @@ static inline void __free_one_page(struct page *page,add_to_free_list (page, zone, order, migratetype);/* Notify page reporting subsystem of freed page */ -if (report) +if (!(fop_flags &FOP_SKIP_REPORT_NOTIFY ))page_reporting_notify_free (order); }@@ -1379,7 +1390,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,if (unlikely (isolated_pageblocks)) mt =get_pageblock_migratetype (page); -__free_one_page (page,page_to_pfn (page), zone,0 , mt, true); +__free_one_page (page,page_to_pfn (page), zone,0 , mt,FOP_NONE );trace_mm_page_pcpu_drain (page,0 , mt); }spin_unlock (&zone->lock);@@ -1395,7 +1406,7 @@ static void free_one_page(struct zone *zone, is_migrate_isolate(migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype, true); +__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE );spin_unlock (&zone->lock); }
mm/page_alloc.c void __putback_isolated_page(struct page *page, unsigned int order, int mt) · line 3304
Quoted 7 lines
mm/page_alloc.c +2
-1@@ -3288,7 +3299,8 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)lockdep_assert_held (&zone->lock);/* Return isolated page to tail of freelist. */ -__free_one_page (page,page_to_pfn (page), zone, order, mt, false); +__free_one_page (page,page_to_pfn (page), zone, order, mt, +FOP_SKIP_REPORT_NOTIFY ); }
Re: [PATCH v1 4/5] mm/page_alloc: place pages to tail in __free_pages_core()
In reply to David HildenbrandQuoted 152 lines
__free_pages_core()is used when exposing fresh memory to the buddy during system boot and when onlining memory ingeneric_online_page().
generic_online_page()is used in two cases:1. Direct memory onlining in
online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.In 1, we already place pages to the tail of the freelist. Pages will be freed to
MIGRATE_ISOLATElists first and moved to the tail of the freelists viaundo_isolate_page_range().In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online
MAX_ORDER- 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon callsgeneric_online_page()with single pages, usually it will call it on successive single pages in a larger block.The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In
__free_pages_core(), remove the now superflouos call toset_page_refcounted()and add a comment regarding page initialization and the refcount.Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of
generic_online_page()calls in the relevant callers.Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Stephen Hemminger <[email protected]>Cc Wei Liu <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- mm/page_alloc.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)mm/page_alloc.c +23
-12@@ -270,7 +270,8 @@ bool pm_suspended_storage(void)unsigned int pageblock_order__read_mostly ;#endif -static void __free_pages_ok (struct page *page,unsigned int order); +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags);/* * results with 256, 32 in the lowmem_reserve sysctl: @@ -682,7 +683,7 @@ static void bad_page(struct page *page, const char *reason)void free_compound_page (struct page *page) {mem_cgroup_uncharge (page); -__free_pages_ok (page,compound_order (page)); +__free_pages_ok (page,compound_order (page),FOP_NONE ); }void prep_compound_page (struct page *page,unsigned int order)@@ -1419,17 +1420,15 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_unlock (&zone->lock); } -static void free_one_page (struct zone *zone, -struct page *page,unsigned long pfn, -unsigned int order, -int migratetype) +static void free_one_page (struct zone *zone,struct page *page,unsigned long pfn, +unsigned int order,int migratetype,fop_t fop_flags) {spin_lock (&zone->lock);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE ); +__free_one_page (page, pfn, zone, order, migratetype, fop_flags);spin_unlock (&zone->lock); }@@ -1507,7 +1506,8 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) } } -static void __free_pages_ok (struct page *page,unsigned int order) +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags) {unsigned long flags;int migratetype;@@ -1519,7 +1519,8 @@ static void __free_pages_ok(struct page *page, unsigned int order) migratetype =get_pfnblock_migratetype (page, pfn);local_irq_save (flags);__count_vm_events (PGFREE ,1 << order); -free_one_page (page_zone (page), page, pfn, order, migratetype); +free_one_page (page_zone (page), page, pfn, order, migratetype, + fop_flags);local_irq_restore (flags); }@@ -1529,6 +1530,11 @@ void __free_pages_core(struct page *page, unsigned int order)struct page *p = page;unsigned int loop; +/* +* When initializing the memmap, init_single_page() sets the refcount +* of all pages to 1 ("allocated"/"not free"). We have to set the +* refcount of all involved pages to 0. +*/ prefetchw (p);for (loop =0 ; loop < (nr_pages -1 ); loop++, p++) {prefetchw (p +1 );@@ -1539,8 +1545,12 @@ void __free_pages_core(struct page *page, unsigned int order)set_page_count (p,0 );atomic_long_add (nr_pages, &page_zone (page)->managed_pages); -set_page_refcounted (page); -__free_pages (page, order); + +/* +* Bypass PCP and place fresh pages right to the tail, primarily +* relevant for memory onlining. +*/ +__free_pages_ok (page, order,FOP_TO_TAIL ); }#ifdef CONFIG_NEED_MULTIPLE_NODES @@ -3171,7 +3181,8 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn)*/ if (migratetype >=MIGRATE_PCPTYPES ) {if (unlikely (is_migrate_isolate (migratetype))) { -free_one_page (zone, page, pfn,0 , migratetype); +free_one_page (zone, page, pfn,0 , migratetype, +FOP_NONE );return ; } migratetype =MIGRATE_MOVABLE ;
mm/page_alloc.c static inline void free_the_page(struct page *page, unsigned int order) · line 5080
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -5063,7 +5074,7 @@ static inline void free_the_page(struct page *page, unsigned int order)if (order ==0 )/* Via pcp? */ free_unref_page (page);else -__free_pages_ok (page, order); +__free_pages_ok (page, order,FOP_NONE ); }void __free_pages (struct page *page,unsigned int order)
Re: [PATCH v1 2/5] mm/page_alloc: place pages to tail in __putback_isolated_page()
In reply to David HildenbrandQuoted 91 lines
__putback_isolated_page()already documents that pages will be placed to the tail of the freelist - this is, however, not the case for "order >=MAX_ORDER- 2" (seebuddy_merge_likely()) - which should be the case for all existing users.This change affects two users:
- free page reporting
- page isolation, when undoing the isolation (including memory onlining).This behavior is desireable for pages that haven't really been touched lately, so exactly the two users that don't actually read/write page content, but rather move untouched pages.
The new behavior is especially desirable for memory onlining, where we allow allocation of newly onlined pages via
undo_isolate_page_range()inonline_pages(). Right now, we always place them to the head of the free list, resulting in undesireable behavior: Assume we add individual memory chunks viaadd_memory()and online them right away to the NORMAL zone. We create a dependency chain of unmovable allocations e.g., via the memmap. The memmap of the next chunk will be placed onto previous chunks - if the last block cannot get offlined+removed, all dependent ones cannot get offlined+removed. While this can already be observed with individual DIMMs, it's more of an issue for virtio-mem (and I suspect also ppc DLPAR).Document that this should only be used for optimizations, and no code should realy on this for correction (if the order of freepage lists ever changes).
We won't care about page shuffling: memory onlining already properly shuffles after onlining. free page reporting doesn't care about physically contiguous ranges, and there are already cases where page isolation will simply move (physically close) free pages to (currently) the head of the freelists via
move_freepages_block()instead of shuffling. If this becomes ever relevant, we should shuffle the whole zone when undoing isolation of larger ranges, and afterfree_contig_range().Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- mm/page_alloc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)mm/page_alloc.c +15
-1@@ -89,6 +89,18 @@ typedef int __bitwise fop_t;*/ #define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* +* Place the (possibly merged) page to the tail of the freelist. Will ignore +* page shuffling (relevant code - e.g., memory onlining - is expected to +* shuffle the whole zone). +* +* Note: No code should rely onto this flag for correctness - it's purely +* to allow for optimizations when handing back either fresh pages +* (memory onlining) or untouched pages (page isolation, free page +* reporting). +*/ +#define FOP_TO_TAIL ((__force fop_t)BIT(1)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -1038,7 +1050,9 @@ static inline void __free_one_page(struct page *page, unsigned long pfn, done_merging:set_page_order (page, order); -if (is_shuffle_order (order)) +if (fop_flags &FOP_TO_TAIL ) + to_tail = true; +else if (is_shuffle_order (order)) to_tail =shuffle_pick_tail ();else to_tail =buddy_merge_likely (pfn, buddy_pfn, page, order);
mm/page_alloc.c void __putback_isolated_page(struct page *page, unsigned int order, int mt) · line 3318
Quoted 6 lines
mm/page_alloc.c +1
-1@@ -3300,7 +3314,7 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)/* Return isolated page to tail of freelist. */ __free_one_page (page,page_to_pfn (page), zone, order, mt, -FOP_SKIP_REPORT_NOTIFY ); +FOP_SKIP_REPORT_NOTIFY |FOP_TO_TAIL ); }
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to David HildenbrandQuoted 171 lines
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)include/linux/page-isolation.h +2
-2@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. mm/page_alloc.c +24
-11@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); } +/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +static inline void del_page_from_free_list (struct page *page,struct zone *zone,unsigned int order) {@@ -2338,9 +2347,9 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone,* Note that start_page and end_pages are not aligned on a pageblock * boundary. If alignment is required, use move_freepages_block() */ -static int move_freepages (struct zone *zone, -struct page *start_page,struct page *end_page, -int migratetype,int *num_movable) +static int move_freepages (struct zone *zone,struct page *start_page, +struct page *end_page,int migratetype, +bool to_tail,int *num_movable) {struct page *page;unsigned int order;@@ -2371,7 +2380,10 @@ static int move_freepages(struct zone *zone,VM_BUG_ON_PAGE (page_zone (page) != zone, page); order =page_order (page); -move_to_free_list (page, zone, order, migratetype); +if (to_tail) +move_to_free_list_tail (page, zone, order, migratetype); +else +move_to_free_list (page, zone, order, migratetype); page +=1 << order; pages_moved +=1 << order; }@@ -2379,8 +2391,8 @@ static int move_freepages(struct zone *zone,return pages_moved; } -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable) +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable) {unsigned long start_pfn, end_pfn;struct page *start_page, *end_page;@@ -2401,7 +2413,7 @@ int move_freepages_block(struct zone *zone, struct page *page,return 0 ;return move_freepages (zone, start_page, end_page, migratetype, - num_movable); + to_tail, num_movable); } static void change_pageblock_range(struct page *pageblock_page,@@ -2526,8 +2538,8 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,if (!whole_block) goto single_page; - free_pages =move_freepages_block (zone, page, start_type, - &movable_pages); + free_pages =move_freepages_block (zone, page, start_type, false, + &movable_pages);/* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which @@ -2635,7 +2647,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone, && !is_migrate_cma(mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC ); -move_freepages_block (zone, page,MIGRATE_HIGHATOMIC ,NULL ); +move_freepages_block (zone, page,MIGRATE_HIGHATOMIC , false, +NULL ); } out_unlock:@@ -2711,7 +2724,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,*/ set_pageblock_migratetype (page, ac->migratetype); ret =move_freepages_block (zone, page, ac->migratetype, -NULL ); + false,NULL );if (ret) {spin_unlock_irqrestore (&zone->lock, flags);return ret;mm/page_isolation.c +5
-2@@ -45,7 +45,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_set_pageblock_migratetype (page,MIGRATE_ISOLATE ); zone->nr_isolate_pageblock++; nr_pages =move_freepages_block (zone, page,MIGRATE_ISOLATE , -NULL ); + false,NULL );__mod_zone_freepage_state (zone, -nr_pages, mt);spin_unlock_irqrestore (&zone->lock, flags);@@ -83,7 +83,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* Because freepage with more than pageblock_order on isolated * pageblock is restricted to merge due to freepage counting problem, * it is possible that there is free buddy page. -* move_freepages_block() doesn't care of merge so we need other +* move_freepages_block() don't care about merging, so we need another * approach in order to merge them. Isolation and free will make * these pages to be merged. */ @@ -106,9 +106,15 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* If we isolate freepage with more than pageblock_order, there * should be no freepage in the range, so we could avoid costly * pageblock scanning for freepage moving. +* +* We didn't actually touch any of the isolated pages, so place them +* to the tail of the freelist. This is an optimization for memory
mm/page_isolation.c static void unset_migratetype_isolate(struct page *page, unsigned migratetype) · line 120
Quoted 10 lines
mm/page_isolation.c +4
-1+* onlining - just onlined memory won't immediately be considered for +* allocation. */ if (!isolated_page) { - nr_pages =move_freepages_block (zone, page, migratetype,NULL ); + nr_pages =move_freepages_block (zone, page, migratetype, true, +NULL );__mod_zone_freepage_state (zone, nr_pages, migratetype); }set_pageblock_migratetype (page, migratetype);
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
In reply to David HildenbrandQuoted 5 lines · David Hildenbrand
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.
Quoted 13 lines
Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 80 lines
---
mm/page_alloc.c| 28 ++++++++++++++++++++--------1 file changed, 20 insertions(+), 8 deletions(-)mm/page_alloc.c +20
-8@@ -77,6 +77,18 @@#include "shuffle.h" #include "page_reporting.h" +/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ; + +/* No special request */ +#define FOP_NONE ((__force fop_t)0) + +/* +* Skip free page reporting notification for the (possibly merged) page. (will +* *not* mark the page reported, only skip the notification). +*/ +#define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -948,10 +960,9 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,* -- nyc */ -static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags) {struct capture_control *capc =task_capc (zone);unsigned long buddy_pfn;@@ -1038,7 +1049,7 @@ static inline void __free_one_page(struct page *page,add_to_free_list (page, zone, order, migratetype);/* Notify page reporting subsystem of freed page */ -if (report) +if (!(fop_flags &FOP_SKIP_REPORT_NOTIFY ))page_reporting_notify_free (order); }@@ -1379,7 +1390,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,if (unlikely (isolated_pageblocks)) mt =get_pageblock_migratetype (page); -__free_one_page (page,page_to_pfn (page), zone,0 , mt, true); +__free_one_page (page,page_to_pfn (page), zone,0 , mt,FOP_NONE );trace_mm_page_pcpu_drain (page,0 , mt); }spin_unlock (&zone->lock);@@ -1395,7 +1406,7 @@ static void free_one_page(struct zone *zone, is_migrate_isolate(migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype, true); +__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE );spin_unlock (&zone->lock); }@@ -3288,7 +3299,8 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)lockdep_assert_held (&zone->lock);/* Return isolated page to tail of freelist. */ -__free_one_page (page,page_to_pfn (page), zone, order, mt, false); +__free_one_page (page,page_to_pfn (page), zone, order, mt, +FOP_SKIP_REPORT_NOTIFY ); }/* Signature · 1 line
2.26.2
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 2/5] mm/page_alloc: place pages to tail in __putback_isolated_page()
In reply to David HildenbrandQuoted 38 lines · David Hildenbrand
__putback_isolated_page()already documents that pages will be placed to the tail of the freelist - this is, however, not the case for "order >=MAX_ORDER- 2" (seebuddy_merge_likely()) - which should be the case for all existing users.This change affects two users:
- free page reporting
- page isolation, when undoing the isolation (including memory onlining).This behavior is desireable for pages that haven't really been touched lately, so exactly the two users that don't actually read/write page content, but rather move untouched pages.
The new behavior is especially desirable for memory onlining, where we allow allocation of newly onlined pages via
undo_isolate_page_range()inonline_pages(). Right now, we always place them to the head of the free list, resulting in undesireable behavior: Assume we add individual memory chunks viaadd_memory()and online them right away to the NORMAL zone. We create a dependency chain of unmovable allocations e.g., via the memmap. The memmap of the next chunk will be placed onto previous chunks - if the last block cannot get offlined+removed, all dependent ones cannot get offlined+removed. While this can already be observed with individual DIMMs, it's more of an issue for virtio-mem (and I suspect also ppc DLPAR).Document that this should only be used for optimizations, and no code should realy on this for correction (if the order of freepage lists ever changes).
We won't care about page shuffling: memory onlining already properly shuffles after onlining. free page reporting doesn't care about physically contiguous ranges, and there are already cases where page isolation will simply move (physically close) free pages to (currently) the head of the freelists via
move_freepages_block()instead of shuffling. If this becomes ever relevant, we should shuffle the whole zone when undoing isolation of larger ranges, and afterfree_contig_range().
Quoted 14 lines
Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 49 lines
---
mm/page_alloc.c| 18 ++++++++++++++++--1 file changed, 16 insertions(+), 2 deletions(-)mm/page_alloc.c +12
-0@@ -89,6 +89,18 @@ typedef int __bitwise fop_t;*/ #define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* +* Place the (possibly merged) page to the tail of the freelist. Will ignore +* page shuffling (relevant code - e.g., memory onlining - is expected to +* shuffle the whole zone). +* +* Note: No code should rely onto this flag for correctness - it's purely +* to allow for optimizations when handing back either fresh pages +* (memory onlining) or untouched pages (page isolation, free page +* reporting). +*/ +#define FOP_TO_TAIL ((__force fop_t)BIT(1)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -1038,7 +1050,9 @@ static inline void __free_one_page(struct page *page, unsigned long pfn,
done_merging:set_page_order(page, order);mm/page_alloc.c +3
-1-if (is_shuffle_order (order)) +if (fop_flags &FOP_TO_TAIL ) + to_tail = true; +else if (is_shuffle_order (order))to_tail = shuffle_pick_tail(); else to_tail = buddy_merge_likely(pfn, buddy_pfn, page, order);mm/page_alloc.c +1
-1@@ -3300,7 +3314,7 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)/* Return isolated page to tail of freelist. */ __free_one_page (page,page_to_pfn (page), zone, order, mt, -FOP_SKIP_REPORT_NOTIFY ); +FOP_SKIP_REPORT_NOTIFY |FOP_TO_TAIL ); }/* Signature · 1 line
2.26.2
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to David HildenbrandQuoted 54 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>---
include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)include/linux/page-isolation.h +2
-2@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. mm/page_alloc.c +0
-0@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); }
mm/page_alloc.c static inline void move_to_free_list(struct page *page, struct zone *zone, · line 916
Quoted 10 lines
mm/page_alloc.c +9
-0+/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +
Would it be better to pass the *to_tail* to move_to_free_list(), so we won't have a new function?
Quoted 17 lines
mm/page_alloc.c +3
-3static inline void del_page_from_free_list (struct page *page,struct zone *zone,unsigned int order) {@@ -2338,9 +2347,9 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone,* Note that start_page and end_pages are not aligned on a pageblock * boundary. If alignment is required, use move_freepages_block() */ -static int move_freepages (struct zone *zone, -struct page *start_page,struct page *end_page, -int migratetype,int *num_movable) +static int move_freepages (struct zone *zone,struct page *start_page, +struct page *end_page,int migratetype, +bool to_tail,int *num_movable) {struct page *page;unsigned int order;
mm/page_alloc.c static int move_freepages(struct zone *zone, · line 2386
Quoted 8 lines
mm/page_alloc.c +4
-1@@ -2371,7 +2380,10 @@ static int move_freepages(struct zone *zone,VM_BUG_ON_PAGE (page_zone (page) != zone, page); order =page_order (page); -move_to_free_list (page, zone, order, migratetype); +if (to_tail) +move_to_free_list_tail (page, zone, order, migratetype); +else +move_to_free_list (page, zone, order, migratetype);
And here, we just need to pass the *to_tail* to move_to_free_list().
Quoted 94 lines
mm/page_alloc.c +7
-6page +=1 << order; pages_moved +=1 << order; }@@ -2379,8 +2391,8 @@ static int move_freepages(struct zone *zone,return pages_moved; } -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable) +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable) {unsigned long start_pfn, end_pfn;struct page *start_page, *end_page;@@ -2401,7 +2413,7 @@ int move_freepages_block(struct zone *zone, struct page *page,return 0 ;return move_freepages (zone, start_page, end_page, migratetype, - num_movable); + to_tail, num_movable); } static void change_pageblock_range(struct page *pageblock_page,@@ -2526,8 +2538,8 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,if (!whole_block) goto single_page; - free_pages =move_freepages_block (zone, page, start_type, - &movable_pages); + free_pages =move_freepages_block (zone, page, start_type, false, + &movable_pages);/* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which @@ -2635,7 +2647,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone, && !is_migrate_cma(mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC ); -move_freepages_block (zone, page,MIGRATE_HIGHATOMIC ,NULL ); +move_freepages_block (zone, page,MIGRATE_HIGHATOMIC , false, +NULL ); }
out_unlock:mm/page_alloc.c +1
-1@@ -2711,7 +2724,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,*/ set_pageblock_migratetype (page, ac->migratetype); ret =move_freepages_block (zone, page, ac->migratetype, -NULL ); + false,NULL );if (ret) {spin_unlock_irqrestore (&zone->lock, flags);return ret;mm/page_isolation.c +9
-3@@ -45,7 +45,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_set_pageblock_migratetype (page,MIGRATE_ISOLATE ); zone->nr_isolate_pageblock++; nr_pages =move_freepages_block (zone, page,MIGRATE_ISOLATE , -NULL ); + false,NULL );__mod_zone_freepage_state (zone, -nr_pages, mt);spin_unlock_irqrestore (&zone->lock, flags);@@ -83,7 +83,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* Because freepage with more than pageblock_order on isolated * pageblock is restricted to merge due to freepage counting problem, * it is possible that there is free buddy page. -* move_freepages_block() doesn't care of merge so we need other +* move_freepages_block() don't care about merging, so we need another * approach in order to merge them. Isolation and free will make * these pages to be merged. */ @@ -106,9 +106,15 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* If we isolate freepage with more than pageblock_order, there * should be no freepage in the range, so we could avoid costly * pageblock scanning for freepage moving. +* +* We didn't actually touch any of the isolated pages, so place them +* to the tail of the freelist. This is an optimization for memory +* onlining - just onlined memory won't immediately be considered for +* allocation. */ if (!isolated_page) { - nr_pages =move_freepages_block (zone, page, migratetype,NULL ); + nr_pages =move_freepages_block (zone, page, migratetype, true, +NULL );__mod_zone_freepage_state (zone, nr_pages, migratetype); }set_pageblock_migratetype (page, migratetype);Signature · 1 line
2.26.2
Others looks good to me.
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 4/5] mm/page_alloc: place pages to tail in __free_pages_core()
In reply to David HildenbrandQuoted 115 lines · David Hildenbrand
__free_pages_core()is used when exposing fresh memory to the buddy during system boot and when onlining memory ingeneric_online_page().
generic_online_page()is used in two cases:1. Direct memory onlining in
online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.In 1, we already place pages to the tail of the freelist. Pages will be freed to
MIGRATE_ISOLATElists first and moved to the tail of the freelists viaundo_isolate_page_range().In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online
MAX_ORDER- 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon callsgeneric_online_page()with single pages, usually it will call it on successive single pages in a larger block.The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In
__free_pages_core(), remove the now superflouos call toset_page_refcounted()and add a comment regarding page initialization and the refcount.Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of
generic_online_page()calls in the relevant callers.Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Stephen Hemminger <[email protected]>Cc Wei Liu <[email protected]>Signed-off-by David Hildenbrand <[email protected]>---
mm/page_alloc.c| 37 ++++++++++++++++++++++++-------------1 file changed, 24 insertions(+), 13 deletions(-)mm/page_alloc.c +10
-9@@ -270,7 +270,8 @@ bool pm_suspended_storage(void)unsigned int pageblock_order__read_mostly ;#endif -static void __free_pages_ok (struct page *page,unsigned int order); +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags);/* * results with 256, 32 in the lowmem_reserve sysctl: @@ -682,7 +683,7 @@ static void bad_page(struct page *page, const char *reason)void free_compound_page (struct page *page) {mem_cgroup_uncharge (page); -__free_pages_ok (page,compound_order (page)); +__free_pages_ok (page,compound_order (page),FOP_NONE ); }void prep_compound_page (struct page *page,unsigned int order)@@ -1419,17 +1420,15 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_unlock (&zone->lock); } -static void free_one_page (struct zone *zone, -struct page *page,unsigned long pfn, -unsigned int order, -int migratetype) +static void free_one_page (struct zone *zone,struct page *page,unsigned long pfn, +unsigned int order,int migratetype,fop_t fop_flags) {spin_lock (&zone->lock);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE ); +__free_one_page (page, pfn, zone, order, migratetype, fop_flags);spin_unlock (&zone->lock); }@@ -1507,7 +1506,8 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) } } -static void __free_pages_ok (struct page *page,unsigned int order) +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags) {unsigned long flags;int migratetype;@@ -1519,7 +1519,8 @@ static void __free_pages_ok(struct page *page, unsigned int order) migratetype =get_pfnblock_migratetype (page, pfn);local_irq_save (flags);__count_vm_events (PGFREE ,1 << order); -free_one_page (page_zone (page), page, pfn, order, migratetype); +free_one_page (page_zone (page), page, pfn, order, migratetype, + fop_flags);local_irq_restore (flags); }
mm/page_alloc.c void __free_pages_core(struct page *page, unsigned int order) · line 1534
Quoted 5 lines
mm/page_alloc.c +2
-0@@ -1529,6 +1530,11 @@ void __free_pages_core(struct page *page, unsigned int order)struct page *p = page;unsigned int loop; +/* +* When initializing the memmap, init_single_page() sets the refcount
If my code is the latest version.
s/init_single_page/__init_single_page/
Besides this.
Quoted 42 lines
mm/page_alloc.c +12
-4+* of all pages to 1 ("allocated"/"not free"). We have to set the +* refcount of all involved pages to 0. +*/ prefetchw (p);for (loop =0 ; loop < (nr_pages -1 ); loop++, p++) {prefetchw (p +1 );@@ -1539,8 +1545,12 @@ void __free_pages_core(struct page *page, unsigned int order)set_page_count (p,0 );atomic_long_add (nr_pages, &page_zone (page)->managed_pages); -set_page_refcounted (page); -__free_pages (page, order); + +/* +* Bypass PCP and place fresh pages right to the tail, primarily +* relevant for memory onlining. +*/ +__free_pages_ok (page, order,FOP_TO_TAIL ); }#ifdef CONFIG_NEED_MULTIPLE_NODES @@ -3171,7 +3181,8 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn)*/ if (migratetype >=MIGRATE_PCPTYPES ) {if (unlikely (is_migrate_isolate (migratetype))) { -free_one_page (zone, page, pfn,0 , migratetype); +free_one_page (zone, page, pfn,0 , migratetype, +FOP_NONE );return ; } migratetype =MIGRATE_MOVABLE ;@@ -5063,7 +5074,7 @@ static inline void free_the_page(struct page *page, unsigned int order)if (order ==0 )/* Via pcp? */ free_unref_page (page);else -__free_pages_ok (page, order); +__free_pages_ok (page, order,FOP_NONE ); }void __free_pages (struct page *page,unsigned int order)Signature · 1 line
2.26.2
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 5/5] mm/memory_hotplug: update comment regarding zone shuffling
In reply to David HildenbrandQuoted 6 lines · David Hildenbrand
As we no longer shuffle via
generic_online_page()and when undoing isolation, we can simplify the comment.We now effectively shuffle only once (properly) when onlining new memory.
Quoted 10 lines
Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 28 lines
---
mm/memory_hotplug.c| 11 ++++-------1 file changed, 4 insertions(+), 7 deletions(-)mm/memory_hotplug.c +4
-7@@ -859,13 +859,10 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,undo_isolate_page_range (pfn, pfn + nr_pages,MIGRATE_MOVABLE );/* -* When exposing larger, physically contiguous memory areas to the -* buddy, shuffling in the buddy (when freeing onlined pages, putting -* them either to the head or the tail of the freelist) is only helpful -* for maintaining the shuffle, but not for creating the initial -* shuffle. Shuffle the whole zone to make sure the just onlined pages -* are properly distributed across the whole freelist. Make sure to -* shuffle once pageblocks are no longer isolated. +* Freshly onlined pages aren't shuffled (e.g., all pages are placed to +* the tail of the freelist when undoing isolation). Shuffle the whole +* zone to make sure the just onlined pages are properly distributed +* across the whole freelist - to create an initial shuffle. */ shuffle_zone (zone);Signature · 1 line
2.26.2
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to Wei YangQuoted 10 lines · Wei Yang
Quoted 9 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().
s/a a/a/
Quoted 46 lines
Quoted 46 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>---
include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)include/linux/page-isolation.h +2
-2@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. mm/page_alloc.c +0
-0@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); }
Quoted 12 lines
mm/page_alloc.c static inline void move_to_free_list(struct page *page, struct zone *zone, · line 916
Quoted 9 lines
mm/page_alloc.c +9
-0+/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +Would it be better to pass the *to_tail* to
move_to_free_list(), so we won't have a new function?
Hi,
thanks for the review!
See discussion in RFC + cover letter:
"Add a "to_tail" parameter to move_freepages_block() but introduce a new move_to_free_list_tail() - similar to add_to_free_list_tail()."
Re: [PATCH v1 4/5] mm/page_alloc: place pages to tail in __free_pages_core()
In reply to Wei YangQuoted 119 lines · Wei Yang
Quoted 118 lines · David Hildenbrand
__free_pages_core()is used when exposing fresh memory to the buddy during system boot and when onlining memory ingeneric_online_page().
generic_online_page()is used in two cases:1. Direct memory onlining in
online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.In 1, we already place pages to the tail of the freelist. Pages will be freed to
MIGRATE_ISOLATElists first and moved to the tail of the freelists viaundo_isolate_page_range().In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online
MAX_ORDER- 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon callsgeneric_online_page()with single pages, usually it will call it on successive single pages in a larger block.The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In
__free_pages_core(), remove the now superflouos call toset_page_refcounted()and add a comment regarding page initialization and the refcount.Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of
generic_online_page()calls in the relevant callers.Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Stephen Hemminger <[email protected]>Cc Wei Liu <[email protected]>Signed-off-by David Hildenbrand <[email protected]>---
mm/page_alloc.c| 37 ++++++++++++++++++++++++-------------1 file changed, 24 insertions(+), 13 deletions(-)mm/page_alloc.c +10
-9@@ -270,7 +270,8 @@ bool pm_suspended_storage(void)unsigned int pageblock_order__read_mostly ;#endif -static void __free_pages_ok (struct page *page,unsigned int order); +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags);/* * results with 256, 32 in the lowmem_reserve sysctl: @@ -682,7 +683,7 @@ static void bad_page(struct page *page, const char *reason)void free_compound_page (struct page *page) {mem_cgroup_uncharge (page); -__free_pages_ok (page,compound_order (page)); +__free_pages_ok (page,compound_order (page),FOP_NONE ); }void prep_compound_page (struct page *page,unsigned int order)@@ -1419,17 +1420,15 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_unlock (&zone->lock); } -static void free_one_page (struct zone *zone, -struct page *page,unsigned long pfn, -unsigned int order, -int migratetype) +static void free_one_page (struct zone *zone,struct page *page,unsigned long pfn, +unsigned int order,int migratetype,fop_t fop_flags) {spin_lock (&zone->lock);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE ); +__free_one_page (page, pfn, zone, order, migratetype, fop_flags);spin_unlock (&zone->lock); }@@ -1507,7 +1506,8 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) } } -static void __free_pages_ok (struct page *page,unsigned int order) +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags) {unsigned long flags;int migratetype;@@ -1519,7 +1519,8 @@ static void __free_pages_ok(struct page *page, unsigned int order) migratetype =get_pfnblock_migratetype (page, pfn);local_irq_save (flags);__count_vm_events (PGFREE ,1 << order); -free_one_page (page_zone (page), page, pfn, order, migratetype); +free_one_page (page_zone (page), page, pfn, order, migratetype, + fop_flags);local_irq_restore (flags); }@@ -1529,6 +1530,11 @@ void __free_pages_core(struct page *page, unsigned int order)struct page *p = page;unsigned int loop;
Quoted 6 lines
mm/page_alloc.c void __free_pages_core(struct page *page, unsigned int order) · line 1534
Quoted 2 lines
mm/page_alloc.c +2
-0+/* +* When initializing the memmap, init_single_page() sets the refcount If my code is the latest version.
s/init_single_page/__init_single_page/
Indeed - thanks!
Signature · 3 lines
Thanks, David / dhildenb
Wei Yang
Reviewed-byRe: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to David HildenbrandQuoted 73 lines · David Hildenbrand
Quoted 10 lines · Wei Yang
Quoted 9 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().s/a a/a/
Quoted 46 lines
Quoted 46 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>---
include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)include/linux/page-isolation.h +2
-2@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. mm/page_alloc.c +0
-0@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); }Quoted 12 lines
mm/page_alloc.c static inline void move_to_free_list(struct page *page, struct zone *zone, · line 916
Quoted 9 lines
mm/page_alloc.c +9
-0+/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +Would it be better to pass the *to_tail* to
move_to_free_list(), so we won't have a new function?
Quoted 8 lines
Hi,
thanks for the review!
See discussion in RFC + cover letter:
"Add a "
to_tail" parameter tomove_freepages_block()but introduce a newmove_to_free_list_tail()- similar toadd_to_free_list_tail()."
Hmm, sounds reasonable.
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
In reply to David HildenbrandQuoted 5 lines · David Hildenbrand
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.
Quoted 13 lines
Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Hopefully this will not wrack the generated code. But considering we would need another parameter there is not much choice left.
Quoted 80 lines
--- mm/page_alloc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)mm/page_alloc.c +20
-8@@ -77,6 +77,18 @@#include "shuffle.h" #include "page_reporting.h" +/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ; + +/* No special request */ +#define FOP_NONE ((__force fop_t)0) + +/* +* Skip free page reporting notification for the (possibly merged) page. (will +* *not* mark the page reported, only skip the notification). +*/ +#define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -948,10 +960,9 @@ buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn,* -- nyc */ -static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags) {struct capture_control *capc =task_capc (zone);unsigned long buddy_pfn;@@ -1038,7 +1049,7 @@ static inline void __free_one_page(struct page *page,add_to_free_list (page, zone, order, migratetype);/* Notify page reporting subsystem of freed page */ -if (report) +if (!(fop_flags &FOP_SKIP_REPORT_NOTIFY ))page_reporting_notify_free (order); }@@ -1379,7 +1390,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,if (unlikely (isolated_pageblocks)) mt =get_pageblock_migratetype (page); -__free_one_page (page,page_to_pfn (page), zone,0 , mt, true); +__free_one_page (page,page_to_pfn (page), zone,0 , mt,FOP_NONE );trace_mm_page_pcpu_drain (page,0 , mt); }spin_unlock (&zone->lock);@@ -1395,7 +1406,7 @@ static void free_one_page(struct zone *zone, is_migrate_isolate(migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype, true); +__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE );spin_unlock (&zone->lock); }@@ -3288,7 +3299,8 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)lockdep_assert_held (&zone->lock);/* Return isolated page to tail of freelist. */ -__free_one_page (page,page_to_pfn (page), zone, order, mt, false); +__free_one_page (page,page_to_pfn (page), zone, order, mt, +FOP_SKIP_REPORT_NOTIFY ); }/* Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH v1 2/5] mm/page_alloc: place pages to tail in __putback_isolated_page()
In reply to David HildenbrandQuoted 38 lines · David Hildenbrand
__putback_isolated_page()already documents that pages will be placed to the tail of the freelist - this is, however, not the case for "order >=MAX_ORDER- 2" (seebuddy_merge_likely()) - which should be the case for all existing users.This change affects two users:
- free page reporting
- page isolation, when undoing the isolation (including memory onlining).This behavior is desireable for pages that haven't really been touched lately, so exactly the two users that don't actually read/write page content, but rather move untouched pages.
The new behavior is especially desirable for memory onlining, where we allow allocation of newly onlined pages via
undo_isolate_page_range()inonline_pages(). Right now, we always place them to the head of the free list, resulting in undesireable behavior: Assume we add individual memory chunks viaadd_memory()and online them right away to the NORMAL zone. We create a dependency chain of unmovable allocations e.g., via the memmap. The memmap of the next chunk will be placed onto previous chunks - if the last block cannot get offlined+removed, all dependent ones cannot get offlined+removed. While this can already be observed with individual DIMMs, it's more of an issue for virtio-mem (and I suspect also ppc DLPAR).Document that this should only be used for optimizations, and no code should realy on this for correction (if the order of freepage lists ever changes).
We won't care about page shuffling: memory onlining already properly shuffles after onlining. free page reporting doesn't care about physically contiguous ranges, and there are already cases where page isolation will simply move (physically close) free pages to (currently) the head of the freelists via
move_freepages_block()instead of shuffling. If this becomes ever relevant, we should shuffle the whole zone when undoing isolation of larger ranges, and afterfree_contig_range().
Quoted 14 lines
Reviewed-by Alexander Duyck <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 49 lines
--- mm/page_alloc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)mm/page_alloc.c +16
-2@@ -89,6 +89,18 @@ typedef int __bitwise fop_t;*/ #define FOP_SKIP_REPORT_NOTIFY ((__force fop_t)BIT(0)) +/* +* Place the (possibly merged) page to the tail of the freelist. Will ignore +* page shuffling (relevant code - e.g., memory onlining - is expected to +* shuffle the whole zone). +* +* Note: No code should rely onto this flag for correctness - it's purely +* to allow for optimizations when handing back either fresh pages +* (memory onlining) or untouched pages (page isolation, free page +* reporting). +*/ +#define FOP_TO_TAIL ((__force fop_t)BIT(1)) +/* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX (pcp_batch_high_lock);#define MIN_PERCPU_PAGELIST_FRACTION (8)@@ -1038,7 +1050,9 @@ static inline void __free_one_page(struct page *page, unsigned long pfn, done_merging:set_page_order (page, order); -if (is_shuffle_order (order)) +if (fop_flags &FOP_TO_TAIL ) + to_tail = true; +else if (is_shuffle_order (order)) to_tail =shuffle_pick_tail ();else to_tail =buddy_merge_likely (pfn, buddy_pfn, page, order);@@ -3300,7 +3314,7 @@ void __putback_isolated_page(struct page *page, unsigned int order, int mt)/* Return isolated page to tail of freelist. */ __free_one_page (page,page_to_pfn (page), zone, order, mt, -FOP_SKIP_REPORT_NOTIFY ); +FOP_SKIP_REPORT_NOTIFY |FOP_TO_TAIL ); }/* Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko SUSE Labs
Michal Hocko
reviewerRe: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to David HildenbrandQuoted 7 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.
Quoted 5 lines
Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.
Is there anything preventing to do this unconditionally? Or in other words is any of the existing callers of move_freepages_block benefiting from adding to the head?
Quoted 170 lines
Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc Scott Cheloha <[email protected]>Cc Michael Ellerman <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- include/linux/page-isolation.h | 4 ++-- mm/page_alloc.c | 35 +++++++++++++++++++++++----------- mm/page_isolation.c | 12 +++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-)include/linux/page-isolation.h +2
-2@@ -36,8 +36,8 @@ static inline bool is_migrate_isolate(int migratetype)struct page *has_unmovable_pages (struct zone *zone,struct page *page,int migratetype,int flags);void set_pageblock_migratetype (struct page *page,int migratetype); -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable); +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable);/* * Changes migrate type in [start_pfn, end_pfn) to be MIGRATE_ISOLATE. mm/page_alloc.c +24
-11@@ -905,6 +905,15 @@ static inline void move_to_free_list(struct page *page, struct zone *zone,list_move (&page->lru, &area->free_list[migratetype]); } +/* Used for pages which are on another list */ +static inline void move_to_free_list_tail (struct page *page,struct zone *zone, +unsigned int order,int migratetype) +{ +struct free_area *area = &zone->free_area[order]; + +list_move_tail (&page->lru, &area->free_list[migratetype]); +} +static inline void del_page_from_free_list (struct page *page,struct zone *zone,unsigned int order) {@@ -2338,9 +2347,9 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone,* Note that start_page and end_pages are not aligned on a pageblock * boundary. If alignment is required, use move_freepages_block() */ -static int move_freepages (struct zone *zone, -struct page *start_page,struct page *end_page, -int migratetype,int *num_movable) +static int move_freepages (struct zone *zone,struct page *start_page, +struct page *end_page,int migratetype, +bool to_tail,int *num_movable) {struct page *page;unsigned int order;@@ -2371,7 +2380,10 @@ static int move_freepages(struct zone *zone,VM_BUG_ON_PAGE (page_zone (page) != zone, page); order =page_order (page); -move_to_free_list (page, zone, order, migratetype); +if (to_tail) +move_to_free_list_tail (page, zone, order, migratetype); +else +move_to_free_list (page, zone, order, migratetype); page +=1 << order; pages_moved +=1 << order; }@@ -2379,8 +2391,8 @@ static int move_freepages(struct zone *zone,return pages_moved; } -int move_freepages_block (struct zone *zone,struct page *page, -int migratetype,int *num_movable) +int move_freepages_block (struct zone *zone,struct page *page,int migratetype, +bool to_tail,int *num_movable) {unsigned long start_pfn, end_pfn;struct page *start_page, *end_page;@@ -2401,7 +2413,7 @@ int move_freepages_block(struct zone *zone, struct page *page,return 0 ;return move_freepages (zone, start_page, end_page, migratetype, - num_movable); + to_tail, num_movable); } static void change_pageblock_range(struct page *pageblock_page,@@ -2526,8 +2538,8 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page,if (!whole_block) goto single_page; - free_pages =move_freepages_block (zone, page, start_type, - &movable_pages); + free_pages =move_freepages_block (zone, page, start_type, false, + &movable_pages);/* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which @@ -2635,7 +2647,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone, && !is_migrate_cma(mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC ); -move_freepages_block (zone, page,MIGRATE_HIGHATOMIC ,NULL ); +move_freepages_block (zone, page,MIGRATE_HIGHATOMIC , false, +NULL ); } out_unlock:@@ -2711,7 +2724,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,*/ set_pageblock_migratetype (page, ac->migratetype); ret =move_freepages_block (zone, page, ac->migratetype, -NULL ); + false,NULL );if (ret) {spin_unlock_irqrestore (&zone->lock, flags);return ret;mm/page_isolation.c +9
-3@@ -45,7 +45,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_set_pageblock_migratetype (page,MIGRATE_ISOLATE ); zone->nr_isolate_pageblock++; nr_pages =move_freepages_block (zone, page,MIGRATE_ISOLATE , -NULL ); + false,NULL );__mod_zone_freepage_state (zone, -nr_pages, mt);spin_unlock_irqrestore (&zone->lock, flags);@@ -83,7 +83,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* Because freepage with more than pageblock_order on isolated * pageblock is restricted to merge due to freepage counting problem, * it is possible that there is free buddy page. -* move_freepages_block() doesn't care of merge so we need other +* move_freepages_block() don't care about merging, so we need another * approach in order to merge them. Isolation and free will make * these pages to be merged. */ @@ -106,9 +106,15 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype)* If we isolate freepage with more than pageblock_order, there * should be no freepage in the range, so we could avoid costly * pageblock scanning for freepage moving. +* +* We didn't actually touch any of the isolated pages, so place them +* to the tail of the freelist. This is an optimization for memory +* onlining - just onlined memory won't immediately be considered for +* allocation. */ if (!isolated_page) { - nr_pages =move_freepages_block (zone, page, migratetype,NULL ); + nr_pages =move_freepages_block (zone, page, migratetype, true, +NULL );__mod_zone_freepage_state (zone, nr_pages, migratetype); }set_pageblock_migratetype (page, migratetype);Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH v1 4/5] mm/page_alloc: place pages to tail in __free_pages_core()
In reply to David HildenbrandQuoted 25 lines · David Hildenbrand
__free_pages_core()is used when exposing fresh memory to the buddy during system boot and when onlining memory ingeneric_online_page().
generic_online_page()is used in two cases:1. Direct memory onlining in
online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.In 1, we already place pages to the tail of the freelist. Pages will be freed to
MIGRATE_ISOLATElists first and moved to the tail of the freelists viaundo_isolate_page_range().In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online
MAX_ORDER- 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon callsgeneric_online_page()with single pages, usually it will call it on successive single pages in a larger block.The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In
__free_pages_core(), remove the now superflouos call toset_page_refcounted()and add a comment regarding page initialization and the refcount.
Quoted 4 lines
Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of
generic_online_page()calls in the relevant callers.
It took some time to get through all the freeing paths with subtle differences but this looks reasonable. You are mentioning that this influences a boot time free memory ordering as well but only very briefly. I do not expect this to make a huge difference but who knows. It makes some sense to add pages in the order they show up in the physical address ordering.
Quoted 8 lines
Reviewed-by Vlastimil Babka <[email protected]>Reviewed-by Oscar Salvador <[email protected]>Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>
Quoted 8 lines
Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Stephen Hemminger <[email protected]>Cc Wei Liu <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
That being said I do not see any fundamental problems.
Quoted 117 lines
--- mm/page_alloc.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)mm/page_alloc.c +24
-13@@ -270,7 +270,8 @@ bool pm_suspended_storage(void)unsigned int pageblock_order__read_mostly ;#endif -static void __free_pages_ok (struct page *page,unsigned int order); +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags);/* * results with 256, 32 in the lowmem_reserve sysctl: @@ -682,7 +683,7 @@ static void bad_page(struct page *page, const char *reason)void free_compound_page (struct page *page) {mem_cgroup_uncharge (page); -__free_pages_ok (page,compound_order (page)); +__free_pages_ok (page,compound_order (page),FOP_NONE ); }void prep_compound_page (struct page *page,unsigned int order)@@ -1419,17 +1420,15 @@ static void free_pcppages_bulk(struct zone *zone, int count,spin_unlock (&zone->lock); } -static void free_one_page (struct zone *zone, -struct page *page,unsigned long pfn, -unsigned int order, -int migratetype) +static void free_one_page (struct zone *zone,struct page *page,unsigned long pfn, +unsigned int order,int migratetype,fop_t fop_flags) {spin_lock (&zone->lock);if (unlikely (has_isolate_pageblock (zone) ||is_migrate_isolate (migratetype))) { migratetype =get_pfnblock_migratetype (page, pfn); } -__free_one_page (page, pfn, zone, order, migratetype,FOP_NONE ); +__free_one_page (page, pfn, zone, order, migratetype, fop_flags);spin_unlock (&zone->lock); }@@ -1507,7 +1506,8 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) } } -static void __free_pages_ok (struct page *page,unsigned int order) +static void __free_pages_ok (struct page *page,unsigned int order, +fop_t fop_flags) {unsigned long flags;int migratetype;@@ -1519,7 +1519,8 @@ static void __free_pages_ok(struct page *page, unsigned int order) migratetype =get_pfnblock_migratetype (page, pfn);local_irq_save (flags);__count_vm_events (PGFREE ,1 << order); -free_one_page (page_zone (page), page, pfn, order, migratetype); +free_one_page (page_zone (page), page, pfn, order, migratetype, + fop_flags);local_irq_restore (flags); }@@ -1529,6 +1530,11 @@ void __free_pages_core(struct page *page, unsigned int order)struct page *p = page;unsigned int loop; +/* +* When initializing the memmap, init_single_page() sets the refcount +* of all pages to 1 ("allocated"/"not free"). We have to set the +* refcount of all involved pages to 0. +*/ prefetchw (p);for (loop =0 ; loop < (nr_pages -1 ); loop++, p++) {prefetchw (p +1 );@@ -1539,8 +1545,12 @@ void __free_pages_core(struct page *page, unsigned int order)set_page_count (p,0 );atomic_long_add (nr_pages, &page_zone (page)->managed_pages); -set_page_refcounted (page); -__free_pages (page, order); + +/* +* Bypass PCP and place fresh pages right to the tail, primarily +* relevant for memory onlining. +*/ +__free_pages_ok (page, order,FOP_TO_TAIL ); }#ifdef CONFIG_NEED_MULTIPLE_NODES @@ -3171,7 +3181,8 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn)*/ if (migratetype >=MIGRATE_PCPTYPES ) {if (unlikely (is_migrate_isolate (migratetype))) { -free_one_page (zone, page, pfn,0 , migratetype); +free_one_page (zone, page, pfn,0 , migratetype, +FOP_NONE );return ; } migratetype =MIGRATE_MOVABLE ;@@ -5063,7 +5074,7 @@ static inline void free_the_page(struct page *page, unsigned int order)if (order ==0 )/* Via pcp? */ free_unref_page (page);else -__free_pages_ok (page, order); +__free_pages_ok (page, order,FOP_NONE ); }void __free_pages (struct page *page,unsigned int order)Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
In reply to David Hildenbrandmm/page_alloc.c line 81
Quoted 7 lines · David Hildenbrand
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.mm/page_alloc.c +2
-0+/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ;
That invites confusion with f_op. There's no reason to use _t as a suffix here ... why not free_f?
Quoted 3 lines
+/*
+ * Skip free page reporting notification for the (possibly merged) page. (will
+ * *not* mark the page reported, only skip the notification).
... Don't you mean "will not skip marking the page as reported, only skip the notification"?
*reads code*
No, I'm still confused. What does this sentence mean?
Would it help to have a FOP_DEFAULT that has FOP_REPORT_NOTIFY set and then a FOP_SKIP_REPORT_NOTIFY define that is 0?
mm/page_alloc.c buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn, · line 965
Quoted 7 lines
mm/page_alloc.c +3
-4-static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags)
Please don't over-indent like this.
static inline void __free_one_page(struct page *page, unsigned long pfn,
struct zone *zone, unsigned int order, int migratetype, fop_t fop_flags)
reads just as well and then if someone needs to delete the 'static' later, they don't need to fiddle around with subsequent lines getting the whitespace to line up again.
Re: [PATCH v1 5/5] mm/memory_hotplug: update comment regarding zone shuffling
In reply to David HildenbrandQuoted 6 lines · David Hildenbrand
As we no longer shuffle via
generic_online_page()and when undoing isolation, we can simplify the comment.We now effectively shuffle only once (properly) when onlining new memory.
Quoted 10 lines
Cc Andrew Morton <[email protected]>Cc Alexander Duyck <[email protected]>Cc Mel Gorman <[email protected]>Cc Michal Hocko <[email protected]>Cc Dave Hansen <[email protected]>Cc Vlastimil Babka <[email protected]>Cc Wei Yang <[email protected]>Cc Oscar Salvador <[email protected]>Cc Mike Rapoport <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 28 lines
--- mm/memory_hotplug.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)mm/memory_hotplug.c +4
-7@@ -859,13 +859,10 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,undo_isolate_page_range (pfn, pfn + nr_pages,MIGRATE_MOVABLE );/* -* When exposing larger, physically contiguous memory areas to the -* buddy, shuffling in the buddy (when freeing onlined pages, putting -* them either to the head or the tail of the freelist) is only helpful -* for maintaining the shuffle, but not for creating the initial -* shuffle. Shuffle the whole zone to make sure the just onlined pages -* are properly distributed across the whole freelist. Make sure to -* shuffle once pageblocks are no longer isolated. +* Freshly onlined pages aren't shuffled (e.g., all pages are placed to +* the tail of the freelist when undoing isolation). Shuffle the whole +* zone to make sure the just onlined pages are properly distributed +* across the whole freelist - to create an initial shuffle. */ shuffle_zone (zone);Signature · 1 line
2.26.2
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
In reply to Matthew WilcoxQuoted 11 lines · Matthew Wilcox
mm/page_alloc.c line 81
Quoted 7 lines · David Hildenbrand
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.mm/page_alloc.c +2
-0+/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ;That invites confusion with
f_op. There's no reason to use _t as a suffix here ... why notfree_f?
git grep "bitwise" | grep typedef | grep include/linux
indicates that "_t" it the right thing to do.
I want a name that highlights that is is for the internal variants of free_page(), free_f / free_t is too generic.
fpi_t (Free Page Internal) ?
Quoted 7 lines
Quoted 4 lines
+/*
+ * Skip free page reporting notification for the (possibly merged) page. (will
+ * *not* mark the page reported, only skip the notification).... Don't you mean "will not skip marking the page as reported, only skip the notification"?
Yeah, I can use that.
The way free page reporting works is that
1. Free page reporting infrastructure will get notified after buddy merging about a newly freed page.
2. Once a certain threshold of free pages is reached, it will pull pages from the freelist, report them, and mark them as reported. (see mm/page_reporting.c)
During 2., we didn't actually free a "new page", we only temporarily removed it from the list, that's why we have to skip the notification.
What we do here is skip 1., not 2.
Quoted 7 lines
*reads code*
No, I'm still confused. What does this sentence mean?
Would it help to have a
FOP_DEFAULTthat hasFOP_REPORT_NOTIFYset and then aFOP_SKIP_REPORT_NOTIFYdefine that is 0?
Hmm, I'm not entirely sure if that improves the situation. Then, I need 3 defines instead of two, and an "inverse" documentation for FOP_REPORT_NOTIFY.
Quoted 11 lines
mm/page_alloc.c buddy_merge_likely(unsigned long pfn, unsigned long buddy_pfn, · line 965
Quoted 8 lines
mm/page_alloc.c +3
-4-static inline void __free_one_page (struct page *page, -unsigned long pfn, -struct zone *zone,unsigned int order, -int migratetype,bool report) +static inline void __free_one_page (struct page *page,unsigned long pfn, +struct zone *zone,unsigned int order, +int migratetype,fop_t fop_flags)Please don't over-indent like this.
Quoted 8 lines
static inline void __free_one_page(struct page *page, unsigned long pfn,
struct zone *zone, unsigned int order, int migratetype,fop_tfop_flags)reads just as well and then if someone needs to delete the 'static' later, they don't need to fiddle around with subsequent lines getting the whitespace to line up again.
I don't care too much about this specific instance and can fix it up. (this is clearly a matter of personal taste)
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v1 1/5] mm/page_alloc: convert "report" flag of __free_one_page() to a proper flag
Quoted 23 lines · David Hildenbrand
Quoted 11 lines · Matthew Wilcox
mm/page_alloc.c line 81
Quoted 7 lines · David Hildenbrand
Let's prepare for additional flags and avoid long parameter lists of bools. Follow-up patches will also make use of the flags in
__free_pages_ok(), however, I wasn't able to come up with a better name for the type - should be good enough for internal purposes.mm/page_alloc.c +2
-0+/* Free One Page flags: for internal, non-pcp variants of free_pages(). */ +typedef int __bitwise fop_t ;That invites confusion with
f_op. There's no reason to use _t as a suffix here ... why notfree_f?git grep "bitwise" | grep typedef | grep
include/linuxindicates that "_t" it the right thing to do.
I want a name that highlights that is is for the internal variants of
free_page(),free_f/free_tis too generic.
fpi_t(Free Page Internal) ?Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
+/*
+ * Skip free page reporting notification for the (possibly merged) page. (will
+ * *not* mark the page reported, only skip the notification).... Don't you mean "will not skip marking the page as reported, only skip the notification"?
Yeah, I can use that.
Reading again, it doesn't quite fit. Marking pages as reported is handled by mm/page_reporting.c
/*
* Skip free page reporting notification for the (possibly merged) page.
* This does not hinder free page reporting from grabbing the page,
* reporting it and marking it "reported" - it only skips notifying
* the free page reporting infrastructure about a newly freed page. For
* example, used when temporarily pulling a page from the freelist and
* putting it back unmodified.
*/
Is that clearer?
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v1 4/5] mm/page_alloc: place pages to tail in __free_pages_core()
In reply to Michal HockoQuoted 31 lines · Michal Hocko
Quoted 25 lines · David Hildenbrand
__free_pages_core()is used when exposing fresh memory to the buddy during system boot and when onlining memory ingeneric_online_page().
generic_online_page()is used in two cases:1. Direct memory onlining in
online_pages().
2. Deferred memory onlining in memory-ballooning-like mechanisms (HyperV balloon and virtio-mem), when parts of a section are kept fake-offline to be fake-onlined later on.In 1, we already place pages to the tail of the freelist. Pages will be freed to
MIGRATE_ISOLATElists first and moved to the tail of the freelists viaundo_isolate_page_range().In 2, we currently don't implement a proper rule. In case of virtio-mem, where we currently always online
MAX_ORDER- 1 pages, the pages will be placed to the HEAD of the freelist - undesireable. While the hyper-v balloon callsgeneric_online_page()with single pages, usually it will call it on successive single pages in a larger block.The pages are fresh, so place them to the tail of the freelists and avoid the PCP. In
__free_pages_core(), remove the now superflouos call toset_page_refcounted()and add a comment regarding page initialization and the refcount.Quoted 4 lines
Note: In 2. we currently don't shuffle. If ever relevant (page shuffling is usually of limited use in virtualized environments), we might want to shuffle after a sequence of
generic_online_page()calls in the relevant callers.
Quoted 6 lines
It took some time to get through all the freeing paths with subtle differences but this looks reasonable. You are mentioning that this influences a boot time free memory ordering as well but only very briefly. I do not expect this to make a huge difference but who knows. It makes some sense to add pages in the order they show up in the physical address ordering.
I think boot memory is mostly exposed in the physical address ordering. In that case, higher addresses will now be used less likely immediately after this patch. I also don't think it's an issue - if we still detect it's an issue it's fairly easy to change again.
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
In reply to Michal HockoQuoted 11 lines · Michal Hocko
Quoted 10 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().
Quoted 6 lines
Quoted 2 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Is there anything preventing to do this unconditionally? Or in other words is any of the existing callers of
move_freepages_blockbenefiting from adding to the head?
1. mm/page_isolation.c:set_migratetype_isolate()
We move stuff to the MIGRATE_ISOLATE list, we don't care about the order there.
2. steal_suitable_fallback():
I don't think we care too much about the order when already stealing pageblocks ... and the freelist is empty I guess?
3. reserve_highatomic_pageblock()/unreserve_highatomic_pageblock()
Not sure if we really care.
Good question, I tried to be careful of what I touch. Thoughts?
Signature · 3 lines
Thanks, David / dhildenb
Michal Hocko
reviewerRe: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
Quoted 24 lines · David Hildenbrand
Quoted 11 lines · Michal Hocko
Quoted 10 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().Quoted 6 lines
Quoted 2 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Is there anything preventing to do this unconditionally? Or in other words is any of the existing callers of
move_freepages_blockbenefiting from adding to the head?1. mm/page_isolation.c:set_migratetype_isolate()
We move stuff to the
MIGRATE_ISOLATElist, we don't care about the order there.
Quoted 8 lines
2.
steal_suitable_fallback():I don't think we care too much about the order when already stealing pageblocks ... and the freelist is empty I guess?
3. reserve_highatomic_pageblock()/unreserve_highatomic_pageblock()
Not sure if we really care.
Honestly, I have no idea. I can imagine that some atomic high order workloads (e.g. in net) might benefit from cache line hot pages but I am not sure this is really observable. If yes it would likely be better to have this documented than relying on wild guess. If we do not have any evidence then I would vote for simplicity first and go with unconditional add_to_tail which would simply your patch a bit.
Maybe Vlastimil or Mel would have a better picture.
Signature · 2 lines
Michal Hocko SUSE Labs
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
Quoted 30 lines · Michal Hocko
Quoted 29 lines · David Hildenbrand
Quoted 11 lines · Michal Hocko
Quoted 10 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().Quoted 6 lines
Quoted 2 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Is there anything preventing to do this unconditionally? Or in other words is any of the existing callers of
move_freepages_blockbenefiting from adding to the head?1. mm/page_isolation.c:set_migratetype_isolate()
We move stuff to the
MIGRATE_ISOLATElist, we don't care about the order there.2.
steal_suitable_fallback():I don't think we care too much about the order when already stealing pageblocks ... and the freelist is empty I guess?
Quoted 7 lines
Quoted 3 lines
3. reserve_highatomic_pageblock()/unreserve_highatomic_pageblock()
Not sure if we really care.
Honestly, I have no idea. I can imagine that some atomic high order workloads (e.g. in net) might benefit from cache line hot pages but I am not sure this is really observable.
The highatomic reserve is more concerned that about the allocation succeeding than it is about cache hotness.
Signature · 2 lines
Mel Gorman SUSE Labs
Re: [PATCH v1 3/5] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()
Quoted 33 lines · Mel Gorman
Quoted 32 lines · Michal Hocko
Quoted 31 lines · David Hildenbrand
Quoted 11 lines · Michal Hocko
Quoted 10 lines · David Hildenbrand
Page isolation doesn't actually touch the pages, it simply isolates pageblocks and moves all free pages to the
MIGRATE_ISOLATEfreelist.We already place pages to the tail of the freelists when undoing isolation via
__putback_isolated_page(), let's do it in any case (e.g., if order <=pageblock_order) and document the behavior.Add a "
to_tail" parameter tomove_freepages_block()but introduce a a newmove_to_free_list_tail()- similar toadd_to_free_list_tail().Quoted 6 lines
Quoted 2 lines
This change results in all pages getting onlined via
online_pages()to be placed to the tail of the freelist.Is there anything preventing to do this unconditionally? Or in other words is any of the existing callers of
move_freepages_blockbenefiting from adding to the head?1. mm/page_isolation.c:set_migratetype_isolate()
We move stuff to the
MIGRATE_ISOLATElist, we don't care about the order there.2.
steal_suitable_fallback():I don't think we care too much about the order when already stealing pageblocks ... and the freelist is empty I guess?
3. reserve_highatomic_pageblock()/unreserve_highatomic_pageblock()
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Not sure if we really care.
Honestly, I have no idea. I can imagine that some atomic high order workloads (e.g. in net) might benefit from cache line hot pages but I am not sure this is really observable.
The highatomic reserve is more concerned that about the allocation succeeding than it is about cache hotness.
Thanks Mel and Michal. I'll simplify this patch then - and if it turns out to be an actual problem, we can change that one instance, adding a proper comment.
Thanks!
Signature · 3 lines
Thanks, David / dhildenb