Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3102019lqp; Mon, 25 Mar 2024 21:45:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWtIWXScOXuR2ktQyitOQi2FjSlh4AB7/hxItaVFkHrRvNF4XyUYEwoUfIu+syh/dJlQUaFJrVZXyXurCelCx3ErsWOYNdHVfRU6WRyw== X-Google-Smtp-Source: AGHT+IGbDB4YrttUwqMTvujmqrjrLCwoOchP2mqaxx0x1nNjKmDP/4zzys+IMVLmrc4SKugshBVh X-Received: by 2002:a05:620a:1d94:b0:789:e9c1:72a5 with SMTP id pj20-20020a05620a1d9400b00789e9c172a5mr1943761qkn.7.1711428345149; Mon, 25 Mar 2024 21:45:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711428345; cv=pass; d=google.com; s=arc-20160816; b=x61buD0Q/nKWRbrGQrOu4xyuZxATx50SJgVBRirRZly3zZO97A5XnApq8nkIFRp16Z +XzY1NT4Aa3rgZ625DjkwKBK4pQnOGr5oVf56PCITkJPt/0yA+UabTpireiOp+HeclYa o/jtiqde8PhRno9FLm2rDrSmSkvY0ikGpMjgoptUYi4IOgogKuGVw1UL2PFIO8LKJrVZ r5eYuUkUMXQ/wYVZ+Mc/ImR5Fdz8DyqFU0NE/AkQwhTlen66zeGQcFmZoetikPIjcEa6 9RyeLVkxsJLKPJ6hh5VrPZsUz8wAywXPNwArl7iKtljbkYQNAJZ0EOcUC7ZuZoVLKD/I wjkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=iLn9q/d3IXDRXcZITYj+lKYLmTjyEeBrR8h5o+IkddE=; fh=a4ui6i/RWxma5/Ka2qHgtPgrBaVVR+tgzOuShmexjD0=; b=wM6U83RIZIlcsldgOT6UOoDAfNVS4WGjKzfJo2bqsITLxkiQ/l/8r0drwpq+wi+MWe rlmJXi1y7Jv1wgz/4Rlp+tetC74eHCarvCa60V2VXzx+R8zF9R1IdSLD2WM2tHCARroE MRGdoC2NUXeIYArCypnXLDu1EE0HohxwsLmh11L/FtoWrG4aAvEtmYUymZ/DRFqzoa6l BM49VCDrMvzSRsmqxuvGrI3+7upw5HenBM7zb+/xJBmmTf5ZExbmgDsPXm1ba2qGvtgv 9FaL+q5uCtBlk67qtkJ2kS6S3piD9pZcz7B9O3opumKSzJneoadQMlwK6Vagm0cdy9iB WB8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UBNjYIA6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-118360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j17-20020a05620a147100b0078a3d28ee45si7043417qkl.50.2024.03.25.21.45.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 21:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UBNjYIA6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-118360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D08C61C2C4EC for ; Tue, 26 Mar 2024 04:45:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1359871B4C; Tue, 26 Mar 2024 04:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UBNjYIA6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AB4D33FD for ; Tue, 26 Mar 2024 04:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711428338; cv=none; b=lssh3xFqr4M4DU6aOnBUi9PKiJKQw01agmXhxFlfBUe1Ko3NVDLCVT18JYhmamr0F12Hy4eUtWb4unxr9efS3szMPTokkVxuCPFHK6EYOj0eHvZU9TcV+UdUzqfjycEZfi+pFGCo1QtWLYtg1yC7aLEFszV+Qa9I437o8Ur9zfA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711428338; c=relaxed/simple; bh=Pgv/tT/N2P7ZAj+UJ3IWDPgKGNnA2zABKljkfQKwA2U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YGE8vHDUFdmtvcKzR1wb7C9YoVzVK4saTz6pUQ+2TrVXr5YdNe28mz+eheabD5Qx68021XV03yULluJLL2v86QZxPnT+5+K7MFYOb7KvVWcooIFkP9rmpBiSU7T+n64m70wahcxc8V2bGXA+gLGOF56BeSzJ7gj18TfIPxb9KJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UBNjYIA6; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711428335; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iLn9q/d3IXDRXcZITYj+lKYLmTjyEeBrR8h5o+IkddE=; b=UBNjYIA6AbXsH2WUPAUw2yYcxeNH7uemR6Xx1mp4pb8eYZjiqBDGs1NYTL2t41FrLta6Nr o3evOnTNotHlpvwFXN1JeJy9S9bg6GzPRxJ84N7l+pIvxdaryyeU6w8ZQOLcxxMhQ7oIAF Z+NDPY4JPKfDxHa9wWJKHVvWMD9Q/0Y= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-kBzeNlrDPV61i7_pQsiBGg-1; Tue, 26 Mar 2024 00:45:33 -0400 X-MC-Unique: kBzeNlrDPV61i7_pQsiBGg-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-4d45644084cso1996363e0c.3 for ; Mon, 25 Mar 2024 21:45:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711428333; x=1712033133; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iLn9q/d3IXDRXcZITYj+lKYLmTjyEeBrR8h5o+IkddE=; b=FlY8wTJ1eY8forK3SwUlkOvvyXRHtKXf8AAL6eWB8cihx7TKqPxukauZarzcj8nASS ULeYs3U3ulrpYg27/QZm9YaJFWsLAK7Z4f5m0Qwz6lBwE3tLiAoHnPNmoBI2fE8dzOLC ev4qLRLJSS5TLDLpDurgdOVe+fdmbKsvfoAj3UJZHayxeegiLAN0yXGyOirKQasusA1U pg+F5d2gn4xPxNTdX2NBzYXR+KPNbMh3pH52nGDqNn72MWLbDaiBZJNyJTwb0mY3ff/t GDVJwu/wJelymhuG7TkI7TvXlal7A9QPyT0uk4040+0G917123go43RGO6F1DEB6MRxo O8rg== X-Gm-Message-State: AOJu0YwfgWxnChF+Xa2fDGV6mx8UZNcEbn2BSAePFURJ8X6sCbCjfDVj G9JbpBt57LaaUZ1NkFxUQlsbusiLCkrtrV3kG+ottveTlXHdVNWRqa110ow0thbAbY0aR9nl0eB sLOs1ZSKr+e+xv+UhMTSVTyuWRFP76YegyW8TLaTaq/EP1jZoK9VDioJBveGnhQibMWLqF//7GE F5/pD0gxJDnxa7gG+BtMTtp/2k9zsLXP12D4OF X-Received: by 2002:a05:6122:168a:b0:4c9:2540:8520 with SMTP id 10-20020a056122168a00b004c925408520mr1743467vkl.1.1711428332980; Mon, 25 Mar 2024 21:45:32 -0700 (PDT) X-Received: by 2002:a05:6122:168a:b0:4c9:2540:8520 with SMTP id 10-20020a056122168a00b004c925408520mr1743463vkl.1.1711428332671; Mon, 25 Mar 2024 21:45:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240301203023.2197451-1-jsavitz@redhat.com> <87jzmduiva.fsf@kernel.org> In-Reply-To: <87jzmduiva.fsf@kernel.org> From: Joel Savitz Date: Tue, 26 Mar 2024 00:45:16 -0400 Message-ID: Subject: Re: [PATCH] powerpc: align memory_limit to 16MB in early_parse_mem To: "Aneesh Kumar K.V" Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Benjamin Gray , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, Gonzalo Siero Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 8, 2024 at 5:18=E2=80=AFAM Aneesh Kumar K.V wrote: > > Joel Savitz writes: > > > On 64-bit powerpc, usage of a non-16MB-aligned value for the mem=3D ker= nel > > cmdline parameter results in a system hang at boot. > > > > For example, using 'mem=3D4198400K' will always reproduce this issue. > > > > This patch fixes the problem by aligning any argument to mem=3D to 16MB > > corresponding with the large page size on powerpc. > > > > Fixes: 2babf5c2ec2f ("[PATCH] powerpc: Unify mem=3D handling") > > Co-developed-by: Gonzalo Siero > > Signed-off-by: Gonzalo Siero > > Signed-off-by: Joel Savitz > > --- > > arch/powerpc/kernel/prom.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > > index 0b5878c3125b..8cd3e2445d8a 100644 > > --- a/arch/powerpc/kernel/prom.c > > +++ b/arch/powerpc/kernel/prom.c > > @@ -82,8 +82,12 @@ static int __init early_parse_mem(char *p) > > { > > if (!p) > > return 1; > > - > > +#ifdef CONFIG_PPC64 > > + /* Align to 16 MB =3D=3D size of ppc64 large page */ > > + memory_limit =3D ALIGN(memparse(p, &p), 0x1000000); > > +#else > > memory_limit =3D PAGE_ALIGN(memparse(p, &p)); > > +#endif > > DBG("memory limit =3D 0x%llx\n", memory_limit); > > > > return 0; > > -- > > 2.43.0 > > Can you try this change? > > commit 5555bc55e1aa71f545cff31e1eccdb4a2e39df84 > Author: Aneesh Kumar K.V (IBM) > Date: Fri Mar 8 14:45:26 2024 +0530 > > powerpc/mm: Align memory_limit value specified using mem=3D kernel pa= rameter > > The value specified for the memory limit is used to set a restriction= on > memory usage. It is important to ensure that this restriction is with= in > the linear map kernel address space range. The hash page table > translation uses a 16MB page size to map the kernel linear map addres= s > space. htab_bolt_mapping() function aligns down the size of the range > while mapping kernel linear address space. Since the memblock limit i= s > enforced very early during boot, before we can detect the type of mem= ory > translation (radix vs hash), we align the memory limit value specifie= d > as a kernel parameter to 16MB. This alignment value will work for bot= h > hash and radix translations. > > Signed-off-by: Aneesh Kumar K.V (IBM) > > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > index 0b5878c3125b..9bd965d35352 100644 > --- a/arch/powerpc/kernel/prom.c > +++ b/arch/powerpc/kernel/prom.c > @@ -824,8 +824,11 @@ void __init early_init_devtree(void *params) > reserve_crashkernel(); > early_reserve_mem(); > > - /* Ensure that total memory size is page-aligned. */ > - limit =3D ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SI= ZE); > + if (memory_limit > memblock_phys_mem_size()) > + memory_limit =3D 0; > + > + /* Align down to 16 MB which is large page size with hash page tr= anslation */ > + limit =3D ALIGN_DOWN(memory_limit ?: memblock_phys_mem_size(), SZ= _16M); > memblock_enforce_memory_limit(limit); > > #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_4K_PAGES) > diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_i= nit.c > index e67effdba85c..d6410549e141 100644 > --- a/arch/powerpc/kernel/prom_init.c > +++ b/arch/powerpc/kernel/prom_init.c > @@ -817,8 +817,8 @@ static void __init early_cmdline_parse(void) > opt +=3D 4; > prom_memory_limit =3D prom_memparse(opt, (const char **)&= opt); > #ifdef CONFIG_PPC64 > - /* Align to 16 MB =3D=3D size of ppc64 large page */ > - prom_memory_limit =3D ALIGN(prom_memory_limit, 0x1000000)= ; > + /* Align down to 16 MB which is large page size with hash= page translation */ > + prom_memory_limit =3D ALIGN_DOWN(prom_memory_limit, SZ_16= M); > #endif > } > > Sorry for the delayed reply. I just tested this patch and it fixes the bug for me.