The patch titled Subject: mm, page_alloc: fix a division by zero error when boosting watermarks v2 has been added to the -mm tree. Its filename is mm-page_alloc-fix-a-division-by-zero-error-when-boosting-watermarks-v2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-page_alloc-fix-a-division-by-zero-error-when-boosting-watermarks-v2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-page_alloc-fix-a-division-by-zero-error-when-boosting-watermarks-v2.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/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Subject: mm, page_alloc: fix a division by zero error when boosting watermarks v2 Yury Norov reported that an arm64 KVM instance could not boot since after v5.0-rc1 and could addressed by reverting the patches 1c30844d2dfe272d58c ("mm: reclaim small amounts of memory when an external 73444bc4d8f92e46a20 ("mm, page_alloc: do not wake kswapd with zone lock held") The problem is that a division by zero error is possible if boosting occurs very early in boot if the system has very little memory. This patch avoids the division by zero error. Link: http://lkml.kernel.org/r/20190213143012.GT9565@xxxxxxxxxxxxxxxxxxx Fixes: 1c30844d2dfe ("mm: reclaim small amounts of memory when an external fragmentation event occurs") Signed-off-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Reported-by: Yury Norov <yury.norov@xxxxxxxxx> Tested-by: Yury Norov <yury.norov@xxxxxxxxx> Tested-by: Will Deacon <will.deacon@xxxxxxx> Acked-by: Vlastimil Babka <vbabka@xxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/page_alloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/mm/page_alloc.c~mm-page_alloc-fix-a-division-by-zero-error-when-boosting-watermarks-v2 +++ a/mm/page_alloc.c @@ -2170,6 +2170,18 @@ static inline void boost_watermark(struc max_boost = mult_frac(zone->_watermark[WMARK_HIGH], watermark_boost_factor, 10000); + + /* + * high watermark may be uninitialised if fragmentation occurs + * very early in boot so do not boost. We do not fall + * through and boost by pageblock_nr_pages as failing + * allocations that early means that reclaim is not going + * to help and it may even be impossible to reclaim the + * boosted watermark resulting in a hang. + */ + if (!max_boost) + return; + max_boost = max(pageblock_nr_pages, max_boost); zone->watermark_boost = min(zone->watermark_boost + pageblock_nr_pages, _ Patches currently in -mm which might be from mgorman@xxxxxxxxxxxxxxxxxxx are mm-page_alloc-fix-a-division-by-zero-error-when-boosting-watermarks-v2.patch mm-compaction-shrink-compact_control.patch mm-compaction-rearrange-compact_control.patch mm-compaction-remove-last_migrated_pfn-from-compact_control.patch mm-compaction-remove-unnecessary-zone-parameter-in-some-instances.patch mm-compaction-rename-map_pages-to-split_map_pages.patch mm-migrate-immediately-fail-migration-of-a-page-with-no-migration-handler.patch mm-compaction-always-finish-scanning-of-a-full-pageblock.patch mm-compaction-ignore-the-fragmentation-avoidance-boost-for-isolation-and-compaction.patch mm-compaction-use-free-lists-to-quickly-locate-a-migration-source.patch mm-compaction-use-free-lists-to-quickly-locate-a-migration-source-fix.patch mm-compaction-keep-migration-source-private-to-a-single-compaction-instance.patch mm-compaction-use-free-lists-to-quickly-locate-a-migration-target.patch mm-compaction-avoid-rescanning-the-same-pageblock-multiple-times.patch mm-compaction-finish-pageblock-scanning-on-contention.patch mm-compaction-check-early-for-huge-pages-encountered-by-the-migration-scanner.patch mm-compaction-keep-cached-migration-pfns-synced-for-unusable-pageblocks.patch mm-compaction-rework-compact_should_abort-as-compact_check_resched.patch mm-compaction-do-not-consider-a-need-to-reschedule-as-contention.patch mm-compaction-reduce-premature-advancement-of-the-migration-target-scanner.patch mm-compaction-round-robin-the-order-while-searching-the-free-lists-for-a-target.patch mm-compaction-sample-pageblocks-for-free-pages.patch mm-compaction-be-selective-about-what-pageblocks-to-clear-skip-hints.patch mm-compaction-capture-a-page-under-direct-compaction.patch mm-compaction-capture-a-page-under-direct-compaction-fix.patch