Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1510502pxx; Fri, 30 Oct 2020 11:41:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk1y7A9bFwYfLNMUyvHNQMv56S9Hknjy57KDvQHOUgjyAjr1s6NtmdLB9KqQzLo0hSbH94 X-Received: by 2002:a17:906:c30a:: with SMTP id s10mr3813438ejz.369.1604083260467; Fri, 30 Oct 2020 11:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604083260; cv=none; d=google.com; s=arc-20160816; b=ihWbOffoC0rhJngXqXmYQcCOG/6Ux+vk/CW/ebyMJ117csNJeyFOUXuDm+omcnxfAd JW8dqq4LfUm6EPm34XDGdjCYP+dGDaWkxNNfBi2sTeABkSRDhMXsvfGOGZUBDHJB/uie 00ownl7tTJw0edwGdjm1rTMjg9/fX94ucluVIcIdozQrOMYWKtJov6YKoKM2tcex0Qao q6tPUIKGjACjLSi+PRDDK8Ir8RaIJBdLf1K0i+fD/9IW+6BS0SF9EQDAZ3W81Ak3k1Ko U33LbYagPYOpzf/kzGH4SoNqynlpoBGf40qUIszDi2vB1N3q4ItgpFgme5tA6hQ2EGnA LdrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=g/YnYMgCoBBEyZnTNWw3FE62Lv8lPjtnXr9pHWmcOt8=; b=ERfAvUuP8H8CQOosXA5JhzphbO7Tdz8Daxw954PTwa3owcFvpGfqGcvgsfc81WX2R7 0oNhSJi+Qg/g/l3k8gHxcqf57abL/vtZM32ax5q86tZW5wrGX5KVRi17yyi8/pCkSZS0 YP1jiCEiBUw7DtNNUugnlmAg+nfaWPBWF39H0MQQKy6esYnBDYJajjfYUqYx2bKQ3+X9 4r9QOmNGzoViL56G2WkzqrnT3n1EHCp3HheWZOOjxW9Ck9qmRkD0rK70vKTR0Ogcbi4I MloR+jRII20654vv4KiLSxuP3Nqb+s6jVembjUhnn7jKWcBQoDJ6KiiTKWQ4qjWPCNkf uYxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=AU1cxw4Y; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si4961020eda.489.2020.10.30.11.40.37; Fri, 30 Oct 2020 11:41:00 -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=@nvidia.com header.s=n1 header.b=AU1cxw4Y; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbgJ3SjG (ORCPT + 99 others); Fri, 30 Oct 2020 14:39:06 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:6674 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726095AbgJ3SjF (ORCPT ); Fri, 30 Oct 2020 14:39:05 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 30 Oct 2020 11:39:10 -0700 Received: from [10.2.173.19] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 30 Oct 2020 18:39:04 +0000 From: Zi Yan To: Yang Shi CC: Michal Hocko , Andrew Morton , Linux MM , Rik van Riel , Linux Kernel Mailing List , Vlastimil Babka Subject: Re: [PATCH] mm/compaction: count pages and stop correctly during page isolation. Date: Fri, 30 Oct 2020 14:39:02 -0400 X-Mailer: MailMate (1.13.2r5673) Message-ID: In-Reply-To: References: <20201029200435.3386066-1-zi.yan@sent.com> <20201030094308.GG1478@dhcp22.suse.cz> <6CAAB1FC-2B41-490B-A67A-93063629C19B@nvidia.com> <20201030133625.GJ1478@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=_MailMate_39F95D72-F34A-46D4-92E5-7EF47E8EF89B_="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1604083150; bh=g/YnYMgCoBBEyZnTNWw3FE62Lv8lPjtnXr9pHWmcOt8=; h=From:To:CC:Subject:Date:X-Mailer:Message-ID:In-Reply-To: References:MIME-Version:Content-Type:X-Originating-IP: X-ClientProxiedBy; b=AU1cxw4Y9sh11ASB0Flr+WLBaVYkFal+dk40q22hxV02mEk/rKtOmU67c11xOWeKq fEwAHGrA9l5S4dm5CLaJILZvMTMGX464I5xOEtkc+Z3yHcciMsINP055WC3iMJRaCR ffhktTj536x8QUu2DltLc2gCEPxE+vzs75C+lZulZyxmyFTnb5tkaq8VB9+1uWLALp wW5lDcr3yx6DZ0rYxQfmpOl+lO621DJzNhIEHi7QRgvJU89vEwVXkOfR2PHRq5HO5p 2b5whobOnDZ+g6MAZG2bPYt4MsX6HjvOLg2v8EnQhTY31vkRAdNha+lODhE0ek2F3r egIQYYb4uAT+Q== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=_MailMate_39F95D72-F34A-46D4-92E5-7EF47E8EF89B_= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 30 Oct 2020, at 14:33, Yang Shi wrote: > On Fri, Oct 30, 2020 at 6:36 AM Michal Hocko wrote: >> >> On Fri 30-10-20 08:20:50, Zi Yan wrote: >>> On 30 Oct 2020, at 5:43, Michal Hocko wrote: >>> >>>> [Cc Vlastimil] >>>> >>>> On Thu 29-10-20 16:04:35, Zi Yan wrote: >>>>> From: Zi Yan >>>>> >>>>> In isolate_migratepages_block, when cc->alloc_contig is true, we ar= e >>>>> able to isolate compound pages, nr_migratepages and nr_isolated did= not >>>>> count compound pages correctly, causing us to isolate more pages th= an we >>>>> thought. Use thp_nr_pages to count pages. Otherwise, we might be tr= apped >>>>> in too_many_isolated while loop, since the actual isolated pages ca= n 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 coul= d >>>>> never be equal to COMPACT_CLUSTER_MAX if compound pages are isolate= d, >>>>> thus page isolation could not stop as we intended. Change the isola= tion >>>>> 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_con= trol *cc, unsigned long low_pfn, >>>>> >>>>> 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); >>>> >>>> Does thp_nr_pages work for __PageMovable pages? >>> >>> Yes. It is the same as compound_nr() but compiled >>> to 1 when THP is not enabled. >> >> I am sorry but I do not follow. First of all the implementation of the= >> two is different and also I was asking about __PageMovable which shoul= d >> never be THP IIRC. Can they be compound though? > > I have the same question, can they be compound? If they can be > compound, PageTransHuge() can't tell from THP and compound movable > page, right? Right. I have updated the patch and use compound_nr instead. =E2=80=94 Best Regards, Yan Zi --=_MailMate_39F95D72-F34A-46D4-92E5-7EF47E8EF89B_= Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEh7yFAW3gwjwQ4C9anbJR82th+ooFAl+cXcYPHHppeUBudmlk aWEuY29tAAoJEJ2yUfNrYfqKRAkP/jSOdKd1rzNd+SwOVTQYeIoDxSX8treiEYM+ kVwomAWlSi1mutl1ew+hxSZIRQ0a5V9r+IJZDob7W23Z2mEVGCQLCOW6GKcZv7CX RECU2+CdB6uY3r2p1YWx32Cb9mlpyJc4TJhlPgNgg9OHr7r5Ma1KkHCDNwU8o7Zg M/l22g0VHd/TnhrYIrfd+YNcMGO4s/j6R5KOZ4S6Cig/FLgb7RFrixaJ2bSSVPTh E4sdvPdqVSf6znSEY8eMhOf1jFgAtOwdfIppc8OSIthPrdvKBdik7/tlo/iwGMj2 0DM3wrP0eFwm9G2fFLlJCXqUyLzygaz3Ac/NtrvvivtI/E5irZAgZAMCdO6bbZXq 5fbXk5oZ9LHeTqwfI7s5E13wv8VGPyXcTgliD6aa9U9BKzq4YjbSwMZ9BT+vo3IX s7N2Xs5bzuvL6PB5LSFSSq63FzY1YTkrAZ+45yQ8xhVnN4Q1/7BoNzQaTk03zVRq SpBzQz3oPI63fPWf/FgFCiOE769Mpd91sgKprfbgPGFavUlhm0T8S9II2HdP5qaB 8A1JECql9v72F1LrGbo+UoCq8kN1uooSnxNEU5jIvu0Y2F0/39UmNqy0ixCJJ5QC hIyLz/z+YBLZVfCko+QZaLILBJfXMz7CmiWiqjLfG+RD1CA7bx6GPd4/+2ysGJRy vVPE4e3h =v/oH -----END PGP SIGNATURE----- --=_MailMate_39F95D72-F34A-46D4-92E5-7EF47E8EF89B_=--