Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp119790ybf; Wed, 26 Feb 2020 09:53:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzG842K40drwkuJ+F1hG36KJu7JfYfOg9pSsh33KpKDIQ+XxWvo/FjG1a60MtyoxWURLqad X-Received: by 2002:a9d:798e:: with SMTP id h14mr3991444otm.257.1582739638301; Wed, 26 Feb 2020 09:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582739638; cv=none; d=google.com; s=arc-20160816; b=aoqxpia8Gb/BALTe5tJgCVV9aj3HQqPrE7Wy/A7WSvuaBzbTEGXHvG4Wkj+mnVAqNb cfVI+CbtlyJ7alXw8G1hkZRGgi76iT8UqZy/J780atysUw6ZzANLN/vE+kWGzs5Qg2W5 pWVicL2tSsWZLKQ1lx8Vq1Q4X3JHeRy+2jXXjXB3jpCZSFq1rhvXrGfXddaeY3qRIzb2 kHkYN+BNQv5+VEgcPIhxtplG5ywNOgFkkzexU7ubzKkU/M+dRtqh4dO2S+UOP3yHS8g1 PglYpnOI6nCawOxgWrkTMoysfyNjH14XylFfeNaHk3sjK3cntmEGzZw2dLB8kCAiBXG2 VjEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=2i3TAznF6Mn7kO1Vvs+7cLifpw40vhr2nsyeuqddQ1Q=; b=sOlr6VuitO8AYOUQTgaGtO1EZMC8DRX1S0PklFwKCBQQ50r8LAy9pEmV3sx8FK0gMo 4MmjCGyBvaRqfhbSpTBgV4b+K9X846fSs6pGUnaofAMENs7SPCsLaY2SWCM5gWbWM8NZ XPMNYB/VnW+M4eqGiQt0km/TJEpDqE4eblNqZic6nfPe5ssIM04xQIU9JT2SLW8m0hqU kojCPD0FlTY05sLAMBGL4NGNXYmycWhMUYLHAsn7iFbvWH6xwjFoHZF0DzIxZzyoWukv IJbVpJHtUygPnYDhhUvfqdhYViLbPbwDb42KXPbQE0C5cVPWPzV2uu4jw5r0V0eXHvs4 U5Jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t127si5518oih.45.2020.02.26.09.53.46; Wed, 26 Feb 2020 09:53:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgBZRxV (ORCPT + 99 others); Wed, 26 Feb 2020 12:53:21 -0500 Received: from shelob.surriel.com ([96.67.55.147]:32920 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbgBZRxV (ORCPT ); Wed, 26 Feb 2020 12:53:21 -0500 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 1j70s0-0008P5-Ix; Wed, 26 Feb 2020 12:53:16 -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: Wed, 26 Feb 2020 12:53:16 -0500 In-Reply-To: <81c8d2fa-a8ae-82b8-f359-bba055fbff68@suse.cz> References: <3289dc5e6c4c3174999598d8293adf8ed3e93b57.1582321645.git.riel@surriel.com> <05027092-a43e-756f-4fee-78f29a048ca1@suse.cz> <81c8d2fa-a8ae-82b8-f359-bba055fbff68@suse.cz> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-t9zdfWG5XcRqe4x+Yg9s" User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-t9zdfWG5XcRqe4x+Yg9s Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2020-02-26 at 10:48 +0100, Vlastimil Babka wrote: > On 2/25/20 7:44 PM, Rik van Riel wrote: > > > 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. > >=20 > > So far so good. > >=20 > > > if (!PageLRU(head) && !__PageMovable(head)) return page > >=20 > > I don't get this one, though. What about a THP that has > > not made it onto the LRU list yet for some reason? >=20 > Uh, is it any different from base pages which have to pass the same > check? I > guess the caller could do e.g. lru_add_drain_all() first. You are right, it is not different. As for lru_add_drain_all(), I wonder at what point that should happen? It appears that the order in which things are done does not really provide a good moment: 1) decide to attempt allocating a range of memory 2) scan each page block for unmovable pages 3) if no unmovable pages are found, mark the page block MIGRATE_ISOLATE I wonder if we should do things the opposite way, first marking the page block MIGRATE_ISOLATE (to prevent new allocations), then scanning it, and calling lru_add_drain_all if we encounter a page that looks like it could benefit from that. If we still see unmovable pages after that, it is cheap enough to set the page block back to its previous state. > > 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. > >=20 > > What am I missing? >=20 > My point is that we should not accept compound pages that are neither > a > migratable hugetlbfs page nor a THP, as movable. I have merged your suggestions into my code base. Thank you for pointing out that 4kB pages have the exact same restrictions as THPs, and why. I'll run some tests and will post v2 of the series soon. --=20 All Rights Reversed. --=-t9zdfWG5XcRqe4x+Yg9s Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAl5WsIwACgkQznnekoTE 3oPmYQf+IdLWdhToGGwYGNtVh1aGC98lpNsEf625QKc/kFP9s8eF9D3sc5lfh+a5 h+2sSpxBcMnGrdxfyvJBcbo5GN9UH2KANFxub4CiglZ4ev/OaQ02LQzw8SaDcGcr L2Lb1ZdNak+o9LRcmRlZ6MIkImc4jDDC6EQ0p+xS/zZfurrvKypGi+upQy8TngQs FxuNXPIikQyZk3kFY6HAilHTxYy39x0EzYVy4sp3cbU+sZHiH1ZXh8rQ8ZaXTquK oQV2hEvXHpfgpQTS0qtb4nmXBSF98TAXUv5XCbNl3rhqUSBWPAM1U9YLk7tk6VJk MSm2iBqF82eba7RdYdJGkjnpeDfc4Q== =F0AS -----END PGP SIGNATURE----- --=-t9zdfWG5XcRqe4x+Yg9s--