From patchwork Wed Feb 13 14:30:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10810029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6447922 for ; Wed, 13 Feb 2019 14:30:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FFA42D42A for ; Wed, 13 Feb 2019 14:30:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 846BB2D433; Wed, 13 Feb 2019 14:30:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 28C202D441 for ; Wed, 13 Feb 2019 14:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2xcaDn8wEMxYnSKGYgJxRZ4aXTtBk/nbZz4+I3x64kk=; b=OnDzWJxIy7kKrY Hbzt3y2BLmk9vOVIrEgEKOGDNdXpmhpTmhVkMZsAthfFB3nBPdVbQJnztS0DPx4uyV38lUW/i2var 689dNzeZDX0s42q9NeAZQJfSg1jb7TfSegAWgMEbIATPuEa91FeSn03TPgzW2c4Y1F+b7gN4L+BVm mg05PC+lEPZ8Bn2koN78TVWx8wZbGd11kq01dZT2Vx/QxDgL6OgOVnXuKwHIg0j/beim0ZZBVZ78H XX7fgKIfvOxygHBeu3lcR7JqCZwnjQ54EOQYCgJjByWoVn5kCmuCN4gBor6LAcOl6rQjoI2kolqbO 7Wb2EMgF1LZl5cC1bzSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtvYL-00059a-TI; Wed, 13 Feb 2019 14:30:21 +0000 Received: from outbound-smtp04.blacknight.com ([81.17.249.35]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtvYI-00058e-0u for linux-arm-kernel@lists.infradead.org; Wed, 13 Feb 2019 14:30:19 +0000 Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp04.blacknight.com (Postfix) with ESMTPS id 9211998A96 for ; Wed, 13 Feb 2019 14:30:14 +0000 (UTC) Received: (qmail 2776 invoked from network); 13 Feb 2019 14:30:14 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[37.228.225.79]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 13 Feb 2019 14:30:14 -0000 Date: Wed, 13 Feb 2019 14:30:13 +0000 From: Mel Gorman To: Andrew Morton Subject: [PATCH] mm, page_alloc: Fix a division by zero error when boosting watermarks v2 Message-ID: <20190213143012.GT9565@techsingularity.net> References: <20190213131923.GQ9565@techsingularity.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190213131923.GQ9565@techsingularity.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190213_063018_199249_46123896 X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , Yury Norov , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Michal Hocko , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, David Rientjes , Vlastimil Babka Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Fixes: 1c30844d2dfe ("mm: reclaim small amounts of memory when an external fragmentation event occurs") Reported-and-tested-by: Yury Norov Tested-by: Will Deacon Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/page_alloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d295c9bc01a8..bb1c7d843ebf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2170,6 +2170,18 @@ static inline void boost_watermark(struct zone *zone) 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,