Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4431530ybz; Tue, 21 Apr 2020 00:00:20 -0700 (PDT) X-Google-Smtp-Source: APiQypJg2VpLQZXDd6od+C8KDUBEWNiStevujfeQF31aCo/rso0yTYbrU1RGhcA8bPFNcXyDGXnz X-Received: by 2002:a05:6402:1619:: with SMTP id f25mr18055155edv.201.1587452420750; Tue, 21 Apr 2020 00:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587452420; cv=none; d=google.com; s=arc-20160816; b=oVUfgMXaB/Q2xRQ1CUHuds2D8TShBgFLYHmzfz0+T7otMxVShvx2qyN9cmC2ryluWo cHiP5a90+Vz7nJ9djFxzBE+pZZNAYEb1za3nk+4yLLCR3VDKv0F3OaYi/5aCCJCVCBmM VcFuYc3qOjM0WEGuSR5yKrYu1ygnhr8CW0/8vYfLBleosoS/6m8Y7nFtOyY38lztYahA l6nSEqUxZ5QN9xiC+7LRn4j/1hMHrntkDBDjl8ETxs3jVck7vVxeDos6fz+jRkm+QzPV g/xRwbtvqtYJ06Qag/mGjibAsdlbO9KkrpPEcH0p5HqltyicfOLtEnvYA3Mf+fusKq21 RnaA== 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=6P8shjSruP+Jbh0ZqugzN5fC26tEIX5ILDg3M+VmMhc=; b=Jrr5Cd2Yc135F5IqWFxpuJdlSC1IfU8L2c3sgulHVYC1IzyiabjqrTPS8v/FOPWpCO IJuCWO/QJrY4oteUSDw3ZQckgUJ4EImKl67lyVmze/8A9qDARQPFy+eUqI6zUy0F2RyF RU6wuc1V8DsRRRdDW+4+rPj3UfEIm8IcaRyGzpNA5YgiaE6pYmpZ5rsKtMbZd1yLIPgA 8RLLQns7D+NSVvvuQwfC36dFy9GyfYboQ2tRUANxDSexqVK3uvtnAaqAgpUKz615i7pA c3oe8FqWwNqiLVi5Z6aVNtkwv3ub6X49gjV/4qMUmENuIcqLKPPvWfRm8XeFu05qkRPs bCng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="u/UKJNZH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w7si720852edr.309.2020.04.20.23.59.54; Tue, 21 Apr 2020 00:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="u/UKJNZH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726748AbgDUG6q (ORCPT + 99 others); Tue, 21 Apr 2020 02:58:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:57114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbgDUG6q (ORCPT ); Tue, 21 Apr 2020 02:58:46 -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 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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