Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4407327rdb; Fri, 29 Dec 2023 00:02:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHg9mi5rJmf/QgktgWa8jYB+Z9bMt2Q/dOlktV3O4qjuqb1K148Trm16mChPLj62Ihvl/uo X-Received: by 2002:a05:6a20:5603:b0:194:f03c:edd5 with SMTP id ir3-20020a056a20560300b00194f03cedd5mr11432522pzc.62.1703836966660; Fri, 29 Dec 2023 00:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703836966; cv=none; d=google.com; s=arc-20160816; b=tdsdTHC+Sv9zpOcPWKGn+hYYMOOZUN4kNybYtEw83Nz7xy6NcWTVWWkUnawQxgYZM2 +veW6Vvuh/uijfFaYM3P4szKgjrZeapPApSEZ0qggkN28Sk5QzPUy7+tZR3vtGu1X9RB 4XYtl+utGGKBavR4mYBUeoxl/gBQaLUChsLMyIkaiAj5LOg8fGAdqMoUqPQ0ioWMVKS2 Pd4FwipqaeVPmiIgcwfsIBpODqRoK4zp/6x/3tOv96s2R3/I17manJkWuRctn83+dw8R eXvCuWRH9NXVeowL0ktDP/WeGCUXI9YoUMpHcnNEMNUBpQyjBKs8C4KahaMzOSfR7kSj g9Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=14PbnCrQcvtbDTFn2eIaDhLXCDoJ3azf4x+SXrPkyws=; fh=rO18BW7qAOTwW8K5oCz/WW7P7eZpVSjdjyFaCA0r94U=; b=PrUcGUXoEKOpWQcv2UypeiPh4TaLb1+vTB6rEdlIOOQn8Cfk95BQyrNBFyt1GaY4Ol gzKtYZBVRXHo34Z6aTEWMTHRZT51ZRBzC60EpPq6rs6xBRNdEDUe1IVOL9yZucTFRAvD BziwwxOqkE1HhSgld8uQNscaqoLE3ro6c8zEwGZsLpZd37FzEZmRrnT4diZvCXSOofH8 Lb72Wm0pAIwbeE29ybGDj6yLqE6AM4gzBhiBmJA4EKxY/HuAQuqeYogvhn9qrZfRGTq8 f5mgSPgJDfnMOKvNmD/GUCyK/M2yVgiaxCIcCW2M2iZzE5B5RClxMWWUAfG1hx5ZANW3 n4tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12983-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i18-20020aa79092000000b006cbd40b46basi13944030pfa.133.2023.12.29.00.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 00:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12983-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12983-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D03D7B21251 for ; Fri, 29 Dec 2023 08:02:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A64CC6FC4; Fri, 29 Dec 2023 08:02:34 +0000 (UTC) X-Original-To: linux-kernel@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 3C39563BD for ; Fri, 29 Dec 2023 08:02:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2140C433C8; Fri, 29 Dec 2023 08:02:31 +0000 (UTC) From: Huacai Chen To: Baoquan He Cc: Vivek Goyal , Dave Young , Youling Tang , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Huacai Chen Subject: [PATCH] kdump: Defer the insertion of crashkernel resources Date: Fri, 29 Dec 2023 16:02:13 +0800 Message-Id: <20231229080213.2622204-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In /proc/iomem, sub-regions should be inserted after their parent, otherwise the insertion of parent resource fails. But after generic crashkernel reservation applied, in both RISC-V and ARM64 (LoongArch will also use generic reservation later on), crashkernel resources are inserted before their parent, which causes the parent disappear in /proc/iomem. So we defer the insertion of crashkernel resources to an early_initcall(). 1, Without 'crashkernel' parameter: 100d0100-100d01ff : LOON0001:00 100d0100-100d01ff : LOON0001:00 LOON0001:00 100e0000-100e0bff : LOON0002:00 100e0000-100e0bff : LOON0002:00 LOON0002:00 1fe001e0-1fe001e7 : serial 90400000-fa17ffff : System RAM f6220000-f622ffff : Reserved f9ee0000-f9ee3fff : Reserved fa120000-fa17ffff : Reserved fa190000-fe0bffff : System RAM fa190000-fa1bffff : Reserved fe4e0000-47fffffff : System RAM 43c000000-441ffffff : Reserved 47ff98000-47ffa3fff : Reserved 47ffa4000-47ffa7fff : Reserved 47ffa8000-47ffabfff : Reserved 47ffac000-47ffaffff : Reserved 47ffb0000-47ffb3fff : Reserved 2, With 'crashkernel' parameter, before this patch: 100d0100-100d01ff : LOON0001:00 100d0100-100d01ff : LOON0001:00 LOON0001:00 100e0000-100e0bff : LOON0002:00 100e0000-100e0bff : LOON0002:00 LOON0002:00 1fe001e0-1fe001e7 : serial e6200000-f61fffff : Crash kernel fa190000-fe0bffff : System RAM fa190000-fa1bffff : Reserved fe4e0000-47fffffff : System RAM 43c000000-441ffffff : Reserved 47ff98000-47ffa3fff : Reserved 47ffa4000-47ffa7fff : Reserved 47ffa8000-47ffabfff : Reserved 47ffac000-47ffaffff : Reserved 47ffb0000-47ffb3fff : Reserved 3, With 'crashkernel' parameter, after this patch: 100d0100-100d01ff : LOON0001:00 100d0100-100d01ff : LOON0001:00 LOON0001:00 100e0000-100e0bff : LOON0002:00 100e0000-100e0bff : LOON0002:00 LOON0002:00 1fe001e0-1fe001e7 : serial 90400000-fa17ffff : System RAM e6200000-f61fffff : Crash kernel f6220000-f622ffff : Reserved f9ee0000-f9ee3fff : Reserved fa120000-fa17ffff : Reserved fa190000-fe0bffff : System RAM fa190000-fa1bffff : Reserved fe4e0000-47fffffff : System RAM 43c000000-441ffffff : Reserved 47ff98000-47ffa3fff : Reserved 47ffa4000-47ffa7fff : Reserved 47ffa8000-47ffabfff : Reserved 47ffac000-47ffaffff : Reserved 47ffb0000-47ffb3fff : Reserved Signed-off-by: Huacai Chen --- kernel/crash_core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index d4313b53837e..755d8d4ef5b0 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -377,7 +377,6 @@ static int __init reserve_crashkernel_low(unsigned long long low_size) crashk_low_res.start = low_base; crashk_low_res.end = low_base + low_size - 1; - insert_resource(&iomem_resource, &crashk_low_res); #endif return 0; } @@ -459,8 +458,19 @@ void __init reserve_crashkernel_generic(char *cmdline, crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; - insert_resource(&iomem_resource, &crashk_res); } + +static __init int insert_crashkernel_resources(void) +{ + if (crashk_res.start < crashk_res.end) + insert_resource(&iomem_resource, &crashk_res); + + if (crashk_low_res.start < crashk_low_res.end) + insert_resource(&iomem_resource, &crashk_low_res); + + return 0; +} +early_initcall(insert_crashkernel_resources); #endif int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, -- 2.39.3