Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp233293lqj; Wed, 10 Apr 2024 08:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrrekNUsNV9UoCftOrZ+nMnb+kr67R19mE05mmaZ7rtTTXtpwP/dwjLfM0EALA8VeKFlLVIsnThTFM4x74D/34Jd+66gpCkZt9RKpOkQ== X-Google-Smtp-Source: AGHT+IFs0fROEa4Na9WGKYosJwkaGdoOelH9QdbVwoGIk3IhPuArFvU92EzunS87K7Vyk7NKCOmd X-Received: by 2002:a05:6358:6e87:b0:183:645b:cf8d with SMTP id q7-20020a0563586e8700b00183645bcf8dmr3915532rwm.16.1712764670462; Wed, 10 Apr 2024 08:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712764670; cv=pass; d=google.com; s=arc-20160816; b=B0j+o++b4rMmHrrYhDOmvxq0uCBAwsUZBdXmnGbiCs/Hj95HFwYouG/2uMVXFmxIj1 Dm20IBuyRAhBIW5gIx7DudMJf5Xq+Xu6DFoSXc69EEaeJWVXKL4xiA73MKWRxS/2D/Su AUJDpm7NNhC6OksObxkrIicfj/adp8ToYurbKBYPXjE3w+h0z7kqnDrRoQnO/QGD7bah agzyZsG7ihvXcd0a2UFx187iUqX07ynYtDcrndbMWBxyNuwyDcFj8n6EHtwsR40GJuAO 3sZfDnL6VYnjp+O4k6eTlrZUZXqltpGWdWPqkRB7eOPm/vTJQ1wmFv+fasdvTtov/iUy IFUw== 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=IVcVKrk4PzUgF4HuIkdKngsDaWK3az1O5+iMCoeeUwY=; fh=a4ui6i/RWxma5/Ka2qHgtPgrBaVVR+tgzOuShmexjD0=; b=B7mwl7Qbii6EISnMRKqwdCU4w83Dqwxyc0ULseJCVRYn6ClAJ3EKzDu3Yz6xFObk7d c3qBMcuQyGZTUl3Lph54HFn/IhuTA6mLK/9z2V43bZI0a95UPweQ3dka/6oFatoBOJgN MFmiZoQSUMEpziSVVSKdRbtc+px7ukPwvBgnj+abycf/j3Xl7bh4RKgM933a7S4Rsy7m 1gzCdFdEMVwBcFmHPwG22+Qw8tmhQN4xKi/MS2T7VGUY4mI+Vc9kMth+/kHYUe6Urhoh S32aTR+58a0bevkn5rxJ9euFLD55HAPU0MMWFiIY5CtsO6U7Kh5YMl+yQcgaCCGRUB2p AU6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fpcj2kka; 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-138865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l26-20020a63571a000000b005f42737fa1dsi1916793pgb.790.2024.04.10.08.57.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 08:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fpcj2kka; 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-138865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138865-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 26962B28049 for ; Wed, 10 Apr 2024 15:23:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C4A916E87F; Wed, 10 Apr 2024 15:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fpcj2kka" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 8FAA516D30E for ; Wed, 10 Apr 2024 15:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712762587; cv=none; b=RteHCbBTZ6xLdpKyLGGtW9tyPQBiiIUIpFQq0Y1e3+2CJb427LVlHuUkmy5gkLmld1B53Hp6ESjJtzcIsrGuAKVby7JuWPwfvI59towDLLztMJiY+7csWtu2q2xqu4QzIML+x2mv9hRvEMy8gJcVKZKXYyMt1fqOXoXzi8vUyDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712762587; c=relaxed/simple; bh=2YA6ScZP2GPnSctrWzlZF+AF+jlSQgnZuSK6LYSu3Wo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ME5voR/NCfgIEC03QLuhVNTASWzHqbaOYh2sfc3m+gZVDum55E1NnRtOZYFySnu3oJfl3bnZgcgs/UAnDSIDl99Him4va+DM08kS61xYD88XM8UD45z8qe3f7qlVQ6Om5IOjWRKO6nTqcaJIuw+t7IEdAZzjoGtQFpcBeGs5WzU= 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=Fpcj2kka; arc=none smtp.client-ip=170.10.133.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=1712762584; 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=IVcVKrk4PzUgF4HuIkdKngsDaWK3az1O5+iMCoeeUwY=; b=Fpcj2kkacXVBs91eS6FDxP4GtLk3y7UKIwgiWh7VpaHMZruCFYkpi7CLlDdRIfFwbU+oq1 DnAANK9WcHxshTz4gkeu0mNoowpc6Vz5LE9ux59WDYZ/BeT2aGAe69Fkyg5IG1uWIIgoa0 HOGmqzndwlk7DwID6KFJlUf2Bdt6fRw= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-X3ym9ZzXONqLdowp-1PJrA-1; Wed, 10 Apr 2024 11:23:03 -0400 X-MC-Unique: X3ym9ZzXONqLdowp-1PJrA-1 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-4daa117d98fso2689661e0c.0 for ; Wed, 10 Apr 2024 08:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712762582; x=1713367382; 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=IVcVKrk4PzUgF4HuIkdKngsDaWK3az1O5+iMCoeeUwY=; b=Rtu92W+lrmFmVxvq6vsNBdaQh0Un7ilg/xPxOKkrTCnLXzW9i8S8iM/33Idm2vdg8+ dIvDD301Tlz8W+Nht79lHPztdx8yVdxquD+ccxHNxDtGUEVZbkQqD4Y9FPjfT/MPoVXs sfUfrTkP7qHLSlXkMmBO075ZpeG2VxPLka0Nt/wzkTZ1w0vK2iZBxW7swnv869F6q96K 8had1amOpiLYs5MQbBgBdIfjapd7aNsLe4WJSpu3rgO4U+21Dzr9CBg0V/uFdqx50YSI egd6029s83B7qOvrqAKSnop858LLsBD4xxSSh4IFyk6g47aol4CoABlM51mrOGacPQue UEGA== X-Gm-Message-State: AOJu0YykSbfDRZ2dKEEymkGG8vNy020xtu6XblUT5sbXxlSv1WYtf2IT 94ZT6AGJhXh3qz+e/0VcU2d5JYtWWiz1sGI/8Clj8ZAT22lPULE1u7nSwWE35Lxatx5x/FZFLzk RbYNuymkNKMoYLsuYL4LQ83cMHFuWcL8du3h6EHQYzrfMo5TvmkdL46ZFzD9fHDBytRaGdGZ1tB gvEfL5dGSXV3NRMT8vfMLau0uHR5EuLrIeHGXulF2Hpq0tVx4= X-Received: by 2002:a05:6122:180a:b0:4d4:5d86:b2d with SMTP id ay10-20020a056122180a00b004d45d860b2dmr3229323vkb.16.1712762581867; Wed, 10 Apr 2024 08:23:01 -0700 (PDT) X-Received: by 2002:a05:6122:180a:b0:4d4:5d86:b2d with SMTP id ay10-20020a056122180a00b004d45d860b2dmr3229309vkb.16.1712762581508; Wed, 10 Apr 2024 08:23:01 -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: From: Joel Savitz Date: Wed, 10 Apr 2024 11:22:45 -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 Mon, Apr 1, 2024 at 10:17=E2=80=AFAM Joel Savitz wr= ote: > > On Tue, Mar 26, 2024 at 12:45=E2=80=AFAM Joel Savitz = wrote: > > > > 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= kernel > > > > cmdline parameter results in a system hang at boot. > > > > > > > > For example, using 'mem=3D4198400K' will always reproduce this issu= e. > > > > > > > > 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 kerne= l parameter > > > > > > The value specified for the memory limit is used to set a restric= tion on > > > memory usage. It is important to ensure that this restriction is = within > > > the linear map kernel address space range. The hash page table > > > translation uses a 16MB page size to map the kernel linear map ad= dress > > > space. htab_bolt_mapping() function aligns down the size of the r= ange > > > while mapping kernel linear address space. Since the memblock lim= it is > > > enforced very early during boot, before we can detect the type of= memory > > > translation (radix vs hash), we align the memory limit value spec= ified > > > as a kernel parameter to 16MB. This alignment value will work for= both > > > 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(), PAG= E_SIZE); > > > + if (memory_limit > memblock_phys_mem_size()) > > > + memory_limit =3D 0; > > > + > > > + /* Align down to 16 MB which is large page size with hash pag= e translation */ > > > + 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/pr= om_init.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, 0x1000= 000); > > > + /* Align down to 16 MB which is large page size with = hash page translation */ > > > + prom_memory_limit =3D ALIGN_DOWN(prom_memory_limit, S= Z_16M); > > > #endif > > > } > > > > > > > > > > Sorry for the delayed reply. I just tested this patch and it fixes the > > bug for me. > > Hi, > > Just a quick follow up on this. > > The above patch fixed the bug for me. > > How do we want to proceed? > > Best, > Joel Savitz Hi, I haven't heard anything on this thread so I'm just sending a quick follow = up. Do we want to merge this Best, Joel Savitz