Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp734027pxx; Thu, 29 Oct 2020 13:09:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6MV6x69C08C055nw5PnVaTSjefOma5Qf1UYcZSyGaA4WWgZmwx7k9KeG52TD+2dfuQk4B X-Received: by 2002:a17:907:444f:: with SMTP id on23mr5681644ejb.17.1604002152132; Thu, 29 Oct 2020 13:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604002152; cv=none; d=google.com; s=arc-20160816; b=s866M3TrQMdFi7jYWr2nY86Y7WkBaujyYtgkzBxLHI2qsj8Z0u81IBICRQnNJOV2+L WsviqVmmhD6Miso4tLb1VUxdHwoaSoP9fTNkrLLmfIhNvgT4WPWMi8h8dYUPUSVYHws+ 1TxeWfW0FKxpUDnivhA2H6vhOdYDxd9lbzyNtrnr1P+0Iz4P/ExC9N0AGBwz3omBA44+ N9J50dGLo/sNDGEObZm6ChfLGliuzLepVwcmnbjnDfAbgBuRB1rNs3eoYXPHcYccqI7n tjzkgLL+cXYrpRAU4DocC7gcVkPZMNt5IXL5rD0tnDiCIeunBD+sdNjFtIgKEiNOum0k nHTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=aZLLXKp5r2DJC4J80zb/c1UjaTSWfTyQJPTu9tTd62M=; b=zDGCsdc9c692MdR75u17Vfvj5W6fk9jgmTfpgSFjyyoAQ1Bv6GLYyM/1hfqYjym6js kUAjDb0jE1620xvbzYvxTsuyl5igSEwElMD6Yb3Bp5n5j9ZcnrJ5zayd/sYnI1KXVg7/ Cw+yNBgFu+iLCvowraXeFuYCC0ge0twOHM6BnlViuG6O5+nEJ8yTWUiyKC/UnjOHqXCN JDLkoiUehOSI3Jvrsr9sVFAEvDlCCH0RAfnb29CoNpMxsbObzDDqDXbP/lOt0w3FqTRy q2XIiDtdgoJoJC0/nhDnHKOZOIHkIrWANco5cABBvYm2QIpWcboKl0113HquAmwGF3dl AL6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=RZK50DSa; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=rnxHk3yc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x102si2698668ede.455.2020.10.29.13.08.49; Thu, 29 Oct 2020 13:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=RZK50DSa; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=rnxHk3yc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgJ2UEx (ORCPT + 99 others); Thu, 29 Oct 2020 16:04:53 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:38039 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgJ2UEw (ORCPT ); Thu, 29 Oct 2020 16:04:52 -0400 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=3D16384, 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 >=3D. 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, =20 isolate_success: list_add(&page->lru, &cc->migratepages); - cc->nr_migratepages++; - nr_isolated++; + cc->nr_migratepages +=3D thp_nr_pages(page); + nr_isolated +=3D thp_nr_pages(page); =20 /* * 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 =3D=3D COMPACT_CLUSTER_MAX && + if (cc->nr_migratepages >=3D 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; =20 - if (cc->nr_migratepages =3D=3D COMPACT_CLUSTER_MAX) + if (cc->nr_migratepages >=3D COMPACT_CLUSTER_MAX) break; } =20 --=20 2.28.0