From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18F15606A320 for ; Wed, 21 Oct 2026 09:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nd3RRESd; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=EE/OeHk1; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=VNIuT+eZ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qly2ZXVqJU8mRHFencdxpDDot1stjgFFpJM+J90ArtI=; b=nd3RRESdvJxaaBB6ULXaGSM3K4 Hn4jNvcKbUWvDjVq1ptvarN9MZGClvCxi2nUVuxjmlndHTFCu7TiswVjY+gq/50khZjf1jk/DNSkU djEv6ZOnvOgwTf03kZ24A3x3R0FRbn8jDHG3y0ZgP/DpszI7T5G8o3bG8f/Wqho+sKppldxSh397o y+muYVeWj1N3jZ/TnDJR6XmNenpdRjVqwp6d3C1zxnmpjAkXfHrEXI+aGKMzizCIgwsZeemHEriy2 csIFCFBkz5ZtFdWs9c3rBlC4sCPUoLoXVPbqaZvdJ63wTy27Ddsc7PcYGsduD+Hr97HFyv/d1kCIY WoEHgHBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xJSGf-0000000BR1i-3SUY; Wed, 21 Oct 2026 09:05:53 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xJSGb-0000000BR0s-3DTr; Wed, 21 Oct 2026 09:05:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=qly2ZXVqJU8mRHFencdxpDDot1stjgFFpJM+J90ArtI=; b=EE/OeHk1rF0+dtB8vBwQ76ixey f7Tf1oFYzWIJ9yNOELL2C8OgWUafv71mEn+bVqI3FLksOphPCyzbW27EEs5AMxjqTp36+XA78zic8 DxqErRdQkRhw4F9u3YREb04aB1HJTxwMnYv0zOOyU7BrZdK8PeXyF0z9ViS5ICWWObVk2jguVzOBt qN7LeMI1hptb0qbeM4/QqPG+80irxYe5i6lj1VN3tfi4TioF058xI8EnAqX/8hC5fqMraildazcnz +cswG0ctBNiWHw1L6GnhMGCeb04U0hNUBsBa7pbJx43UlLXPf0P2RxPmZ3vTRLE4xi3862mgnHuJJ FGpPRoYA==; Received: from canpmsgout09.his.huawei.com ([113.46.200.224]) by desiato.infradead.org with esmtps (Exim 4.99.5 #2 (Red Hat Linux)) id 1xJSGW-00000005d87-3WUk; Wed, 21 Oct 2026 09:05:48 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=qly2ZXVqJU8mRHFencdxpDDot1stjgFFpJM+J90ArtI=; b=VNIuT+eZ75BYq5bEgDxPMwxDJad0LsRd2qh8O5xIl6lSkVcMxoMw0iYMTpsMxZj6Jahuezyk/ yCYxoyiTPQ7Vzfr1pjBJxOpwsIQj3XOgI1W9mckRnRaKJwL0kZrJRME/xKwgmPeH9Mbs9PUKvqW U5k8YRQq520iy9kJHkZbWqo= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4j8jks5JQPz1cySH; Wed, 21 Oct 2026 16:54:13 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 682B34058E; Wed, 21 Oct 2026 17:05:33 +0800 (CST) Received: from [10.67.110.68] (10.67.110.68) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Wed, 21 Oct 2026 17:05:32 +0800 Message-ID: <6d4ba1c2-b672-465b-9683-0aa1ad8dee73@huawei.com> Date: Wed, 21 Oct 2026 17:05:31 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 1/8] riscv: build crash_mem ranges from memblock instead of resource tree To: Wandun Chen , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20261021083011.2170525-1-chenwandun1@gmail.com> <20261021083011.2170525-2-chenwandun1@gmail.com> From: Jinjie Ruan In-Reply-To: <20261021083011.2170525-2-chenwandun1@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemk200008.china.huawei.com (7.202.194.74) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261021_100546_082397_A33A8784 X-CRM114-Status: GOOD ( 16.23 ) X-Spam-Score: -0.1 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 在 2026/10/21 16:30, Wandun Chen 写道: > From: Wandun Chen > > Replace walk_system_ram_res() with for_each_mem_range(). A later patch > introduces MEMBLOCK_NODUMP in memblock, the reserved-memory regions > marked with MEMBLOCK_NODUMP can be excluded from the vmcore by walking > memblock. > > for_each_mem_range() iterates memblock.memory, which is freed after > init unless ARCH_KEEP_MEMBLOCK is selected. riscv needs ARCH_KEEP_MEMBLOCK > to filter reserved memory from the vmcore, so extend its condition > (ACPI || KEXEC) with CRASH_DUMP. arm64 and loongarch already select > ARCH_KEEP_MEMBLOCK unconditionally. > > Signed-off-by: Wandun Chen > Tested-by: Meijing Zhao > Acked-by: Baoquan He > --- > arch/riscv/Kconfig | 2 +- > arch/riscv/kernel/machine_kexec_file.c | 31 ++++++++++---------------- > 2 files changed, 13 insertions(+), 20 deletions(-) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index e7891a2a89da..e21d0bab77ee 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -58,7 +58,7 @@ config RISCV > select ARCH_HAS_UBSAN > select ARCH_HAS_VDSO_ARCH_DATA > select ARCH_HAVE_NMI_SAFE_CMPXCHG > - select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC > + select ARCH_KEEP_MEMBLOCK if ACPI || KEXEC || CRASH_DUMP > select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if 64BIT && MMU > select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX > select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT > diff --git a/arch/riscv/kernel/machine_kexec_file.c b/arch/riscv/kernel/machine_kexec_file.c > index 26cd2a8bd0cd..808e872f4063 100644 > --- a/arch/riscv/kernel/machine_kexec_file.c > +++ b/arch/riscv/kernel/machine_kexec_file.c > @@ -37,39 +37,32 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) > } > > #ifdef CONFIG_CRASH_DUMP > -static int get_nr_ram_ranges_callback(struct resource *res, void *arg) > -{ > - unsigned int *nr_ranges = arg; > - > - (*nr_ranges)++; > - return 0; > -} > - > unsigned int arch_get_system_nr_ranges(void) > { > unsigned int nr_ranges = 2 + crashk_cma_cnt; /* For exclusion of crashkernel region */ > + u64 i; > + phys_addr_t start, end; The kernel prefers the reverse Christmas tree layout for local variables. > > - walk_system_ram_res(0, -1, &nr_ranges, get_nr_ram_ranges_callback); > + for_each_mem_range(i, &start, &end) > + nr_ranges++; > > return nr_ranges; > } > > -static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) > +int arch_crash_populate_cmem(struct crash_mem *cmem) > { > - struct crash_mem *cmem = arg; > + u64 i; > + phys_addr_t start, end; > > - cmem->ranges[cmem->nr_ranges].start = res->start; > - cmem->ranges[cmem->nr_ranges].end = res->end; > - cmem->nr_ranges++; > + for_each_mem_range(i, &start, &end) { > + cmem->ranges[cmem->nr_ranges].start = start; > + cmem->ranges[cmem->nr_ranges].end = end - 1; > + cmem->nr_ranges++; > + } > > return 0; > } > > -int arch_crash_populate_cmem(struct crash_mem *cmem) > -{ > - return walk_system_ram_res(0, -1, cmem, prepare_elf64_ram_headers_callback); > -} > - > static char *setup_kdump_cmdline(struct kimage *image, char *cmdline, > unsigned long cmdline_len) > { -- Best regards, Jinjie