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 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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 5F817C282C2 for ; Wed, 13 Feb 2019 13:21:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30082222B1 for ; Wed, 13 Feb 2019 13:21:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OKuG3atk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30082222B1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=//XV1eeO65nwqNt9o82eKw7Pu76fcdSTlEOX1378OAM=; b=OKuG3atkPt5pGt lOhXTQw4T+smae944RrJ01tX/c1SNhspau3kw6fwx/AH+r7xyToP4G4y5XoP51kso9vXw+TIs7zQb AuZEZDRpOIiJXg6rte3Fl5IZgxlXlQ+zclUlkcFw/Ed1BHfA2JpJm7c0kc3tvgSPSWi7yv4HWROJq NUHen1AzB3DZ8CHVt3Om17r7erNnbdk6qqX0Oi8IuewjuIbTPOIfPvjvtGSDpiPOSjiKel6MX1p3K 5FTMcyTysjrSWiw7a/4HuEmZW6YyPUWpT/NohNu91p+HIROqE8g2IS76g5qcyqnJ9mYeOMhVG61oy hTvR/MhKVMWC2ckkBqQg==; 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 1gtuTK-0000mU-FR; Wed, 13 Feb 2019 13:21:06 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtuTH-0000lX-7h for linux-arm-kernel@lists.infradead.org; Wed, 13 Feb 2019 13:21:04 +0000 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 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-Disposition: inline In-Reply-To: <20190213131923.GQ9565@techsingularity.net> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190213_052103_280230_5775C458 X-CRM114-Status: GOOD ( 19.49 ) 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 , linux-kernel@vger.kernel.org, Michal Hocko , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, David Rientjes , Andrew Morton , Vlastimil Babka Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel