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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 173BFC54FCC for ; Tue, 21 Apr 2020 06:58:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C648F2073A for ; Tue, 21 Apr 2020 06:58:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="u/UKJNZH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C648F2073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 70EB48E0005; Tue, 21 Apr 2020 02:58:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BEA18E0003; Tue, 21 Apr 2020 02:58:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D59B8E0005; Tue, 21 Apr 2020 02:58:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 466DB8E0003 for ; Tue, 21 Apr 2020 02:58:47 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id F1D0F181AEF10 for ; Tue, 21 Apr 2020 06:58:46 +0000 (UTC) X-FDA: 76730959452.17.seat13_2f82f3f8fe55d X-HE-Tag: seat13_2f82f3f8fe55d X-Filterd-Recvd-Size: 5545 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Apr 2020 06:58:46 +0000 (UTC) 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 B1A8C206A5; Tue, 21 Apr 2020 06:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587452325; bh=zSEWmKynQKWmz0IUSm5ihu6tEO3dWhXZaB1lMRy7jqQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u/UKJNZHEKIupjB7ZBsUtiiYe7I6nCSpdDQbmHIZGClUxVmUlZIUfiPEZIzRHYUn6 g6qnj51G9uRyRFpu8kN44be1pro4HTNJ141yDBBMvK2ulYFktfLaQWDGM/4efuHYdD p/+dw+DK48euKA47LcgpoqVY6ox6mMphLQl6q9NI= Date: Tue, 21 Apr 2020 07:58:37 +0100 From: Will Deacon To: Mike Kravetz Cc: Anders Roxell , Qian Cai , Linux-MM , LKML , Linux ARM , linuxppc-dev , 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 , Christophe Leroy , Randy Dunlap , Mina Almasry , Peter Xu , Nitesh Narayan Lal , Andrew Morton Subject: Re: [PATCH v3 0/4] Clean up hugetlb boot command line processing Message-ID: <20200421065836.GA14448@willie-the-truck> References: <20200417185049.275845-1-mike.kravetz@oracle.com> <5E312000-05D8-4C5D-A7C0-DDDE1842CB0E@lca.pw> <4c36c6ce-3774-78fa-abc4-b7346bf24348@oracle.com> <86333853-0648-393f-db96-d581ee114d2b@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86333853-0648-393f-db96-d581ee114d2b@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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, Apr 20, 2020 at 02:40:05PM -0700, Mike Kravetz wrote: > On 4/20/20 1:29 PM, Anders Roxell wrote: > > On Mon, 20 Apr 2020 at 20:23, Mike Kravetz wrote: > >> On 4/20/20 8:34 AM, Qian Cai wrote: > >>> > >>> Reverted this series fixed many undefined behaviors on arm64 with the config, > >> While rearranging the code (patch 3 in series), I made the incorrect > >> assumption that CONT_XXX_SIZE == (1UL << CONT_XXX_SHIFT). However, > >> this is not the case. Does the following patch fix these issues? > >> > >> From b75cb4a0852e208bee8c4eb347dc076fcaa88859 Mon Sep 17 00:00:00 2001 > >> From: Mike Kravetz > >> Date: Mon, 20 Apr 2020 10:41:18 -0700 > >> Subject: [PATCH] arm64/hugetlb: fix hugetlb initialization > >> > >> When calling hugetlb_add_hstate() to initialize a new hugetlb size, > >> be sure to use correct huge pages size order. > >> > >> Signed-off-by: Mike Kravetz > >> --- > >> arch/arm64/mm/hugetlbpage.c | 8 ++++---- > >> 1 file changed, 4 insertions(+), 4 deletions(-) > >> > >> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > >> index 9ca840527296..a02411a1f19a 100644 > >> --- a/arch/arm64/mm/hugetlbpage.c > >> +++ b/arch/arm64/mm/hugetlbpage.c > >> @@ -453,11 +453,11 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma, > >> static int __init hugetlbpage_init(void) > >> { > >> #ifdef CONFIG_ARM64_4K_PAGES > >> - hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); > >> + hugetlb_add_hstate(ilog2(PUD_SIZE) - PAGE_SHIFT); > >> #endif > >> - hugetlb_add_hstate(CONT_PMD_SHIFT - PAGE_SHIFT); > >> - hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT); > >> - hugetlb_add_hstate(CONT_PTE_SHIFT - PAGE_SHIFT); > >> + 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; > >> } > > > > I build this for an arm64 kernel and ran it in qemu and it worked. > > Thanks for testing Anders! > > Will, here is an updated version of the patch based on your suggestion. > I added the () for emphasis but that may just be noise for some. Also, > the naming differences and values for CONT_PTE may make some people > look twice. Not sure if being consistent here helps? Cheers, thanks for this. I think being consistent is worthwhile, as it's the definitions themselves that are weird and we can conceivably clean that up as a separate patch. So, Acked-by: Will Deacon Looks like Andrew already picked it up (thanks!) Thanks, Will