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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 4D116C35E04 for ; Tue, 25 Feb 2020 18:44:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 202B02084E for ; Tue, 25 Feb 2020 18:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 202B02084E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AFBF06B0006; Tue, 25 Feb 2020 13:44:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAB066B0007; Tue, 25 Feb 2020 13:44:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C19B6B0008; Tue, 25 Feb 2020 13:44:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 854E36B0006 for ; Tue, 25 Feb 2020 13:44:38 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 41038180AD80F for ; Tue, 25 Feb 2020 18:44:38 +0000 (UTC) X-FDA: 76529525436.01.clam92_286e9f87e6f19 X-HE-Tag: clam92_286e9f87e6f19 X-Filterd-Recvd-Size: 5415 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Feb 2020 18:44:37 +0000 (UTC) Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1j6fC4-0002Wn-BC; Tue, 25 Feb 2020 13:44:32 -0500 Message-ID: Subject: Re: [PATCH 2/2] mm,thp,compaction,cma: allow THP migration for CMA allocations From: Rik van Riel To: Vlastimil Babka , linux-kernel@vger.kernel.org Cc: kernel-team@fb.com, akpm@linux-foundation.org, linux-mm@kvack.org, mhocko@kernel.org, mgorman@techsingularity.net, rientjes@google.com, aarcange@redhat.com Date: Tue, 25 Feb 2020 13:44:31 -0500 In-Reply-To: <05027092-a43e-756f-4fee-78f29a048ca1@suse.cz> References: <3289dc5e6c4c3174999598d8293adf8ed3e93b57.1582321645.git.riel@surriel.com> <05027092-a43e-756f-4fee-78f29a048ca1@suse.cz> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-iO9vIcEIcIrv1iZZfjKe" User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) 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: --=-iO9vIcEIcIrv1iZZfjKe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2020-02-24 at 16:29 +0100, Vlastimil Babka wrote: > On 2/21/20 10:53 PM, Rik van Riel wrote: > > @@ -981,7 +981,9 @@ isolate_migratepages_block(struct > > compact_control *cc, unsigned long low_pfn, > > if (__isolate_lru_page(page, isolate_mode) !=3D 0) > > goto isolate_fail; > > =20 > > - VM_BUG_ON_PAGE(PageCompound(page), page); > > + /* The whole page is taken off the LRU; skip the tail > > pages. */ > > + if (PageCompound(page)) > > + low_pfn +=3D compound_nr(page) - 1; > > =20 > > /* Successfully isolated */ > > del_page_from_lru_list(page, lruvec, page_lru(page)); >=20 > This continues by: > inc_node_page_state(page, NR_ISOLATED_ANON + > page_is_file_cache(page)); >=20 >=20 > I think it now needs to use mod_node_page_state() with > hpage_nr_pages(page) otherwise the counter will underflow after the > migration? You are absolutely right. I have not observed the underflow, but the functions doing the decrementing use hpage_nr_pages, and I need to do that as well on the incrementing side. Change made. > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index a36736812596..38c8ddfcecc8 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -8253,14 +8253,16 @@ struct page *has_unmovable_pages(struct > > zone *zone, struct page *page, > > =20 > > /* > > * Hugepages are not in LRU lists, but they're movable. > > + * THPs are on the LRU, but need to be counted as > > #small pages. > > * We need not scan over tail pages because we don't > > * handle each tail page individually in migration. > > */ > > - if (PageHuge(page)) { > > + if (PageTransHuge(page)) { >=20 > Hmm, PageTransHuge() has VM_BUG_ON() for tail pages, while this code > is > written so that it can encounter a tail page and skip the rest of the > compound page properly. So I would be worried about this. Good point, a CMA allocation could start partway into a compound page.=20 > Also PageTransHuge() is basically just a PageHead() so for each > non-hugetlbfs compound page this will assume it's a THP, while > correctly > it should reach the __PageMovable() || PageLRU(page) tests below. >=20 > So probably this should do something like. >=20 > if (PageHuge(page) || PageTransCompound(page)) { > ... > if (PageHuge(page) && !hpage_migration_supported)) return page. So far so good. > if (!PageLRU(head) && !__PageMovable(head)) return page I don't get this one, though. What about a THP that has not made it onto the LRU list yet for some reason? I don't think anonymous pages are marked __PageMovable, are they? It looks like they only have the PAGE_MAPPING_ANON flag set, not the PAGE_MAPPING_MOVABLE one. What am I missing? > ... >=20 > > struct page *head =3D compound_head(page); > > unsigned int skip_pages; > > =20 > > - if > > (!hugepage_migration_supported(page_hstate(head))) > > + if (PageHuge(page) && > > + !hugepage_migration_supported(page_hstate(h > > ead))) > > return page; > > =20 > > skip_pages =3D compound_nr(head) - (page - head); > >=20 >=20 >=20 --=20 All Rights Reversed. --=-iO9vIcEIcIrv1iZZfjKe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAl5Vaw8ACgkQznnekoTE 3oOMCAf+JXdppj6x3n1YbJueKjvdyjYwy84gbdtOs88pApMBtrjMFwt2cT4LbL08 FBR4LLG/dTPzhR8wlQpnh/gY9q91sbadYQ38T6NO0zcDtqPRnoNE5Jce+b/91Jmk LOBugJ8u3HA7nrnu/laP8FtmPFWjxj6s2XlKZlvHb9AKCUzCJE3tzizEADkE4y+l xDcDYX6Ex/rujhIgFBgcrxvaL7ooVv6YvFVL8FIMN/mW7BEknKPcREt7ooUcc1eT rLMlWk+ClC1Woxnct31SF1JNCG4ynX3m10KgaVH+gKq/r99saHXm59V7PvgoPY1Q PZUGrdRyv8xJWKrKvnq4dhIcuisgag== =yJ9b -----END PGP SIGNATURE----- --=-iO9vIcEIcIrv1iZZfjKe--