Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1105217ybh; Wed, 18 Mar 2020 15:12:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vveN7lsNhnN/y/GBwgpq6WZ9rpNWJsn1HW44crjLZjgFqo1IU9uTK2WESirBwrXByfGCMuq X-Received: by 2002:aca:1201:: with SMTP id 1mr122226ois.172.1584569534527; Wed, 18 Mar 2020 15:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584569534; cv=none; d=google.com; s=arc-20160816; b=V+dUw+01vuEvq71K+99pUCVsrMOtnM6BjxYfLqKvQiaZPJMLelxEpOVKwFezRtr/9w mtfeZsi3NnA4gzWokeigaxYKdS5FGYtIOHH2WIMro0SSVdx4OOHRsLyLTFdrzn1Muinu H6JvRvjGROdOSbmyAKcjQbA2bu+jg9Nxo1XwMORbD5uOnUmfZiBR4nLTN0SWT16Ivpb8 N3qLxIfAmc6DsbtnrV2UTmFlK9jYKqbp2HNhb8EdnmbA8wtO9l6PA5EzKX7GjykyHeOq NBTV6AucRheGV/Fp4CSf9GVg04rCC0/02OYtBZhzyA1PPjPmv17BH+yBulwsc4k4VFj2 2O4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R3BBwhZM3L9J08yDIedBVHnwiidpcaJbNsBzNYu/+/4=; b=D+eZmYBvSl2kXwVGGFXCg4fepZpXpXwxibRMFoD8RWdnVoLSGUvIEYUKQPezLC5H2p 324n9DB2PlGRUJPNww4rhwK0JPVFyh9eZhfsFyvdkcAHvA07P9XSQdbGvFkGcMF4ALdc P05iqDVznfivbr9qTW3jKSOc2GV371mkYggdRsn6jwgKCY3nd3YbZop43yS35G3+lr1O PIGas0cJUDG68n/f1qyGspLF5qkZyu75XDLjjqqTapAt7i8XeZt+lWKuzLQe7x2vtJgM 9KhFjZGo+6EPLVxXqhFxOEiMmNjoCxTGc9VCTzVaPOFOgXlzdP2h0WuAlHwDOZEemO14 TqGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HEJhPkoL; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si163650otj.14.2020.03.18.15.12.01; Wed, 18 Mar 2020 15:12:14 -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=@kernel.org header.s=default header.b=HEJhPkoL; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbgCRWKD (ORCPT + 99 others); Wed, 18 Mar 2020 18:10:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:40860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbgCRWKD (ORCPT ); Wed, 18 Mar 2020 18:10:03 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2E42820752; Wed, 18 Mar 2020 22:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584569402; bh=KgfnX7ZnIYjuVD6XaJeA2ijPdABkLg8pgurlLh1kogI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HEJhPkoLbELea44ApXW6LjmWEy3NzdN+AZlAxjzkba7HN4vGDtaKHRQVwAwYpfJcG Ox5kNQ3BOeItN30yKdh/wLq0+edeQSOCKeaDZF4ReUYYRhh8tSM6lK1GNfl8jdubaR ELODdye+Ixp0Hk/34KAiQVZJ+HYzrkK/RwZmCMVc= Date: Wed, 18 Mar 2020 22:09:54 +0000 From: Will Deacon To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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 , 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 Subject: Re: [PATCH 1/4] hugetlbfs: add arch_hugetlb_valid_size Message-ID: <20200318220954.GD8477@willie-the-truck> References: <20200318220634.32100-1-mike.kravetz@oracle.com> <20200318220634.32100-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200318220634.32100-2-mike.kravetz@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 18, 2020 at 03:06:31PM -0700, Mike Kravetz wrote: > The architecture independent routine hugetlb_default_setup sets up > the default huge pages size. It has no way to verify if the passed > value is valid, so it accepts it and attempts to validate at a later > time. This requires undocumented cooperation between the arch specific > and arch independent code. > > For architectures that support more than one huge page size, provide > a routine arch_hugetlb_valid_size to validate a huge page size. > hugetlb_default_setup can use this to validate passed values. > > arch_hugetlb_valid_size will also be used in a subsequent patch to > move processing of the "hugepagesz=" in arch specific code to a common > routine in arch independent code. > > Signed-off-by: Mike Kravetz > --- > arch/arm64/include/asm/hugetlb.h | 2 ++ > arch/arm64/mm/hugetlbpage.c | 19 ++++++++++++++----- > arch/powerpc/include/asm/hugetlb.h | 3 +++ > arch/powerpc/mm/hugetlbpage.c | 20 +++++++++++++------- > arch/riscv/include/asm/hugetlb.h | 3 +++ > arch/riscv/mm/hugetlbpage.c | 28 ++++++++++++++++++---------- > arch/s390/include/asm/hugetlb.h | 3 +++ > arch/s390/mm/hugetlbpage.c | 18 +++++++++++++----- > arch/sparc/include/asm/hugetlb.h | 3 +++ > arch/sparc/mm/init_64.c | 23 ++++++++++++++++------- > arch/x86/include/asm/hugetlb.h | 3 +++ > arch/x86/mm/hugetlbpage.c | 21 +++++++++++++++------ > include/linux/hugetlb.h | 7 +++++++ > mm/hugetlb.c | 16 +++++++++++++--- > 14 files changed, 126 insertions(+), 43 deletions(-) > > diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h > index 2eb6c234d594..3248f35213ee 100644 > --- a/arch/arm64/include/asm/hugetlb.h > +++ b/arch/arm64/include/asm/hugetlb.h > @@ -59,6 +59,8 @@ extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr, > extern void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr, > pte_t *ptep, pte_t pte, unsigned long sz); > #define set_huge_swap_pte_at set_huge_swap_pte_at > +extern bool __init arch_hugetlb_valid_size(unsigned long long size); > +#define arch_hugetlb_valid_size arch_hugetlb_valid_size > > #include > > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index bbeb6a5a6ba6..da30127086d0 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -462,23 +462,32 @@ static int __init hugetlbpage_init(void) > } > arch_initcall(hugetlbpage_init); > > -static __init int setup_hugepagesz(char *opt) > +bool __init arch_hugetlb_valid_size(unsigned long long size) > { > - unsigned long ps = memparse(opt, &opt); > - > - switch (ps) { > + switch (size) { > #ifdef CONFIG_ARM64_4K_PAGES > case PUD_SIZE: > #endif > case CONT_PMD_SIZE: > case PMD_SIZE: > case CONT_PTE_SIZE: > + return true; > + } > + > + return false; > +} > + > +static __init int setup_hugepagesz(char *opt) > +{ > + unsigned long long ps = memparse(opt, &opt); > + > + if arch_hugetlb_valid_size(ps)) { Please compile your changes if you're touching multiple architectures. You can get cross-compiler binaries from: https://mirrors.edge.kernel.org/pub/tools/crosstool/ https://toolchains.bootlin.com/ Will