From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93632C282C2 for ; Wed, 13 Feb 2019 13:21:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BFFF222B1 for ; Wed, 13 Feb 2019 13:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390591AbfBMNVD (ORCPT ); Wed, 13 Feb 2019 08:21:03 -0500 Received: from foss.arm.com ([217.140.101.70]:53580 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388551AbfBMNVD (ORCPT ); Wed, 13 Feb 2019 08:21:03 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 134E480D; Wed, 13 Feb 2019 05:21:03 -0800 (PST) Received: from brain-police (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 59A333F557; Wed, 13 Feb 2019 05:21:00 -0800 (PST) Date: Wed, 13 Feb 2019 13:20:57 +0000 From: Will Deacon To: Mel Gorman Cc: Andrew Morton , Yury Norov , Vlastimil Babka , Andrea Arcangeli , David Rientjes , Michal Hocko , Catalin Marinas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH] mm, page_alloc: Fix a division by zero error when boosting watermarks Message-ID: <20190213132056.GE5875@brain-police> References: <20190213131923.GQ9565@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190213131923.GQ9565@techsingularity.net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 13, 2019 at 01:19:23PM +0000, Mel Gorman wrote: > 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 > either very early in boot or if the high watermark is very small. This > patch checks for the conditions and avoids boosting in those cases. > > Fixes: 1c30844d2dfe ("mm: reclaim small amounts of memory when an external fragmentation event occurs") > Reported-and-tested-by: Yury Norov > Signed-off-by: Mel Gorman > --- > mm/page_alloc.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index d295c9bc01a8..ae7e4ba5b9f5 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2170,6 +2170,11 @@ static inline void boost_watermark(struct zone *zone) > > max_boost = mult_frac(zone->_watermark[WMARK_HIGH], > watermark_boost_factor, 10000); > + > + /* high watermark be be uninitialised or very small */ > + if (!max_boost) > + return; > + > max_boost = max(pageblock_nr_pages, max_boost); > > zone->watermark_boost = min(zone->watermark_boost + pageblock_nr_pages, I can confirm that this also allows my KVM guest to boot: Tested-by: Will Deacon Will