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 A8083C54FC9 for ; Tue, 21 Apr 2020 06:58:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D8092072D for ; Tue, 21 Apr 2020 06:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587452327; bh=zSEWmKynQKWmz0IUSm5ihu6tEO3dWhXZaB1lMRy7jqQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=J6AmqyacbcRV8appVdijy+0aGfdzEcey36+wCDxap/Eu2Wk/bp/3YyNzhEemg4RMU WGWuzl8jGvgUplSKfgbjgqjraJIVt44jeL8wZruuQTah/trcBEzZZ+TOyzSw3QFt2C uQ/hIN2Dk3SjsgTEv62DuNjhJoGMMzYGzKDyIBaQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbgDUG6r (ORCPT ); Tue, 21 Apr 2020 02:58:47 -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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Date: Tue, 21 Apr 2020 06:58:37 +0000 Subject: Re: [PATCH v3 0/4] Clean up hugetlb boot command line processing Message-Id: <20200421065836.GA14448@willie-the-truck> List-Id: 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> In-Reply-To: <86333853-0648-393f-db96-d581ee114d2b@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Mike Kravetz Cc: linux-doc@vger.kernel.org, Catalin Marinas , Dave Hansen , Heiko Carstens , Peter Xu , Linux-MM , Paul Mackerras , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Mina Almasry , linux-s390@vger.kernel.org, Anders Roxell , Jonathan Corbet , Christian Borntraeger , Ingo Molnar , Benjamin Herrenschmidt , Longpeng , Albert Ou , Vasily Gorbik , Qian Cai , Paul Walmsley , Thomas Gleixner , Linux ARM , Christophe Leroy , Nitesh Narayan Lal , Randy Dunlap , LKML , Palmer Dabbelt , Andrew Morton , linuxppc-dev , "David S.Miller" 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 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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 AB59DC2BA19 for ; Tue, 21 Apr 2020 06:58:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 473F42073A for ; Tue, 21 Apr 2020 06:58:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Tvc3XYxs"; dkim=fail reason="signature verification failed" (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 473F42073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To :Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6P8shjSruP+Jbh0ZqugzN5fC26tEIX5ILDg3M+VmMhc=; b=Tvc3XYxsH2CftIanxXGWdl8Ln oy2PPEnBbxsfAHNmX5Tq9j4FbmLTcdNBJwYcOd4hsKBpoYJs2rFhG7u5AmBa6xKeCuTVWCkQKKKMH cFoyrrX7CrMFbSXpNpxMrlDATW9HZZHfjM+8kSxjXNnRh8Ykm6G9thICmN6VcxcBFmODrLvkYHZvs znbkqtbpU7HpVkURdsCHT5npLFd2FakvE8JfnvjxChNTeOM7XQHhIjhk9/R3D3H4c0Mb8bhlPh4QV Z/BMJq7Y6fRgThCiABps+rkeki1tF4g9eHA0cyY335R+inUMr50QA7Iqu8e31f8wnIae8C57FwsK6 CS3d4FmXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQmrv-00018U-EZ; Tue, 21 Apr 2020 06:58:55 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQmrm-0000yu-9V; Tue, 21 Apr 2020 06:58:47 +0000 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200420_235846_370042_EE2F997E X-CRM114-Status: GOOD ( 20.92 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, Catalin Marinas , Dave Hansen , Heiko Carstens , Peter Xu , Linux-MM , Paul Mackerras , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Mina Almasry , linux-s390@vger.kernel.org, Anders Roxell , Jonathan Corbet , Christian Borntraeger , Ingo Molnar , Benjamin Herrenschmidt , Longpeng , Albert Ou , Vasily Gorbik , Qian Cai , Paul Walmsley , Thomas Gleixner , Linux ARM , Christophe Leroy , Nitesh Narayan Lal , Randy Dunlap , LKML , Palmer Dabbelt , Andrew Morton , linuxppc-dev , "David S.Miller" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.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 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.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 F3C4FC2BA19 for ; Tue, 21 Apr 2020 07:00:30 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A51B4206A5 for ; Tue, 21 Apr 2020 07:00:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (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 A51B4206A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 495vbJ3JfTzDqst for ; Tue, 21 Apr 2020 17:00:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=will@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=u/UKJNZH; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 495vYN38s7zDqNQ for ; Tue, 21 Apr 2020 16:58:48 +1000 (AEST) 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 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-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, Catalin Marinas , Dave Hansen , Heiko Carstens , Peter Xu , Linux-MM , Paul Mackerras , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Mina Almasry , linux-s390@vger.kernel.org, Anders Roxell , Jonathan Corbet , Christian Borntraeger , Ingo Molnar , Longpeng , Albert Ou , Vasily Gorbik , Qian Cai , Paul Walmsley , Thomas Gleixner , Linux ARM , Nitesh Narayan Lal , Randy Dunlap , LKML , Palmer Dabbelt , Andrew Morton , linuxppc-dev , "David S.Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 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.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 1CB8AC54FC9 for ; Tue, 21 Apr 2020 06:58:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3F852072D for ; Tue, 21 Apr 2020 06:58:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SqIBrwCU"; dkim=fail reason="signature verification failed" (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 E3F852072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gTaesB28hxod+pVVt1XA1cBfHG5AmfTe7/RlEFsedjs=; b=SqIBrwCUPZNx8Q V4KfHaTHsKL3AW5C/cumQ2gzBEg9jKzvM1oHlH9lk79nDn+z2UeIMr/tt5ArU2fkoLHNHdk1Gc1EA DRcUQB8gM6cGcgYObgrFnSQfDZfVOFYMHzxVcHFBbKe39KjvYBqgjHIw16kGEFc5yGSxpuRaz42xg c0bNva7HNm2+STHBzzNySOazs+3uxO2jZc+ZX7IB3LXa2aTBV0cqyFn2smozO1qa6FfMHPzJM9t25 NVencSDCZVxzz4ofNbH9acRHfpG39SSyUK1vWtH/fiUvmvWx42dSSvrDiKgJ7jNFacuVKEN7mwjCa Vdp7mcvV/x/+dFChrj3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQmro-0000zm-FI; Tue, 21 Apr 2020 06:58:48 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQmrm-0000yu-9V; Tue, 21 Apr 2020 06:58:47 +0000 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 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-Disposition: inline In-Reply-To: <86333853-0648-393f-db96-d581ee114d2b@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200420_235846_370042_EE2F997E X-CRM114-Status: GOOD ( 20.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, Catalin Marinas , Dave Hansen , Heiko Carstens , Peter Xu , Linux-MM , Paul Mackerras , sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org, Mina Almasry , linux-s390@vger.kernel.org, Anders Roxell , Jonathan Corbet , Christian Borntraeger , Ingo Molnar , Benjamin Herrenschmidt , Longpeng , Albert Ou , Vasily Gorbik , Qian Cai , Paul Walmsley , Thomas Gleixner , Linux ARM , Christophe Leroy , Nitesh Narayan Lal , Randy Dunlap , LKML , Palmer Dabbelt , Andrew Morton , linuxppc-dev , "David S.Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel