Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2055705ybd; Sun, 23 Jun 2019 23:26:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPnDa4p+n4faTlvw5203zBMv6EUwFPwnxhPYDF646o0cAKrT4pi5UZuMiKRfz3d/45GuZL X-Received: by 2002:a17:90a:898e:: with SMTP id v14mr22865844pjn.119.1561357606367; Sun, 23 Jun 2019 23:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561357606; cv=none; d=google.com; s=arc-20160816; b=eksYXC9mfhrfwo5fOyfw8BQVsAkA+QVXesG0kAkprW7vVIgWJ6hPaVWNDrn6vYn73G rgoxAsLs+BSQLur7aIwXuZSdfI76k87PALtbPEr4eafgp9C/186FQdkCpi56WyyRwv1/ uNcVq3J7KHJF3WO0vlhIknekXyir7OfRT92M5Q0dgKOuTo1xnHnSfvMXvZLzt2MxDd2M mXp3A0qMcZl5pwLBdOjzZqOSGhZhYI3wCVElWVsVC/AtYGR1SkGO5u/YlUvZA4bZQSEA wis3yxaH8FNOThoTFMheAJQjjdq7lvfkZd/LrmC+MpPK4QoxgQy1Ri8tgYEQVxHAyhjk Q2FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4j6NnH/rtjW7YqPJZlJgQIQOVFVwz7hkEl28tcCpX/c=; b=001+7Am+dr5WMO/b2lZGt/dMDOCnHiTyXEEdTRRgQOPEczfqXfo4S9xBw7iv326q9E Ky0iGYBWTkEHuVkXtYHPgTUsLT5NsnwCiZSj9hEIdLZIEQOIqcv4SOkM1uIvVH0VebFI mcptNse2maF1yj1p/VJvrirjR0ALO5+Jl1iGniMiKPVnkcXDj2alno1NeohkDnG8efTs 4S+5sRh34Uox2zd6DwMLa8sq3n8+F44LO3e/Bz7ywLjyuAT5O1jNgTRiHXVIHrs1csjI lDcCyIRHgX9VXkGFBsgMIKURMVW98da05IEvvre/zwffbfKgLL3uw27a/Bj1sXQnPVNb 0Z6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QaG2tg0Y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e30si10263096pfm.78.2019.06.23.23.26.27; Sun, 23 Jun 2019 23:26:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QaG2tg0Y; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbfFXGKO (ORCPT + 99 others); Mon, 24 Jun 2019 02:10:14 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:40318 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbfFXGKO (ORCPT ); Mon, 24 Jun 2019 02:10:14 -0400 Received: by mail-io1-f67.google.com with SMTP id n5so295098ioc.7 for ; Sun, 23 Jun 2019 23:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4j6NnH/rtjW7YqPJZlJgQIQOVFVwz7hkEl28tcCpX/c=; b=QaG2tg0YYgd5+P5YRlDvLPsQpP7pDaSmqOTCFDcG7/rcTc53ymw2VqKN97slpnV64h Z0qRqTGndfOy26HG/tWXys9SYkoqbC/kD6scoZi8KsC2l3+OsH6QsMKNsERmRMR0PDlM NCls1WOiUY+TnzK1tWtORWC0o/KQlxMxSoR4va5E58FzkSBpUkmE8HWQZ0/Zb3ZcfTSn mSaid68PFqvYlQA3Fnblkgdug64w3pgL4eb3n3Di+vyEQM9/Ab7C/9Jip9LxDovl67NG S5t16MOLFqYUMTdA5h1HYzdKbBrk8BRvQa+OW1Z8gIH+DIPrutdgXyVI2/6HHWDy+kos tJSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4j6NnH/rtjW7YqPJZlJgQIQOVFVwz7hkEl28tcCpX/c=; b=NRfJJeQGvm7Y8JpdsLgW4iDRe8HLFW2K4w0gW3F6oz7EcC/i427Ji9MmyFuC3CqLTP BXXa0R8nLxB3kvDifMq/4llxkaAfSfkgxlMRYgK2wgoDWkJriDm4DPWw1QwdStMnX1Hn jBGgJXTefepo09FLt5dPuuA6UDIGWr7s/lj3kVjJcOUd/KC00UFX/P2Fe2egy0r6PmGA BbOEtb5ZJ3huX4yf69tC8dXeM/3VH3L12BezDCQfSkrEaQftfy147ovF1DCcm+qnTfOL yu6Lf6Qqa3UJW3pbqVLru5tlrSmRt4KOtDWSygeAw07MY9r+W2FHHadxnMhoxNRVw8vT aboA== X-Gm-Message-State: APjAAAXhJFxanyPSjKommSIpFXhGx17Rq468FtHPan4Juj+ms88uUZjF sJA9JFvUNmclb5jEuT4xESxtQa3b1+WOdVCP1A== X-Received: by 2002:a02:a384:: with SMTP id y4mr124829515jak.77.1561356613275; Sun, 23 Jun 2019 23:10:13 -0700 (PDT) MIME-Version: 1.0 References: <1561350068-8966-1-git-send-email-kernelfans@gmail.com> <216a335d-f7c6-26ad-2ac1-427c8a73ca2f@arm.com> In-Reply-To: <216a335d-f7c6-26ad-2ac1-427c8a73ca2f@arm.com> From: Pingfan Liu Date: Mon, 24 Jun 2019 14:10:02 +0800 Message-ID: Subject: Re: [PATCH] mm/hugetlb: allow gigantic page allocation to migrate away smaller huge page To: Anshuman Khandual Cc: linux-mm@kvack.org, Mike Kravetz , Oscar Salvador , David Hildenbrand , Andrew Morton , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 1:16 PM Anshuman Khandual wrote: > > > > 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 PUD hugetlb has already driven out PMD thp in current. This patch just want to make PUD hugetlb survives PMD hugetlb. > guarantee that after migration of multiple PMD sized THP/HugeTLB pages on the > given range, the allocation request for PUD will succeed ? The migration is complicated, but as my understanding, if there is no gup pin in the range and there is enough memory including swap, then it will success. > > > > > 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. Sorry, but I think this logic is only for hugetlb. The caller alloc_gigantic_page() is only used inside mm/hugetlb.c, not by huge_memory.c. Thanks, Pingfan