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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 B5BF8C10DCE for ; Tue, 24 Mar 2020 00:23:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F09C206F9 for ; Tue, 24 Mar 2020 00:23:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GwlYf85E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F09C206F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 027306B0096; Mon, 23 Mar 2020 20:23:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF2AD6B0099; Mon, 23 Mar 2020 20:23:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBAA66B009A; Mon, 23 Mar 2020 20:23:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id BD4316B0096 for ; Mon, 23 Mar 2020 20:23:28 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8561F18448E47 for ; Tue, 24 Mar 2020 00:23:28 +0000 (UTC) X-FDA: 76628356896.11.sign12_3b608f0c88d42 X-HE-Tag: sign12_3b608f0c88d42 X-Filterd-Recvd-Size: 12242 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Mar 2020 00:23:27 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id y71so16767804oia.7 for ; Mon, 23 Mar 2020 17:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nT6jCQDEDbGNVEIn/LnERb00hoLuYmjeNAiNp5nTKYM=; b=GwlYf85ESUp/DlVF7x/wlBGNQEeIAYZZv0wplHKftWadCwEoQf9BFPhxGWJUqpavRR 3pmPVVdZhXhaG+L+i+aPxIDvGtRh9WgAbSZOlUfWyKyBM+5kp9AIlJioRFZm5vnG6DPt a2n1+mqvcCxm8nGSAWgoacptEWH6H3LNIUKcMWv73rOxP3xA5b4LifNMbIIkM0FUS+HK VgnGw7p2CpgsjhWNYQR9zD1lmZOMmGmjIf7S8sttMruE+zU8pvt3myw/LJekVkqUjJ4A AvujDnaja2ledhfx4wosGI/SYCr0Z6GqKMnNkusprc3N9MJHrP8+gGju1xr6QG5bpgh1 zekQ== 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=nT6jCQDEDbGNVEIn/LnERb00hoLuYmjeNAiNp5nTKYM=; b=d3xsguBkBnhepQhcewka0ReibzC497PUG3qbpYEGdzJwE36KUFgt9l3UzXRKBDE8P6 3oylMn1mb+T680blT/hTaC6+EXid2TA7Wy7UZrXtBesuDWsf6VqN29dcXqD5io6qSOdM 6+oUVytOPsY63kOAy5Q1XKoZASRrgzVUx5aylwlEvkDKlxmtlBNfm5D8u2pED7TkB7ny 8gBJ9JHOEnKM2j3aF48lYO9fkZW7lacyDv440JQmMOIF0wK0iJvVzJwvT8emk2duzIPs HWsfpOLYYO2aGgIwX8pWbbxVU2KJU77yRuLNcDDLee2Qtw2qIjlj0WCukuy0Cw5RZt0J UCIg== X-Gm-Message-State: ANhLgQ2yXL7vlEKCxhsweSOKHPpGqFPsbVvvlOJv4SVsWokQPV+FQpIL D85i1bHiespUahfIZAxQYEEekVMFLdC5ziupsqzAJQ== X-Google-Smtp-Source: ADFU+vv2AfwnU57S8AACvd8xl8oCuLz4H6mlZ0SvtJJCSGZGnACkdbmOtsu6ApbR+iSoN014+vCe3BJOk7b5zrbzxWE= X-Received: by 2002:aca:d705:: with SMTP id o5mr1241248oig.67.1585009406681; Mon, 23 Mar 2020 17:23:26 -0700 (PDT) MIME-Version: 1.0 References: <20200318220634.32100-1-mike.kravetz@oracle.com> <20200318220634.32100-4-mike.kravetz@oracle.com> <54fd7234-bdd9-de78-9351-16706bae2c08@oracle.com> In-Reply-To: <54fd7234-bdd9-de78-9351-16706bae2c08@oracle.com> From: Mina Almasry Date: Mon, 23 Mar 2020 17:23:15 -0700 Message-ID: Subject: Re: [PATCH 3/4] hugetlbfs: remove hugetlb_add_hstate() warning for existing hstate To: Mike Kravetz Cc: Linux-MM , open list , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-doc@vger.kernel.org, Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "David S.Miller" , Thomas Gleixner , Ingo Molnar , Dave Hansen , Jonathan Corbet , Longpeng , Andrew Morton Content-Type: text/plain; charset="UTF-8" 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 Mon, Mar 23, 2020 at 5:17 PM Mike Kravetz wrote: > > On 3/23/20 5:01 PM, Mina Almasry wrote: > > On Wed, Mar 18, 2020 at 3:07 PM Mike Kravetz wrote: > >> > >> The routine hugetlb_add_hstate prints a warning if the hstate already > >> exists. This was originally done as part of kernel command line > >> parsing. If 'hugepagesz=' was specified more than once, the warning > >> pr_warn("hugepagesz= specified twice, ignoring\n"); > >> would be printed. > >> > >> Some architectures want to enable all huge page sizes. They would > >> call hugetlb_add_hstate for all supported sizes. However, this was > >> done after command line processing and as a result hstates could have > >> already been created for some sizes. To make sure no warning were > >> printed, there would often be code like: > >> if (!size_to_hstate(size) > >> hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT) > >> > >> The only time we want to print the warning is as the result of command > >> line processing. So, remove the warning from hugetlb_add_hstate and > >> add it to the single arch independent routine processing "hugepagesz=". > >> After this, calls to size_to_hstate() in arch specific code can be > >> removed and hugetlb_add_hstate can be called without worrying about > >> warning messages. > >> > >> Signed-off-by: Mike Kravetz > >> --- > >> arch/arm64/mm/hugetlbpage.c | 16 ++++------------ > >> arch/powerpc/mm/hugetlbpage.c | 3 +-- > >> arch/riscv/mm/hugetlbpage.c | 2 +- > >> arch/sparc/mm/init_64.c | 19 ++++--------------- > >> arch/x86/mm/hugetlbpage.c | 2 +- > >> mm/hugetlb.c | 10 +++++++--- > >> 6 files changed, 18 insertions(+), 34 deletions(-) > >> > >> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > >> index 4aa9534a45d7..050809e6f0a9 100644 > >> --- a/arch/arm64/mm/hugetlbpage.c > >> +++ b/arch/arm64/mm/hugetlbpage.c > >> @@ -441,22 +441,14 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma, > >> clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); > >> } > >> > >> -static void __init add_huge_page_size(unsigned long size) > >> -{ > >> - if (size_to_hstate(size)) > >> - return; > >> - > >> - hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); > >> -} > >> - > >> static int __init hugetlbpage_init(void) > >> { > >> #ifdef CONFIG_ARM64_4K_PAGES > >> - add_huge_page_size(PUD_SIZE); > >> + hugetlb_add_hstate(ilog2(PUD_SIZE) - PAGE_SHIFT); > >> #endif > >> - add_huge_page_size(CONT_PMD_SIZE); > >> - add_huge_page_size(PMD_SIZE); > >> - add_huge_page_size(CONT_PTE_SIZE); > >> + hugetlb_add_hstate(ilog2(CONT_PMD_SIZE) - PAGE_SHIFT); > >> + hugetlb_add_hstate(ilog2(PMD_SIZE) - PAGE_SHIFT); > >> + hugetlb_add_hstate(ilog2(CONT_PTE_SIZE) - PAGE_SHIFT); > >> > >> return 0; > >> } > >> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c > >> index 166960ba1236..f46464ba6fb4 100644 > >> --- a/arch/powerpc/mm/hugetlbpage.c > >> +++ b/arch/powerpc/mm/hugetlbpage.c > >> @@ -584,8 +584,7 @@ static int __init add_huge_page_size(unsigned long long size) > >> if (!arch_hugetlb_valid_size(size)) > >> return -EINVAL; > >> > >> - if (!size_to_hstate(size)) > >> - hugetlb_add_hstate(shift - PAGE_SHIFT); > >> + hugetlb_add_hstate(shift - PAGE_SHIFT); > >> return 0; > >> } > >> > >> diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c > >> index bdf89d7eb714..beaa91941db8 100644 > >> --- a/arch/riscv/mm/hugetlbpage.c > >> +++ b/arch/riscv/mm/hugetlbpage.c > >> @@ -26,7 +26,7 @@ bool __init arch_hugetlb_valid_size(unsigned long long size) > >> static __init int gigantic_pages_init(void) > >> { > >> /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */ > >> - if (IS_ENABLED(CONFIG_64BIT) && !size_to_hstate(1UL << PUD_SHIFT)) > >> + if (IS_ENABLED(CONFIG_64BIT)) > >> hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); > >> return 0; > >> } > >> diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c > >> index 5c29203fd460..8f619edc8f8c 100644 > >> --- a/arch/sparc/mm/init_64.c > >> +++ b/arch/sparc/mm/init_64.c > >> @@ -325,23 +325,12 @@ static void __update_mmu_tsb_insert(struct mm_struct *mm, unsigned long tsb_inde > >> } > >> > >> #ifdef CONFIG_HUGETLB_PAGE > >> -static void __init add_huge_page_size(unsigned long size) > >> -{ > >> - unsigned int order; > >> - > >> - if (size_to_hstate(size)) > >> - return; > >> - > >> - order = ilog2(size) - PAGE_SHIFT; > >> - hugetlb_add_hstate(order); > >> -} > >> - > >> static int __init hugetlbpage_init(void) > >> { > >> - add_huge_page_size(1UL << HPAGE_64K_SHIFT); > >> - add_huge_page_size(1UL << HPAGE_SHIFT); > >> - add_huge_page_size(1UL << HPAGE_256MB_SHIFT); > >> - add_huge_page_size(1UL << HPAGE_2GB_SHIFT); > >> + hugetlb_add_hstate(HPAGE_64K_SHIFT - PAGE_SHIFT); > >> + hugetlb_add_hstate(HPAGE_SHIFT - PAGE_SHIFT); > >> + hugetlb_add_hstate(HPAGE_256MB_SHIFT - PAGE_SHIFT); > >> + hugetlb_add_hstate(HPAGE_2GB_SHIFT - PAGE_SHIFT); > >> > >> return 0; > >> } > >> diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c > >> index dd3ed09f6c23..8a3f586e1217 100644 > >> --- a/arch/x86/mm/hugetlbpage.c > >> +++ b/arch/x86/mm/hugetlbpage.c > >> @@ -195,7 +195,7 @@ bool __init arch_hugetlb_valid_size(unsigned long long size) > >> static __init int gigantic_pages_init(void) > >> { > >> /* With compaction or CMA we can allocate gigantic pages at runtime */ > >> - if (boot_cpu_has(X86_FEATURE_GBPAGES) && !size_to_hstate(1UL << PUD_SHIFT)) > >> + if (boot_cpu_has(X86_FEATURE_GBPAGES)) > >> hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); > >> return 0; > >> } > >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c > >> index cd4ec07080fb..cc85b4f156ca 100644 > >> --- a/mm/hugetlb.c > >> +++ b/mm/hugetlb.c > >> @@ -3116,8 +3116,7 @@ static int __init hugetlb_init(void) > >> } > >> > >> default_hstate_size = HPAGE_SIZE; > >> - if (!size_to_hstate(default_hstate_size)) > >> - hugetlb_add_hstate(HUGETLB_PAGE_ORDER); > >> + hugetlb_add_hstate(HUGETLB_PAGE_ORDER); > >> } > >> default_hstate_idx = hstate_index(size_to_hstate(default_hstate_size)); > >> if (default_hstate_max_huge_pages) { > >> @@ -3155,7 +3154,6 @@ void __init hugetlb_add_hstate(unsigned int order) > >> unsigned long i; > >> > >> if (size_to_hstate(PAGE_SIZE << order)) { > >> - pr_warn("hugepagesz= specified twice, ignoring\n"); > >> return; > >> } > >> BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE); > >> @@ -3231,6 +3229,12 @@ static int __init hugepagesz_setup(char *s) > >> return 0; > >> } > >> > >> + if (size_to_hstate(size)) { > >> + pr_warn("HugeTLB: hugepagesz %s specified twice, ignoring\n", > >> + saved_s); > >> + return 0; > >> + } > >> + > > > > Not too familiar with the code but I'm a bit confused by this print. > > AFAICT this prints the warning when hugepagesz= refers to a hugepage > > that is already added via hugetlb_add_hstate, but there is a default > > hstate added here without the user specifying hugepagesz, no? > > Correct. > > > Does > > that mean the warning prints if you specify this size? > > The code which adds the default hstate (in hugetlb_init) runs after this > code which is reading/processing command line options. So, the case you > are concerned with will not happen. > > Thanks for taking a look, > -- > Mike Kravetz > > > 'HugeTLB: hugepage size already supported: xxxxx' or > > 'HugeTLB: hugepage size xxxx specified twice or is default size, ignoring.' > > > > Or don't print anything if it's the default size. > > > >> hugetlb_add_hstate(ilog2(size) - PAGE_SHIFT); > >> return 1; > >> } > >> -- > >> 2.24.1 Acked-By: Mina Almasry