From patchwork Thu Oct 29 20:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11867485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB12F92C for ; Thu, 29 Oct 2020 20:04:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7DEFE2083B for ; Thu, 29 Oct 2020 20:04:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="RZK50DSa"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rnxHk3yc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DEFE2083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 40B236B005C; Thu, 29 Oct 2020 16:04:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3BB156B0062; Thu, 29 Oct 2020 16:04:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AA7C6B0068; Thu, 29 Oct 2020 16:04:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id F1FA46B005C for ; Thu, 29 Oct 2020 16:04:52 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9AAA6180AD806 for ; Thu, 29 Oct 2020 20:04:52 +0000 (UTC) X-FDA: 77426041224.13.route77_31026b527290 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 75A5618140B60 for ; Thu, 29 Oct 2020 20:04:52 +0000 (UTC) X-Spam-Summary: 1,0,0,33dcaaa1a783953f,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:355:379:421:541:800:960:968:973:988:989:1260:1261:1311:1314:1345:1437:1513:1515:1521:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:4321:5007:6261:6653:7576:10004:11026:11473:11658:11914:12043:12294:12296:12438:12555:12679:12895:12986:14096:14181:14394:14721:21080:21627:30054:30064:30070,0,RBL:66.111.4.29:@sent.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04ygtro8dhkaro51fms49xpgczmf3ypmp1xokgk6hat6uudz8o115ui9w3auzyo.37w36mmrtk9mxpjcsa9zfbrih7eykf633ipan7uykqduronyh7br7c6yyqhee3n.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:167,LUA_SUMMARY:none X-HE-Tag: route77_31026b527290 X-Filterd-Recvd-Size: 5598 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 20:04:51 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6C7485C00E7; Thu, 29 Oct 2020 16:04:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 29 Oct 2020 16:04:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; s=fm1; bh=aZLLXKp5r2DJC4J80zb/c1UjaT SWfTyQJPTu9tTd62M=; b=RZK50DSa4ZBCTbJmBMt2I/nt0teMNqY/9Uka0FOC5f c4RkwYCfi98RLzpLM6B0MvshvTEpPHFiMIvENHVtyx0QlnZvny+nB7gjLZtUhJcP OO+/brab6dUNk8zKJkmZf+mEql+xnEyj1X1izbW5dJu0JUQTobfg93AHSSWBjhhP qmS5wdf/hrMWqUsGqYLe++g0W+05xV7kMsueWY1bT0QpuDCsjt1CC81e9nMohfQF kuPsIcKQjS6S4YCIi4LKJj+rPpLiEUn0a0JQy5zN0FcO1Vxt1TvLdR9jpOnlR3Yo iBemLKMJWtB2Aj8HAHW44yKZQ7e7k8m1t4pbXm6dF9ew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:reply-to:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=aZLLXK p5r2DJC4J80zb/c1UjaTSWfTyQJPTu9tTd62M=; b=rnxHk3yceoX3jSgD+S4wjJ 6lSG/T/sGNbg6cmQBxgGwtrJbnEOH1WHp13HQ+W9Kn1/Meu/kyWXA/aJPw5w8sgz y1cJhXUcErxpTJA+uxEdVJ4E676LPrYhLgfYPG3ksZrD1AiV7X6l02XYrdwtsgzc 8qeTP7NAphW11RAp9yX+Xt5eRwp9lEwRQub0cUbVePGs+rygHxNDnu1YVyq0M1X9 B/tiz24pTRLbsLPqyU1Zwud92zlBTMW7jtclVUaHPbUq7KSFfYRjg4TEtrp0yYDI CJRI4GYE2LU2D+ujrt53GCp/KdTyQmokKVQ+Xf8kWji2sN18uiEXn7naHbp8Qf4g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrleefgddufeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfforhgggfestdhqredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepleetvddtvd dttdetffdvkeehffdtjefhkedtheffjeehvdejueektedukedufeffnecukfhppeduvddr geeirddutdeirdduieegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id 1BA97328005A; Thu, 29 Oct 2020 16:04:50 -0400 (EDT) From: Zi Yan To: Andrew Morton , linux-mm@kvack.org Cc: Rik van Riel , linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH] mm/compaction: count pages and stop correctly during page isolation. Date: Thu, 29 Oct 2020 16:04:35 -0400 Message-Id: <20201029200435.3386066-1-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zi Yan In isolate_migratepages_block, when cc->alloc_contig is true, we are able to isolate compound pages, nr_migratepages and nr_isolated did not count compound pages correctly, causing us to isolate more pages than we thought. Use thp_nr_pages to count pages. Otherwise, we might be trapped in too_many_isolated while loop, since the actual isolated pages can go up to COMPACT_CLUSTER_MAX*512=16384, where COMPACT_CLUSTER_MAX is 32, since we stop isolation after cc->nr_migratepages reaches to COMPACT_CLUSTER_MAX. In addition, after we fix the issue above, cc->nr_migratepages could never be equal to COMPACT_CLUSTER_MAX if compound pages are isolated, thus page isolation could not stop as we intended. Change the isolation stop condition to >=. Signed-off-by: Zi Yan --- mm/compaction.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index ee1f8439369e..0683a4999581 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1012,8 +1012,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, isolate_success: list_add(&page->lru, &cc->migratepages); - cc->nr_migratepages++; - nr_isolated++; + cc->nr_migratepages += thp_nr_pages(page); + nr_isolated += thp_nr_pages(page); /* * Avoid isolating too much unless this block is being @@ -1021,7 +1021,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, * or a lock is contended. For contention, isolate quickly to * potentially remove one source of contention. */ - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX && + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX && !cc->rescan && !cc->contended) { ++low_pfn; break; @@ -1132,7 +1132,7 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn, if (!pfn) break; - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX) + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX) break; }