Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp850443lqb; Wed, 17 Apr 2024 12:35:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWt789OXRM6Glue1o8IPOBcmYzNKCOTmskv9XX+ugIJ4NAJk4XXp5vZX7xNFFvO9etnM3yEHpa7EpKlEeUFZQ3hrMOm0HSBH8E+piumpw== X-Google-Smtp-Source: AGHT+IF78RkhJ9WMmxwJOIhdyAEU2CIhgIJ7exxLu3Bdc8czUdt/cJmv2uHPUhSYTcYhQy/UUHH0 X-Received: by 2002:a17:90a:db08:b0:2a2:d10d:d30d with SMTP id g8-20020a17090adb0800b002a2d10dd30dmr435791pjv.26.1713382548105; Wed, 17 Apr 2024 12:35:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713382548; cv=pass; d=google.com; s=arc-20160816; b=JuFx///2gwsyqWjZcxN5MBKqo30pqskdYTSydh4A3eOiF/54Hh3pUThV9I4WeCFfR2 NQHy2EXgvygtNw0QK7bbx6ekIYltIbtRqKbqNY+qN3teTWa4OEw2bVo9Hdzr3t9rdHFL Tf0jdO2gRtiy+UXkouHztO32FbQjEskYuQ/SeOzkmuClxV+ZW1HVtYXIPFknX6QyP3dK cRfGag5nvG7KY4130G6LcaiYlTVZvJb/gSOe+EGHvbNP1+QE1yHvOk7UKr2LZY+Cz8nN xG66P93H+ArWO++Li/UYLYahNh/57d8dLkI7GPlKdiiixNRKa7pRqsZRAzff1Zm2miHe yp7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pBMdcpQ25/+T/NEM+WU5iK2tV2QpEf94VKfD0+pnnZw=; fh=hdmPxYuH/NxoT0+T0Uy6keTrTow8UDPyyjFVc9zCFQc=; b=jsf2KRITP2oHD1+qw04zHrtmMZzWMbtcHliZ5QBdyGAoX6tjNSoPU4a6GjaHf5xK2N QDBAca51iOuk/VG5KKHeH+zpmdSE1JG3Un85qk7eNGFsfvJNhYMSDc3wTX95A51gUmfs qfGF0MJEC/OA29MSioTErQGi2g5WJWudkZpFf/5rxBilWQnYGjJBCNd8GgtHnnPN0y4Z FQlr9j03MHHcKhFt7JDYmEgWc0X168+fFugsOcaIbwcP/eTXU8O/pdqQu47PdUQjhNaD vcwy09k26FWwOziGXiq/aZSp92hqhUF7S4De7f/U8MGonoi6rZV19Q/wIa1Iy7Om+qhW lryQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hb+8+TXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-2135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b6-20020a636706000000b005dc788f3767si12101400pgc.620.2024.04.17.12.35.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 12:35:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hb+8+TXV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-2135-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B7F462825EE for ; Wed, 17 Apr 2024 19:35:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA16F2C861; Wed, 17 Apr 2024 19:35:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hb+8+TXV" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 261D51BF53; Wed, 17 Apr 2024 19:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713382541; cv=none; b=ABepTx2xIv7redKzvNoonhYQ539mcK519YGuWClOoKiUZ5WygTSfd+mMp/MS4jGehQ+YCrA0rZL8Ae+JnKbnpwS63tlzAvJpY+PPpMGlFPPYsv4O+qg3XD8RldRpfeFZ07/j1mqBGjhi6OzgtX8vFfgTMoXsK+0wTiQworGpjsU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713382541; c=relaxed/simple; bh=D7V7cK/8mNacv3vFISbQfmWRwzEyZTIcIMLY5u7r1pA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q7ZrOJ6UczIPILyWIG0sO5NWh/KYtOuzKCYvI9cW3yHOasj1DGHu+SB+Ro9pTmUPs9xESoJgVh7U4mL0ArtVHoRvopV7Bjy3c6uOare/B76J7GTCV/ACtCSSuP6uD3Oj0YfFScDYjSUzNSCkT0dYDaGAdaw88lYnAVhdz5PoAkY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hb+8+TXV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3909CC072AA; Wed, 17 Apr 2024 19:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713382540; bh=D7V7cK/8mNacv3vFISbQfmWRwzEyZTIcIMLY5u7r1pA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hb+8+TXVdmYjhheg9GEtOlw+rpmMP0ryAmTR3HCIbTH3jWoQmDTy6dI0KIzG5O6z4 RoXopQ9dEv7BCk9+6snZO118PbwU8tPqVRWRXdE2+J4iCXcvysOcBu1jdgJBONZ0HZ grOlXjP6FnouSABVzLIq83/U/jFXay0lcKNNKLd9CxHvA4GNvNfFVBsMDeIa8QK9yq SdJX1AIklVERA6yFqxMhRf91wZJoxR0/V+Ybmkc3M1Q96cansBf9aQ+vWqpb4w0WCe uftHf9VatHr1/2PjLjo7eYVe9nYjSsgzYZd7crt0+dFDxVUm2gntDjtBwBCfof006e a/7poxFCaJYnA== Date: Wed, 17 Apr 2024 22:34:28 +0300 From: Mike Rapoport To: Nam Cao Cc: Matthew Wilcox , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Christian Brauner , Andreas Dilger , Al Viro , linux-fsdevel , Jan Kara , Linux Kernel Mailing List , linux-riscv@lists.infradead.org, Theodore Ts'o , Ext4 Developers List , Conor Dooley , Anders Roxell , Alexandre Ghiti Subject: Re: riscv32 EXT4 splat, 6.8 regression? Message-ID: References: <8734rlo9j7.fsf@all.your.base.are.belong.to.us> <20240416171713.7d76fe7d@namcao> <20240416173030.257f0807@namcao> <87v84h2tee.fsf@all.your.base.are.belong.to.us> <20240416181944.23af44ee@namcao> <20240417003639.13bfd801@namcao> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240417003639.13bfd801@namcao> On Wed, Apr 17, 2024 at 12:36:39AM +0200, Nam Cao wrote: > On 2024-04-16 Mike Rapoport wrote: > > On Tue, Apr 16, 2024 at 06:00:29PM +0100, Matthew Wilcox wrote: > > > On Tue, Apr 16, 2024 at 07:31:54PM +0300, Mike Rapoport wrote: > > > > > - if (!IS_ENABLED(CONFIG_64BIT)) { > > > > > - max_mapped_addr = __pa(~(ulong)0); > > > > > - if (max_mapped_addr == (phys_ram_end - 1)) > > > > > - memblock_set_current_limit(max_mapped_addr - 4096); > > > > > - } > > > > > + memblock_reserve(__pa(-PAGE_SIZE), PAGE_SIZE); > > > > > > > > Ack. > > > > > > Can this go to generic code instead of letting architecture maintainers > > > fall over it? > > > > Yes, it's just have to happen before setup_arch() where most architectures > > enable memblock allocations. > > This also works, the reported problem disappears. > > However, I am confused about one thing: doesn't this make one page of > physical memory inaccessible? > > Is it better to solve this by setting max_low_pfn instead? Then at > least the page is still accessible as high memory. It could be if riscv had support for HIGHMEM. > Best regards, > Nam > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index fa34cf55037b..6e3130cae675 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -197,7 +197,6 @@ early_param("mem", early_mem); > static void __init setup_bootmem(void) > { > phys_addr_t vmlinux_end = __pa_symbol(&_end); > - phys_addr_t max_mapped_addr; > phys_addr_t phys_ram_end, vmlinux_start; > > if (IS_ENABLED(CONFIG_XIP_KERNEL)) > @@ -235,23 +234,9 @@ static void __init setup_bootmem(void) > if (IS_ENABLED(CONFIG_64BIT)) > kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base; > > - /* > - * memblock allocator is not aware of the fact that last 4K bytes of > - * the addressable memory can not be mapped because of IS_ERR_VALUE > - * macro. Make sure that last 4k bytes are not usable by memblock > - * if end of dram is equal to maximum addressable memory. For 64-bit > - * kernel, this problem can't happen here as the end of the virtual > - * address space is occupied by the kernel mapping then this check must > - * be done as soon as the kernel mapping base address is determined. > - */ > - if (!IS_ENABLED(CONFIG_64BIT)) { > - max_mapped_addr = __pa(~(ulong)0); > - if (max_mapped_addr == (phys_ram_end - 1)) > - memblock_set_current_limit(max_mapped_addr - 4096); To be precisely strict about the conflict between mapping a page at 0xfffff000 and IS_ERR_VALUE, memblock should not allocate the that page, so memblock_set_current_limit() should remain. It does not need all the surrounding if, though just setting the limit for -PAGE_SIZE should do. Although I suspect that this call to memblock_set_current_limit() is what caused the splat in ext4. Without that limit enforcement, the last page would be the first one memblock allocates and it most likely would have ended in the kernel page tables and would never be checked for IS_ERR. With the limit set that page made it to the buddy and got allocated by the code that actually does IS_ERR checks. > - } > - > min_low_pfn = PFN_UP(phys_ram_base); > - max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end); > + max_pfn = PFN_DOWN(phys_ram_end); > + max_low_pfn = min(max_pfn, PFN_DOWN(__pa(-PAGE_SIZE))); > high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); > > dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn)); -- Sincerely yours, Mike.