Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2025842ybd; Sun, 23 Jun 2019 22:44:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgcmIgKoke2xsR0YvF0znpyqwMlcPDl6qYmMi9PTvf7/9GRrXSFyZ4mCHL4FKxi9TmlZku X-Received: by 2002:a63:4553:: with SMTP id u19mr30925927pgk.420.1561355078585; Sun, 23 Jun 2019 22:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355078; cv=none; d=google.com; s=arc-20160816; b=W4OzJ1qftMbSl2x4Xqup1GMw+F9qdHuQluhvFwkTY72Q1JS9kSuLZCfCHkMZXf0a51 MPFybYn9A+2jtK4TUuXQvhX7Z9KtJgbFSadZxtnV+u7sCdyGvJ9WEWxnde0S+AZx4IPY tZuVkF+rRtbl1IIt5qMGljRJZJYQtAsaXnjecmcymp8MatDY1dmOZjKiHv7QocvDWPK3 2gUvbMghBNldkdgE+ZU+InXRHypHMEzAhO+lUJE6MiAvvhffPN0Xk/2Tg2osMlfy3uUi RkZd7pwP3ce8iIGmccvGJyoGjkNfWMT2uWNoh1M55jY5GNkSTumsK5oBULEjxfBWJAXA LMnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ZRFgzicg77+rcj3QkgTNCzOOesTvIaxUshyWhE6ak/s=; b=fRaavoybJiGhOJAzBmzc+OF6wpM9hdi5j8XF7iPzNRJTQ5bJ/e8aLqq41ielgQs8Ey CfknUInz43xg24lyOt0OAbPD4qS7ZfPVUad6YnRPXxv+aG1ox0nqlg/zaUSSDtGP3u3S ++vxoy9OZ7c1lTz9ImsLQEkmn4fk8dHUT4TChZwGoaVJkl3WOUGFj35qo85YOtyGT78U mGI/djCiI46ithAc+Pr0PbWzHUa6loZbMp6JVn4layx0pNv0nzhM0F1kbtSdljvPF0tp HrbtE6MOE7xdWeaPJZzi//BKXM+CLkLr811zS7xfm2uDvxmZUX9RWchE547KxiQ0pMp1 3Pxg== 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 s21si10326764pfe.204.2019.06.23.22.44.22; Sun, 23 Jun 2019 22:44:38 -0700 (PDT) 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 S1727912AbfFXFQP (ORCPT + 99 others); Mon, 24 Jun 2019 01:16:15 -0400 Received: from foss.arm.com ([217.140.110.172]:41224 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbfFXFQP (ORCPT ); Mon, 24 Jun 2019 01:16:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 95739344; Sun, 23 Jun 2019 22:16:14 -0700 (PDT) Received: from [10.162.41.123] (p8cg001049571a15.blr.arm.com [10.162.41.123]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E82183F718; Sun, 23 Jun 2019 22:18:00 -0700 (PDT) Subject: Re: [PATCH] mm/hugetlb: allow gigantic page allocation to migrate away smaller huge page To: Pingfan Liu , linux-mm@kvack.org Cc: Mike Kravetz , Oscar Salvador , David Hildenbrand , Andrew Morton , linux-kernel@vger.kernel.org References: <1561350068-8966-1-git-send-email-kernelfans@gmail.com> From: Anshuman Khandual Message-ID: <216a335d-f7c6-26ad-2ac1-427c8a73ca2f@arm.com> Date: Mon, 24 Jun 2019 10:46:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1561350068-8966-1-git-send-email-kernelfans@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/24/2019 09:51 AM, Pingfan Liu wrote: > The current pfn_range_valid_gigantic() rejects the pud huge page allocation > if there is a pmd huge page inside the candidate range. > > But pud huge resource is more rare, which should align on 1GB on x86. It is > worth to allow migrating away pmd huge page to make room for a pud huge > page. > > The same logic is applied to pgd and pud huge pages. The huge page in the range can either be a THP or HugeTLB and migrating them has different costs and chances of success. THP migration will involve splitting if THP migration is not enabled and all related TLB related costs. Are you sure that a PUD HugeTLB allocation really should go through these ? Is there any guarantee that after migration of multiple PMD sized THP/HugeTLB pages on the given range, the allocation request for PUD will succeed ? > > Signed-off-by: Pingfan Liu > Cc: Mike Kravetz > Cc: Oscar Salvador > Cc: David Hildenbrand > Cc: Andrew Morton > Cc: linux-kernel@vger.kernel.org > --- > mm/hugetlb.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index ac843d3..02d1978 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1081,7 +1081,11 @@ static bool pfn_range_valid_gigantic(struct zone *z, > unsigned long start_pfn, unsigned long nr_pages) > { > unsigned long i, end_pfn = start_pfn + nr_pages; > - struct page *page; > + struct page *page = pfn_to_page(start_pfn); > + > + if (PageHuge(page)) > + if (compound_order(compound_head(page)) >= nr_pages) > + return false; > > for (i = start_pfn; i < end_pfn; i++) { > if (!pfn_valid(i)) > @@ -1098,8 +1102,6 @@ static bool pfn_range_valid_gigantic(struct zone *z, > if (page_count(page) > 0) > return false; > > - if (PageHuge(page)) > - return false; > } > > return true; > So except in the case where there is a bigger huge page in the range this will attempt migrating everything on the way. As mentioned before if it all this is a good idea, it needs to differentiate between HugeTLB and THP and also take into account costs of migrations and chance of subsequence allocation attempt into account.