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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 AAB46C4CECE for ; Mon, 14 Oct 2019 12:52:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4B8D820673 for ; Mon, 14 Oct 2019 12:52:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B8D820673 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AEBBB8E0005; Mon, 14 Oct 2019 08:52:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9D768E0001; Mon, 14 Oct 2019 08:52:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B22B8E0005; Mon, 14 Oct 2019 08:52:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 74A208E0001 for ; Mon, 14 Oct 2019 08:52:47 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 146504850 for ; Mon, 14 Oct 2019 12:52:47 +0000 (UTC) X-FDA: 76042379574.30.badge02_522a4046b1663 X-HE-Tag: badge02_522a4046b1663 X-Filterd-Recvd-Size: 9063 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Oct 2019 12:52:44 +0000 (UTC) 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 42E5A337; Mon, 14 Oct 2019 05:52:43 -0700 (PDT) Received: from [10.162.42.133] (p8cg001049571a15.blr.arm.com [10.162.42.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C99013F68E; Mon, 14 Oct 2019 05:52:34 -0700 (PDT) Subject: Re: + mm-hugetlb-make-alloc_gigantic_page-available-for-general-use.patch added to -mm tree To: Michal Hocko , akpm@linux-foundation.org Cc: ard.biesheuvel@linaro.org, broonie@kernel.org, christophe.leroy@c-s.fr, dan.j.williams@intel.com, dave.hansen@intel.com, davem@davemloft.net, gerald.schaefer@de.ibm.com, gregkh@linuxfoundation.org, heiko.carstens@de.ibm.com, jgg@ziepe.ca, jhogan@kernel.org, keescook@chromium.org, kirill@shutemov.name, linux@armlinux.org.uk, mark.rutland@arm.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, mpe@ellerman.id.au, paul.burton@mips.com, paulus@samba.org, penguin-kernel@i-love.sakura.ne.jp, peterz@infradead.org, ralf@linux-mips.org, rppt@linux.vnet.ibm.com, schowdary@nvidia.com, schwidefsky@de.ibm.com, Steven.Price@arm.com, tglx@linutronix.de, vbabka@suse.cz, vgupta@synopsys.com, willy@infradead.org, yamada.masahiro@socionext.com, linux-mm@kvack.org References: <20191011202932.GZoUOoURm%akpm@linux-foundation.org> <20191014121730.GE317@dhcp22.suse.cz> From: Anshuman Khandual Message-ID: <89f328f0-ca00-a9b0-8df6-808a53bfcdd4@arm.com> Date: Mon, 14 Oct 2019 18:23:00 +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: <20191014121730.GE317@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 10/14/2019 05:47 PM, Michal Hocko wrote: > On Fri 11-10-19 13:29:32, Andrew Morton wrote: >> alloc_gigantic_page() implements an allocation method where it scans over >> various zones looking for a large contiguous memory block which could not >> have been allocated through the buddy allocator. A subsequent patch which >> tests arch page table helpers needs such a method to allocate PUD_SIZE >> sized memory block. In the future such methods might have other use cases >> as well. So alloc_gigantic_page() has been split carving out actual >> memory allocation method and made available via new >> alloc_gigantic_page_order(). > > You are exporting a helper used for hugetlb internally. Is this really Right, because the helper i.e alloc_gigantic_page() is generic enough which scans over various zones to allocate a page order which could not be allocated through the buddy. Only thing which is HugeTLB specific in there, is struct hstate from where the order is derived with huge_page_order(). Otherwise it is very generic. > what is needed? I haven't followed this patchset but don't you simply Originally I had just implemented similar allocator inside the test itself but then figured that alloc_gigantic_page() can be factored out to create a generic enough allocator helper. > need a generic 1GB allocator? If yes then you should be looking at The test needs a PUD_SIZE allocator. > alloc_contig_range. IIUC alloc_contig_range() requires (start pfn, end pfn) for the region to be allocated. But before that all applicable zones need to be scanned to figure out any available and suitable pfn range for alloc_contig_range() to try. In this case pfn_range_valid_gigantic() check seemed reasonable while scanning the zones. If pfn_range_valid_gigantic() is good enough or could be made more generic, then the new factored alloc_gigantic_page_order() could be made a helper in mm/page_alloc.c > > Or did I miss the point you really want hugetlb page? > >> Link: http://lkml.kernel.org/r/1570775142-31425-2-git-send-email-anshuman.khandual@arm.com >> Signed-off-by: Anshuman Khandual >> Cc: Vlastimil Babka >> Cc: Greg Kroah-Hartman >> Cc: Thomas Gleixner >> Cc: Mike Rapoport >> Cc: Mike Kravetz >> Cc: Jason Gunthorpe >> Cc: Dan Williams >> Cc: Peter Zijlstra >> Cc: Michal Hocko >> Cc: Mark Rutland >> Cc: Mark Brown >> Cc: Steven Price >> Cc: Ard Biesheuvel >> Cc: Masahiro Yamada >> Cc: Kees Cook >> Cc: Tetsuo Handa >> Cc: Matthew Wilcox >> Cc: Sri Krishna chowdary >> Cc: Dave Hansen >> Cc: Russell King - ARM Linux >> Cc: Michael Ellerman >> Cc: Paul Mackerras >> Cc: Martin Schwidefsky >> Cc: Heiko Carstens >> Cc: "David S. Miller" >> Cc: Vineet Gupta >> Cc: James Hogan >> Cc: Paul Burton >> Cc: Ralf Baechle >> Cc: Kirill A. Shutemov >> Cc: Gerald Schaefer >> Cc: Christophe Leroy >> Signed-off-by: Andrew Morton >> --- >> >> include/linux/hugetlb.h | 9 +++++++++ >> mm/hugetlb.c | 24 ++++++++++++++++++++++-- >> 2 files changed, 31 insertions(+), 2 deletions(-) >> >> --- a/include/linux/hugetlb.h~mm-hugetlb-make-alloc_gigantic_page-available-for-general-use >> +++ a/include/linux/hugetlb.h >> @@ -299,6 +299,9 @@ static inline bool is_file_hugepages(str >> } >> >> >> +struct page * >> +alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask, >> + int nid, nodemask_t *nodemask); >> #else /* !CONFIG_HUGETLBFS */ >> >> #define is_file_hugepages(file) false >> @@ -310,6 +313,12 @@ hugetlb_file_setup(const char *name, siz >> return ERR_PTR(-ENOSYS); >> } >> >> +static inline struct page * >> +alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask, >> + int nid, nodemask_t *nodemask) >> +{ >> + return NULL; >> +} >> #endif /* !CONFIG_HUGETLBFS */ >> >> #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA >> --- a/mm/hugetlb.c~mm-hugetlb-make-alloc_gigantic_page-available-for-general-use >> +++ a/mm/hugetlb.c >> @@ -1112,10 +1112,9 @@ static bool zone_spans_last_pfn(const st >> return zone_spans_pfn(zone, last_pfn); >> } >> >> -static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, >> +struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask, >> int nid, nodemask_t *nodemask) >> { >> - unsigned int order = huge_page_order(h); >> unsigned long nr_pages = 1 << order; >> unsigned long ret, pfn, flags; >> struct zonelist *zonelist; >> @@ -1151,6 +1150,14 @@ static struct page *alloc_gigantic_page( >> return NULL; >> } >> >> +static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, >> + int nid, nodemask_t *nodemask) >> +{ >> + unsigned int order = huge_page_order(h); >> + >> + return alloc_gigantic_page_order(order, gfp_mask, nid, nodemask); >> +} >> + >> static void prep_new_huge_page(struct hstate *h, struct page *page, int nid); >> static void prep_compound_gigantic_page(struct page *page, unsigned int order); >> #else /* !CONFIG_CONTIG_ALLOC */ >> @@ -1159,6 +1166,12 @@ static struct page *alloc_gigantic_page( >> { >> return NULL; >> } >> + >> +struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask, >> + int nid, nodemask_t *nodemask) >> +{ >> + return NULL; >> +} >> #endif /* CONFIG_CONTIG_ALLOC */ >> >> #else /* !CONFIG_ARCH_HAS_GIGANTIC_PAGE */ >> @@ -1167,6 +1180,13 @@ static struct page *alloc_gigantic_page( >> { >> return NULL; >> } >> + >> +struct page *alloc_gigantic_page_order(unsigned int order, gfp_t gfp_mask, >> + int nid, nodemask_t *nodemask) >> +{ >> + return NULL; >> +} >> + >> static inline void free_gigantic_page(struct page *page, unsigned int order) { } >> static inline void destroy_compound_gigantic_page(struct page *page, >> unsigned int order) { } >> _ >> >> Patches currently in -mm which might be from anshuman.khandual@arm.com are >> >> mm-hugetlb-make-alloc_gigantic_page-available-for-general-use.patch >> mm-debug-add-tests-validating-architecture-page-table-helpers.patch >> mm-hotplug-reorder-memblock_-calls-in-try_remove_memory.patch >