The patch titled Subject: vmscan: only defer compaction for failed order and higher has been added to the -mm tree. Its filename is vmscan-only-defer-compaction-for-failed-order-and-higher.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Rik van Riel <riel@xxxxxxxxxx> Subject: vmscan: only defer compaction for failed order and higher Currently a failed order-9 (transparent hugepage) compaction can lead to memory compaction being temporarily disabled for a memory zone. Even if we only need compaction for an order 2 allocation, eg. for jumbo frames networking. The fix is relatively straightforward: keep track of the highest order at which compaction is succeeding, and only defer compaction for orders at which compaction is failing. Signed-off-by: Rik van Riel <riel@xxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Minchan Kim <minchan.kim@xxxxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Cc: Hillf Danton <dhillf@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/compaction.h | 14 ++++++++++---- include/linux/mmzone.h | 1 + mm/compaction.c | 12 +++++++++++- mm/page_alloc.c | 6 ++++-- mm/vmscan.c | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff -puN include/linux/compaction.h~vmscan-only-defer-compaction-for-failed-order-and-higher include/linux/compaction.h --- a/include/linux/compaction.h~vmscan-only-defer-compaction-for-failed-order-and-higher +++ a/include/linux/compaction.h @@ -34,20 +34,26 @@ extern unsigned long compaction_suitable * allocation success. 1 << compact_defer_limit compactions are skipped up * to a limit of 1 << COMPACT_MAX_DEFER_SHIFT */ -static inline void defer_compaction(struct zone *zone) +static inline void defer_compaction(struct zone *zone, int order) { zone->compact_considered = 0; zone->compact_defer_shift++; + if (order < zone->compact_order_failed) + zone->compact_order_failed = order; + if (zone->compact_defer_shift > COMPACT_MAX_DEFER_SHIFT) zone->compact_defer_shift = COMPACT_MAX_DEFER_SHIFT; } /* Returns true if compaction should be skipped this time */ -static inline bool compaction_deferred(struct zone *zone) +static inline bool compaction_deferred(struct zone *zone, int order) { unsigned long defer_limit = 1UL << zone->compact_defer_shift; + if (order < zone->compact_order_failed) + return false; + /* Avoid possible overflow */ if (++zone->compact_considered > defer_limit) zone->compact_considered = defer_limit; @@ -73,11 +79,11 @@ static inline unsigned long compaction_s return COMPACT_SKIPPED; } -static inline void defer_compaction(struct zone *zone) +static inline void defer_compaction(struct zone *zone, int order) { } -static inline bool compaction_deferred(struct zone *zone) +static inline bool compaction_deferred(struct zone *zone, int order) { return 1; } diff -puN include/linux/mmzone.h~vmscan-only-defer-compaction-for-failed-order-and-higher include/linux/mmzone.h --- a/include/linux/mmzone.h~vmscan-only-defer-compaction-for-failed-order-and-higher +++ a/include/linux/mmzone.h @@ -365,6 +365,7 @@ struct zone { */ unsigned int compact_considered; unsigned int compact_defer_shift; + int compact_order_failed; #endif ZONE_PADDING(_pad1_) diff -puN mm/compaction.c~vmscan-only-defer-compaction-for-failed-order-and-higher mm/compaction.c --- a/mm/compaction.c~vmscan-only-defer-compaction-for-failed-order-and-higher +++ a/mm/compaction.c @@ -673,9 +673,19 @@ static int __compact_pgdat(pg_data_t *pg INIT_LIST_HEAD(&cc->freepages); INIT_LIST_HEAD(&cc->migratepages); - if (cc->order < 0 || !compaction_deferred(zone)) + if (cc->order < 0 || !compaction_deferred(zone, cc->order)) compact_zone(zone, cc); + if (cc->order > 0) { + int ok = zone_watermark_ok(zone, cc->order, + low_wmark_pages(zone), 0, 0); + if (ok && cc->order > zone->compact_order_failed) + zone->compact_order_failed = cc->order + 1; + /* Currently async compaction is never deferred. */ + else if (!ok && cc->sync) + defer_compaction(zone, cc->order); + } + VM_BUG_ON(!list_empty(&cc->freepages)); VM_BUG_ON(!list_empty(&cc->migratepages)); } diff -puN mm/page_alloc.c~vmscan-only-defer-compaction-for-failed-order-and-higher mm/page_alloc.c --- a/mm/page_alloc.c~vmscan-only-defer-compaction-for-failed-order-and-higher +++ a/mm/page_alloc.c @@ -1990,7 +1990,7 @@ __alloc_pages_direct_compact(gfp_t gfp_m if (!order) return NULL; - if (compaction_deferred(preferred_zone)) { + if (compaction_deferred(preferred_zone, order)) { *deferred_compaction = true; return NULL; } @@ -2012,6 +2012,8 @@ __alloc_pages_direct_compact(gfp_t gfp_m if (page) { preferred_zone->compact_considered = 0; preferred_zone->compact_defer_shift = 0; + if (order >= preferred_zone->compact_order_failed) + preferred_zone->compact_order_failed = order + 1; count_vm_event(COMPACTSUCCESS); return page; } @@ -2028,7 +2030,7 @@ __alloc_pages_direct_compact(gfp_t gfp_m * defer if the failure was a sync compaction failure. */ if (sync_migration) - defer_compaction(preferred_zone); + defer_compaction(preferred_zone, order); cond_resched(); } diff -puN mm/vmscan.c~vmscan-only-defer-compaction-for-failed-order-and-higher mm/vmscan.c --- a/mm/vmscan.c~vmscan-only-defer-compaction-for-failed-order-and-higher +++ a/mm/vmscan.c @@ -2198,7 +2198,7 @@ static inline bool compaction_ready(stru * If compaction is deferred, reclaim up to a point where * compaction will have a chance of success when re-enabled */ - if (compaction_deferred(zone)) + if (compaction_deferred(zone, sc->order)) return watermark_ok; /* If compaction is not ready to start, keep reclaiming */ _ Subject: Subject: vmscan: only defer compaction for failed order and higher Patches currently in -mm which might be from riel@xxxxxxxxxx are origin.patch linux-next.patch mm-vmscanc-cleanup-with-s-reclaim_mode-isolate_mode.patch mm-vmscan-fix-misused-nr_reclaimed-in-shrink_mem_cgroup_zone.patch make-swapin-readahead-skip-over-holes.patch make-swapin-readahead-skip-over-holes-fix.patch vmscan-reclaim-at-order-0-when-compaction-is-enabled.patch vmscan-kswapd-carefully-call-compaction.patch vmscan-kswapd-carefully-call-compaction-fix.patch vmscan-only-defer-compaction-for-failed-order-and-higher.patch mm-fix-page-faults-detection-in-swap-token-logic.patch mm-add-extra-free-kbytes-tunable.patch mm-add-extra-free-kbytes-tunable-update.patch mm-add-extra-free-kbytes-tunable-update-checkpatch-fixes.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html