From patchwork Fri Nov 24 19:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 169555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1493890vqx; Fri, 24 Nov 2023 11:58:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDRk143F35QdLb40jbct6k9qspTle2nYssFQ5XGnxGWP13lD0JLmuspbDmypyf/UHlBxF/ X-Received: by 2002:a17:90a:1cd:b0:285:657b:f17a with SMTP id 13-20020a17090a01cd00b00285657bf17amr4113599pjd.15.1700855885105; Fri, 24 Nov 2023 11:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700855885; cv=none; d=google.com; s=arc-20160816; b=Uyh5wvu8QxvgzzPktTEG5ZCT9ZH+RujxcoygzTk5mTC9OEHcxoD4BnRWAUuBlr1WcF khvjyrsteZpl2hEqNWbws6ELrOD4v4JTWKmU7LPJXo3Mk+zoi7ktfhbUQ5nUc/E493K/ RJvFEJIgNk8LZMH5/lBd4RGfpIAWkJfDN97+ZfoMsVIC0CWgAQ0vofF9+vMtBwgSNlYE ohYHj0rq8gha1fj0Jhr2dfTpTfmj3bze1mt+bWMYmKDGEWGcrrr5GEKMY5ETUiUrhPmE /GvZngdiLIwUiNLuY4AUeX7aC90ShNribiG6dOfjj64YPgVu0f6/gK0gEtVa4i0rVxan MITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=W/fT1pLSNri41feNsUCmL949IgVkjP0z0mkUiKdBhCw=; fh=N9iTC4ETbLLv8Qag9but96wYdeum3ovJpDOsbUrbTQg=; b=P2zG2vj/iawYHzZjtVls2cdB7+9Ay+/V+a+YlupR9V6TRgxc66VE1HoE6nePl31UW0 HzScgoryCUMWLxqK1STj4BLPqKAdgBESUjUkVbWyy16IVpYEW6SEYj7hPpfzi82DFwft v1uu+XjsRxSRICCDMRc1c3f+YHo1GYaXS5MQWQxdKjC4DIqFl7JRTKtWv6Hn+n/kMRQH wXy3vpVZWqGt7j3+z7tOoRjxORRsEfVli5du4LRATx89ur6CVs59hHCPUl36FQvriVg+ 8eByPjTEUVMCRXm5HskWTib9NoesppX3Q2wiuGpYGWNVNY1ED7Lo4yqz5Gd+IuJd2I37 JTCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=GyCU9aqN; dkim=neutral (no key) header.i=@suse.cz header.b=BquKKDNf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id oj1-20020a17090b4d8100b00283a09dcce2si4540109pjb.160.2023.11.24.11.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 11:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=GyCU9aqN; dkim=neutral (no key) header.i=@suse.cz header.b=BquKKDNf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 152F981FD9C8; Fri, 24 Nov 2023 11:58:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjKXT5s (ORCPT + 99 others); Fri, 24 Nov 2023 14:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjKXT5q (ORCPT ); Fri, 24 Nov 2023 14:57:46 -0500 X-Greylist: delayed 193 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 24 Nov 2023 11:57:52 PST Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C721710F6 for ; Fri, 24 Nov 2023 11:57:52 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 469591FE89; Fri, 24 Nov 2023 19:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700855871; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=W/fT1pLSNri41feNsUCmL949IgVkjP0z0mkUiKdBhCw=; b=GyCU9aqNKGMA1KdMC57xu14BtLdrUQSTPKe20/CvTYCk74TbAQZKm2diGqUl6kJ9uoh+AZ 0lPJzJFYCZ3VJ7qTMZOELCbZXaXNqheKH5/m6F1L6oKEqYo0NwYUPE7VTrCJLrG33lvYI/ wY5KvEnmClnS0SQ5rRRy2kZGlm5RaSI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700855871; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=W/fT1pLSNri41feNsUCmL949IgVkjP0z0mkUiKdBhCw=; b=BquKKDNfVhyNnLh2p64LgZzw/GK7mILivQI74biCSPeKBsjmm4iDFIjwm+C7BHkVOBXLLw m/2XTBZVbZDkqIAQ== Received: from localhost (dwarf.suse.cz [10.100.12.32]) by relay2.suse.de (Postfix) with ESMTP id 700D72C145; Fri, 24 Nov 2023 19:57:49 +0000 (UTC) Date: Fri, 24 Nov 2023 20:57:49 +0100 From: Jiri Bohac To: Baoquan He , Vivek Goyal , Dave Young , kexec@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.cz Subject: [PATCH 1/4] kdump: add crashkernel cma suffix Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spamd-Bar: ++++++++++++++++++ X-Spam-Score: 18.59 X-Rspamd-Server: rspamd1 X-Rspamd-Queue-Id: 469591FE89 Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=pass (smtp-out2.suse.de: domain of jbohac@suse.cz designates 149.44.160.134 as permitted sender) smtp.mailfrom=jbohac@suse.cz X-Spamd-Result: default: False [18.59 / 50.00]; RDNS_NONE(1.00)[]; BAYES_SPAM(5.10)[100.00%]; SPAMHAUS_XBL(0.00)[149.44.160.134:from]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:149.44.0.0/16:c]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; HFILTER_HELO_IP_A(1.00)[relay2.suse.de]; HFILTER_HELO_NORES_A_OR_MX(0.30)[relay2.suse.de]; RCPT_COUNT_FIVE(0.00)[6]; MID_RHS_MATCH_FROMTLD(0.00)[]; MX_GOOD(-0.01)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RDNS_DNSFAIL(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HOSTNAME_UNKNOWN(2.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 11:58:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783476660525602876 X-GMAIL-MSGID: 1783476660525602876 Add a new optional ",cma" suffix to the crashkernel= command line option. Add a new cma_size parameter to parse_crashkernel(). When not NULL, call __parse_crashkernel to parse the CMA reservation size from "crashkernel=size,cma" and store it in cma_size. Set cma_size to NULL in all calls to parse_crashkernel(). Signed-off-by: Jiri Bohac --- arch/arm/kernel/setup.c | 2 +- arch/arm64/mm/init.c | 2 +- arch/loongarch/kernel/setup.c | 2 +- arch/mips/kernel/setup.c | 2 +- arch/powerpc/kernel/fadump.c | 2 +- arch/powerpc/kexec/core.c | 2 +- arch/powerpc/mm/nohash/kaslr_booke.c | 2 +- arch/riscv/mm/init.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/sh/kernel/machine_kexec.c | 2 +- arch/x86/kernel/setup.c | 2 +- include/linux/crash_core.h | 3 ++- kernel/crash_core.c | 20 ++++++++++++++++---- 13 files changed, 29 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index ff2299ce1ad7..cb940553c757 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1010,7 +1010,7 @@ static void __init reserve_crashkernel(void) total_mem = get_total_mem(); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base, - NULL, NULL); + NULL, NULL, NULL); /* invalid value specified or crashkernel=0 */ if (ret || !crash_size) return; diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 74c1db8ce271..819b8979584c 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -105,7 +105,7 @@ static void __init arch_reserve_crashkernel(void) ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), &crash_size, &crash_base, - &low_size, &high); + &low_size, NULL, &high); if (ret) return; diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index d183a745fb85..0489c8188b83 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -266,7 +266,7 @@ static void __init arch_parse_crashkernel(void) total_mem = memblock_phys_mem_size(); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base, - NULL, NULL); + NULL, NULL, NULL); if (ret < 0 || crash_size <= 0) return; diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 2d2ca024bd47..98afa80ec002 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -456,7 +456,7 @@ static void __init mips_parse_crashkernel(void) total_mem = memblock_phys_mem_size(); ret = parse_crashkernel(boot_command_line, total_mem, &crash_size, &crash_base, - NULL, NULL); + NULL, NULL, NULL); if (ret != 0 || crash_size <= 0) return; diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index d14eda1e8589..6fa5ab01f4e8 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -313,7 +313,7 @@ static __init u64 fadump_calculate_reserve_size(void) * memory at a predefined offset. */ ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), - &size, &base, NULL, NULL); + &size, &base, NULL, NULL, NULL); if (ret == 0 && size > 0) { unsigned long max_size; diff --git a/arch/powerpc/kexec/core.c b/arch/powerpc/kexec/core.c index 85846cadb9b5..c1e0afd94c90 100644 --- a/arch/powerpc/kexec/core.c +++ b/arch/powerpc/kexec/core.c @@ -112,7 +112,7 @@ void __init reserve_crashkernel(void) total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size(); /* use common parsing */ ret = parse_crashkernel(boot_command_line, total_mem_sz, - &crash_size, &crash_base, NULL, NULL); + &crash_size, &crash_base, NULL, NULL, NULL); if (ret == 0 && crash_size > 0) { crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c index b4f2786a7d2b..df083fe158b6 100644 --- a/arch/powerpc/mm/nohash/kaslr_booke.c +++ b/arch/powerpc/mm/nohash/kaslr_booke.c @@ -178,7 +178,7 @@ static void __init get_crash_kernel(void *fdt, unsigned long size) int ret; ret = parse_crashkernel(boot_command_line, size, &crash_size, - &crash_base, NULL, NULL); + &crash_base, NULL, NULL, NULL); if (ret != 0 || crash_size == 0) return; if (crash_base == 0) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 2e011cbddf3a..d0bae97c9a7a 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1355,7 +1355,7 @@ static void __init arch_reserve_crashkernel(void) ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), &crash_size, &crash_base, - &low_size, &high); + &low_size, NULL, &high); if (ret) return; diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 5701356f4f33..4d18b6b8f5ca 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -619,7 +619,7 @@ static void __init reserve_crashkernel(void) int rc; rc = parse_crashkernel(boot_command_line, ident_map_size, - &crash_size, &crash_base, NULL, NULL); + &crash_size, &crash_base, NULL, NULL, NULL); crash_base = ALIGN(crash_base, KEXEC_CRASH_MEM_ALIGN); crash_size = ALIGN(crash_size, KEXEC_CRASH_MEM_ALIGN); diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c index fa3a7b36190a..e754860a7236 100644 --- a/arch/sh/kernel/machine_kexec.c +++ b/arch/sh/kernel/machine_kexec.c @@ -154,7 +154,7 @@ void __init reserve_crashkernel(void) int ret; ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), - &crash_size, &crash_base, NULL, NULL); + &crash_size, &crash_base, NULL, NULL, NULL); if (ret == 0 && crash_size > 0) { crashk_res.start = crash_base; crashk_res.end = crash_base + crash_size - 1; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 1526747bedf2..f271b2cc3054 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -478,7 +478,7 @@ static void __init arch_reserve_crashkernel(void) ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), &crash_size, &crash_base, - &low_size, &high); + &low_size, NULL, &high); if (ret) return; diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index 5126a4fecb44..f1edefcf7377 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -95,7 +95,8 @@ void final_note(Elf_Word *buf); int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base, - unsigned long long *low_size, bool *high); + unsigned long long *low_size, unsigned long long *cma_size, + bool *high); #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE diff --git a/kernel/crash_core.c b/kernel/crash_core.c index efe87d501c8c..1e952d2e451b 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -184,11 +184,13 @@ static int __init parse_crashkernel_simple(char *cmdline, #define SUFFIX_HIGH 0 #define SUFFIX_LOW 1 -#define SUFFIX_NULL 2 +#define SUFFIX_CMA 2 +#define SUFFIX_NULL 3 static __initdata char *suffix_tbl[] = { - [SUFFIX_HIGH] = ",high", - [SUFFIX_LOW] = ",low", - [SUFFIX_NULL] = NULL, + [SUFFIX_HIGH] = ",high", + [SUFFIX_LOW] = ",low", + [SUFFIX_CMA] = ",cma", + [SUFFIX_NULL] = NULL, }; /* @@ -310,9 +312,11 @@ int __init parse_crashkernel(char *cmdline, unsigned long long *crash_size, unsigned long long *crash_base, unsigned long long *low_size, + unsigned long long *cma_size, bool *high) { int ret; + unsigned long long cma_base; /* crashkernel=X[@offset] */ ret = __parse_crashkernel(cmdline, system_ram, crash_size, @@ -343,6 +347,14 @@ int __init parse_crashkernel(char *cmdline, *high = true; } + + /* + * optional CMA reservation + * cma_base is ignored + */ + if (cma_size) + __parse_crashkernel(cmdline, 0, cma_size, + &cma_base, suffix_tbl[SUFFIX_CMA]); #endif if (!*crash_size) ret = -EINVAL; From patchwork Fri Nov 24 19:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 169556 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1494015vqx; Fri, 24 Nov 2023 11:58:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVwe9NKwKYD275tPA+i9K+liTNq4TuiObsn5ZKWFK8po/FiDXK/D1BV7WPHI6NclOpm6tQ X-Received: by 2002:a17:90b:1809:b0:285:64b8:e2fb with SMTP id lw9-20020a17090b180900b0028564b8e2fbmr4391579pjb.28.1700855899997; Fri, 24 Nov 2023 11:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700855899; cv=none; d=google.com; s=arc-20160816; b=KMewzqRGJfn4sN8ZMXJKefeQIXqm+Jm8GsrGKR7Fjd3vtFLCOpS5LS+5VREfjabLNV R08n6u+g1NoqLU0qF7D1q1JjsaSmsUX5exip9tlsp3LBYn/p6g2AJYSIbbLeQprx2EpR +lAsgyG/7TimcGaxWY1CC4EF8jFbvNcwlvf2xxavfWvl87YUKg1WbqeKOl/dD6i7fSYY 9ga0VsO8U3bwth8lfHRkoHtWmWWY0c5Cma8g++eTJcUF2DcKqkgmm7GU8iiYrT+GaYJK zQbgWf0Y4iNcqTgRUU/BNkI0FpnXrKMj92xuz31hTDvy2rARbIqpqAEi2/dSuzmJrHcp jD0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=rL7u06+WD+aE2+8equGsGoE7y/tVOqmNf5x3nllorEI=; fh=N9iTC4ETbLLv8Qag9but96wYdeum3ovJpDOsbUrbTQg=; b=UNiIqQeU93D7094ub8/SbCwArtma22bi7/DE+jQs/u8vRu7uj+go58mgcjvdZZZh0g 1XcOvqrxdVJT/2UTZP7jVas6JBPhNgx4MJ7Fkqd3piUKjuOSRmrYlOXcwqn/4oBVuLh6 hel9mMPmyw8A43stvaa6vHCbwIdUOIJrR0ImvQPU9y8D1F9/Cg7C1odIAlL/rZvLxUs7 ihvYWS07E8T27XL9os3MPcaGP+djQnERomUSg37PEpmNPa6wwJbv3cXy7/BbedxFT90H OOEQrhBJCt5YPpTX4viHOCfBTQv265TTdWeRbZH0O0gIZ931SO4Ni3LR9MEyzFxrv3F2 TGHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KjB4L2sX; dkim=neutral (no key) header.i=@suse.cz header.b=Cw40MhUy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cp21-20020a17090afb9500b0028103a8ad9csi4243557pjb.68.2023.11.24.11.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 11:58:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KjB4L2sX; dkim=neutral (no key) header.i=@suse.cz header.b=Cw40MhUy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8139281FD9D8; Fri, 24 Nov 2023 11:58:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbjKXT6A (ORCPT + 99 others); Fri, 24 Nov 2023 14:58:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbjKXT55 (ORCPT ); Fri, 24 Nov 2023 14:57:57 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF8E1987 for ; Fri, 24 Nov 2023 11:58:04 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CF9B21FE90; Fri, 24 Nov 2023 19:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700855882; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=rL7u06+WD+aE2+8equGsGoE7y/tVOqmNf5x3nllorEI=; b=KjB4L2sXfNur0f/FabkZEkw3kNGcXvWSv11EpyAEscgbnt7t+V11Up9d4mybmigCfOdWmZ jzcbAdjYNx62MzhKVTCJo/ms7tY0yuWDSJcCC4wPEbZEJ3D2+o8UqSNWyZvzEghXELnb20 cl4eUyNKIuxgFdHPU0spXJtUiaGD128= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700855882; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=rL7u06+WD+aE2+8equGsGoE7y/tVOqmNf5x3nllorEI=; b=Cw40MhUyvssBlKCwj8rHAwDqF5hVptjseRaftR9uOGzG+83CzXWkyqoVKylaTxMxO0BzjZ vSPKUofr9NpUDxCQ== Received: from localhost (dwarf.suse.cz [10.100.12.32]) by relay2.suse.de (Postfix) with ESMTP id 103522C145; Fri, 24 Nov 2023 19:58:01 +0000 (UTC) Date: Fri, 24 Nov 2023 20:58:00 +0100 From: Jiri Bohac To: Baoquan He , Vivek Goyal , Dave Young , kexec@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.cz Subject: [PATCH 2/4] kdump: implement reserve_crashkernel_cma Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spamd-Bar: +++++++++++++ X-Spam-Score: 13.49 X-Rspamd-Server: rspamd1 X-Rspamd-Queue-Id: CF9B21FE90 Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=pass (smtp-out2.suse.de: domain of jbohac@suse.cz designates 149.44.160.134 as permitted sender) smtp.mailfrom=jbohac@suse.cz X-Spamd-Result: default: False [13.49 / 50.00]; RDNS_NONE(1.00)[]; SPAMHAUS_XBL(0.00)[149.44.160.134:from]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:149.44.0.0/16:c]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; HFILTER_HELO_IP_A(1.00)[relay2.suse.de]; HFILTER_HELO_NORES_A_OR_MX(0.30)[relay2.suse.de]; RCPT_COUNT_FIVE(0.00)[6]; MID_RHS_MATCH_FROMTLD(0.00)[]; MX_GOOD(-0.01)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RDNS_DNSFAIL(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HOSTNAME_UNKNOWN(2.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 11:58:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783476676249110187 X-GMAIL-MSGID: 1783476676249110187 reserve_crashkernel_cma() reserves CMA ranges for the crash kernel. If allocating the requested size fails, try to reserve in smaller pieces. Store the reserved ranges in the crashk_cma_ranges array and the number of ranges in crashk_cma_cnt. Signed-off-by: Jiri Bohac --- include/linux/crash_core.h | 9 +++++++ kernel/crash_core.c | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index f1edefcf7377..5afe3866d35a 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -14,6 +14,13 @@ extern struct resource crashk_res; extern struct resource crashk_low_res; +extern struct range crashk_cma_ranges[]; +#ifdef CONFIG_CMA +extern int crashk_cma_cnt; +#else +#define crashk_cma_cnt 0 +#endif + #define CRASH_CORE_NOTE_NAME "CORE" #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) #define CRASH_CORE_NOTE_NAME_BYTES ALIGN(sizeof(CRASH_CORE_NOTE_NAME), 4) @@ -98,6 +105,8 @@ int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, unsigned long long *low_size, unsigned long long *cma_size, bool *high); +void __init reserve_crashkernel_cma(unsigned long long cma_size); + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 1e952d2e451b..d71ecd59f16b 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -475,6 +476,57 @@ void __init reserve_crashkernel_generic(char *cmdline, } #endif +#ifdef CONFIG_CMA +#define CRASHKERNEL_CMA_RANGES_MAX 4 + +struct range crashk_cma_ranges[CRASHKERNEL_CMA_RANGES_MAX]; +int crashk_cma_cnt = 0; + +void __init reserve_crashkernel_cma(unsigned long long cma_size) +{ + unsigned long long request_size = roundup(cma_size, PAGE_SIZE); + unsigned long long reserved_size = 0; + + while (cma_size > reserved_size && + crashk_cma_cnt < CRASHKERNEL_CMA_RANGES_MAX) { + + struct cma *res; + + if (cma_declare_contiguous(0, request_size, 0, 0, 0, false, + "crashkernel", &res)) { + /* reservation failed, try half-sized blocks */ + if (request_size <= PAGE_SIZE) + break; + + request_size = roundup(request_size / 2, PAGE_SIZE); + continue; + } + + crashk_cma_ranges[crashk_cma_cnt].start = cma_get_base(res); + crashk_cma_ranges[crashk_cma_cnt].end = + crashk_cma_ranges[crashk_cma_cnt].start + + cma_get_size(res) - 1; + ++crashk_cma_cnt; + reserved_size += request_size; + } + + if (cma_size > reserved_size) + pr_warn("crashkernel CMA reservation failed: %lld MB requested, %lld MB reserved in %d ranges\n", + cma_size >> 20, reserved_size >> 20, crashk_cma_cnt); + else + pr_info("crashkernel CMA reserved: %lld MB in %d ranges\n", + reserved_size >> 20, crashk_cma_cnt); +} + +#else /* CONFIG_CMA */ +struct range crashk_cma_ranges[0]; +void __init reserve_crashkernel_cma(unsigned long long cma_size) +{ + if (cma_size) + pr_warn("crashkernel CMA reservation failed: CMA disabled\n"); +} +#endif + int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, void **addr, unsigned long *sz) { From patchwork Fri Nov 24 19:58:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 169557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1494155vqx; Fri, 24 Nov 2023 11:58:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1CO/6xUvkTCjcIrXZ70/5U2OQa+/0MIl2wNLRiCkxx3RPCULgj6h/nGgafu+8ewhAFDky X-Received: by 2002:a05:6a20:4413:b0:187:ef24:358 with SMTP id ce19-20020a056a20441300b00187ef240358mr5235630pzb.60.1700855922874; Fri, 24 Nov 2023 11:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700855922; cv=none; d=google.com; s=arc-20160816; b=0iKy5kRK9OiNOsOWoYdyQYUrbciXwBuCb+DMKRrut41asx7UPtwiacNNXArTBCKuI+ m0wnk7M1vZ20nj5nzmb8/hBSUjhO5vnX7tvJYA7TjJrFMazOH+tPYZ0rD1RvQAL4P0g6 CGeXfvaX9YMNkB8YvHgiNyJxkHdhiry+Lcid43QgbADqjw9twBUykSCAYrgO2ksT5Fe3 5hZ75KaEIUFv5o0zWCqtYLcKHdbOKOxMo6xaWYcQgEk9n2aWUODGV9M1l47Ij4Fb/GS2 FapQ43Ftqjsj/qdA/jlbiRHqDezgSPQb7KkAbpyqRJO7fa5oNm6Je7CUo2ghl5vog1aJ vjjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=DjYte/Mctgmrrgkn7xRs0TNg9KtN5CCgmihnS5E7cF0=; fh=N9iTC4ETbLLv8Qag9but96wYdeum3ovJpDOsbUrbTQg=; b=Q/UzF4Jf/5K1sjkgFWuFXDvB+u1GXB8mQL6TfcKs+VQZvRI9ouA3Cbp5uJJRDG1oUj r9xM9jlxb5vnyoq8/KMVN3SXhwO3qhNurNEcMn3XVZXENrkxaKBLJybR4CGMsoQPwwXA ApueGxIq2FNNU2xLlYdJoeWr5z+ipvozs2c2YYkxqX4+IHirLvplPRlc0j2Bjzz0lHrS k3b2405SsLBbLKDmzensBDD4NIz4DNn5uQVYAxzlhsPpQVIL3IsxAhGiZSl4ms40PFXK dhZLmt0zjO71tqVJaDzcMLzwo5pGPznf29k5IgbeGZJkEypARVELKUdDjC0bWUf9Ya05 9+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=x3vw6TRK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ck8OiKFW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id e64-20020a636943000000b005be1f94caddsi4037910pgc.799.2023.11.24.11.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 11:58:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=x3vw6TRK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=Ck8OiKFW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 16CF281FD9E9; Fri, 24 Nov 2023 11:58:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbjKXT6X (ORCPT + 99 others); Fri, 24 Nov 2023 14:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235301AbjKXT6P (ORCPT ); Fri, 24 Nov 2023 14:58:15 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1EC410F6 for ; Fri, 24 Nov 2023 11:58:19 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 7AC9E1FE92; Fri, 24 Nov 2023 19:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700855897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=DjYte/Mctgmrrgkn7xRs0TNg9KtN5CCgmihnS5E7cF0=; b=x3vw6TRKweflrN4jq3gzp3J9Tztzz4CQziwkjFOyLDOcJMkJCYreg4s0xWi6VQBNZeKtQ/ /y26yDCppJ10wNdUceaJ2b8ActKsmL0moHrpyWywvWA/YiBLe7qp5YVzYxMJXvA0Ctjnrd CSXJSi/gSxWqbPoJN0SthoNqDQJ47M4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700855897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=DjYte/Mctgmrrgkn7xRs0TNg9KtN5CCgmihnS5E7cF0=; b=Ck8OiKFWRsiMDMq2mcW+F9tuCIjeoPI8IvWNGjGnlf1WtSRe2LqBreR/KPm80RPA57LvsH I+m8Wr0EkGTW1UDw== Received: from localhost (dwarf.suse.cz [10.100.12.32]) by relay2.suse.de (Postfix) with ESMTP id 8DC052C145; Fri, 24 Nov 2023 19:58:16 +0000 (UTC) Date: Fri, 24 Nov 2023 20:58:16 +0100 From: Jiri Bohac To: Baoquan He , Vivek Goyal , Dave Young , kexec@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.cz Subject: [PATCH 3/4] kdump, x86: implement crashkernel CMA reservation Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spamd-Bar: +++++++++++++ X-Spam-Score: 13.49 X-Rspamd-Server: rspamd1 X-Rspamd-Queue-Id: 7AC9E1FE92 Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=pass (smtp-out2.suse.de: domain of jbohac@suse.cz designates 149.44.160.134 as permitted sender) smtp.mailfrom=jbohac@suse.cz X-Spamd-Result: default: False [13.49 / 50.00]; RDNS_NONE(1.00)[]; SPAMHAUS_XBL(0.00)[149.44.160.134:from]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:149.44.0.0/16:c]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; HFILTER_HELO_IP_A(1.00)[relay2.suse.de]; HFILTER_HELO_NORES_A_OR_MX(0.30)[relay2.suse.de]; RCPT_COUNT_FIVE(0.00)[6]; MID_RHS_MATCH_FROMTLD(0.00)[]; MX_GOOD(-0.01)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RDNS_DNSFAIL(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HOSTNAME_UNKNOWN(2.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 24 Nov 2023 11:58:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783476700276921947 X-GMAIL-MSGID: 1783476700276921947 Implement the crashkernel CMA reservation for x86: - enable parsing of the cma suffix by parse_crashkernel() - reserve memory with reserve_crashkernel_cma() - add the CMA-reserved ranges to the e820 map for the crash kernel - exclude the CMA-reserved ranges from vmcore Signed-off-by: Jiri Bohac --- arch/x86/kernel/crash.c | 26 ++++++++++++++++++++++---- arch/x86/kernel/setup.c | 5 +++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c92d88680dbf..f27d09386157 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -147,10 +147,10 @@ static struct crash_mem *fill_up_crash_elf_data(void) return NULL; /* - * Exclusion of crash region and/or crashk_low_res may cause - * another range split. So add extra two slots here. + * Exclusion of crash region, crashk_low_res and/or crashk_cma_ranges + * may cause range splits. So add extra slots here. */ - nr_ranges += 2; + nr_ranges += 2 + crashk_cma_cnt; cmem = vzalloc(struct_size(cmem, ranges, nr_ranges)); if (!cmem) return NULL; @@ -168,6 +168,7 @@ static struct crash_mem *fill_up_crash_elf_data(void) static int elf_header_exclude_ranges(struct crash_mem *cmem) { int ret = 0; + int i; /* Exclude the low 1M because it is always reserved */ ret = crash_exclude_mem_range(cmem, 0, (1<<20)-1); @@ -182,8 +183,17 @@ static int elf_header_exclude_ranges(struct crash_mem *cmem) if (crashk_low_res.end) ret = crash_exclude_mem_range(cmem, crashk_low_res.start, crashk_low_res.end); + if (ret) + return ret; - return ret; + for (i = 0; i < crashk_cma_cnt; ++i) { + ret = crash_exclude_mem_range(cmem, crashk_cma_ranges[i].start, + crashk_cma_ranges[i].end); + if (ret) + return ret; + } + + return 0; } static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) @@ -336,6 +346,14 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) add_e820_entry(params, &ei); } + for (i = 0; i < crashk_cma_cnt; ++i) { + ei.addr = crashk_cma_ranges[i].start; + ei.size = crashk_cma_ranges[i].end - + crashk_cma_ranges[i].start + 1; + ei.type = E820_TYPE_RAM; + add_e820_entry(params, &ei); + } + out: vfree(cmem); return ret; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f271b2cc3054..5994d18fd2a0 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -468,7 +468,7 @@ static void __init memblock_x86_reserve_range_setup_data(void) static void __init arch_reserve_crashkernel(void) { - unsigned long long crash_base, crash_size, low_size = 0; + unsigned long long crash_base, crash_size, low_size = 0, cma_size = 0; char *cmdline = boot_command_line; bool high = false; int ret; @@ -478,7 +478,7 @@ static void __init arch_reserve_crashkernel(void) ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), &crash_size, &crash_base, - &low_size, NULL, &high); + &low_size, &cma_size, &high); if (ret) return; @@ -489,6 +489,7 @@ static void __init arch_reserve_crashkernel(void) reserve_crashkernel_generic(cmdline, crash_size, crash_base, low_size, high); + reserve_crashkernel_cma(cma_size); } static struct resource standard_io_resources[] = { From patchwork Fri Nov 24 19:58:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Bohac X-Patchwork-Id: 169558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1494242vqx; Fri, 24 Nov 2023 11:58:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrG3HuyHk016764iuTUn6ScxGDA9HRlpPrpTJr8wdo/HkwNGwYxsF2aYvEqIksBD0nCpih X-Received: by 2002:a17:902:9883:b0:1cf:9420:4e6c with SMTP id s3-20020a170902988300b001cf94204e6cmr3757336plp.36.1700855933728; Fri, 24 Nov 2023 11:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700855933; cv=none; d=google.com; s=arc-20160816; b=S4L08KmlgQkvtcZcKRlo9pqHQUETDbvG9+Og8BjEAAT0jI4tw7it1pRf6B/y6WoXWD XNwTMCgM6ow2kKTSV8/Nmq5GcYQPfveqWVpYBSt/go+YbWR0S8uMKSHnYVfBA/K96mjy 1/qC6nPrVInnebnK1TpEIY+A13c4WcOPGjXsbTcKRcN5Lff5y+PRg06nyfDqDptp+Hp/ 0GOoaC510K/AcAN0+XH1GUwKXjfxA2J0LZN2arhhMdp25fQEzx3nGt0Iic3JtJnQkMbI Z6x+r0I9qQY5GExOR+wN4ZEfESOxOkRlTF7cTKo0qnfnuGFRww3ernk73UYX18RruO+K zqxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=qGzEJ9/paLrY7yN9mHnVDrutfQTfMGd2dXLSP1MKgTo=; fh=N9iTC4ETbLLv8Qag9but96wYdeum3ovJpDOsbUrbTQg=; b=s89ngylDDZHsQMkkzwAah9FctQ+yVgahZo5gRtRv93MGqrqAtIOt1To6VZwfZhtM7L L+SGp/8k41r3JTNQ0iHZGZSOKPy2EbXvwhjlAuNzLZtpZ17qwcYNAsoHR7Zk6X8RdqK8 lQYFIEyo1HLfDtzIyLttx6b69z30THTzgQ3RtdTD0um+J+ao9aHQbZy581FmTpMB/J6g 99oKlBIMuKo+VPhUvYIPNGHAz9csE8cB6EQVKnXPW4MqIBOmQ+VgEWHBtbVbdgmEJQ20 JUG/+viFYBtznVFYQ7O22V6VrifxOIIrhnWKzxyYf6RjwrDVFpO8pAxxQQTBa814U8GU RO+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LQLyN4VF; dkim=neutral (no key) header.i=@suse.cz header.b=6N1XaEBp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id jw11-20020a170903278b00b001c624237977si4005095plb.252.2023.11.24.11.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 11:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=LQLyN4VF; dkim=neutral (no key) header.i=@suse.cz header.b=6N1XaEBp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4C9458277E75; Fri, 24 Nov 2023 11:58:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346081AbjKXT6e (ORCPT + 99 others); Fri, 24 Nov 2023 14:58:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232995AbjKXT6W (ORCPT ); Fri, 24 Nov 2023 14:58:22 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E92172A for ; Fri, 24 Nov 2023 11:58:28 -0800 (PST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 476CF1FE8F; Fri, 24 Nov 2023 19:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700855907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=qGzEJ9/paLrY7yN9mHnVDrutfQTfMGd2dXLSP1MKgTo=; b=LQLyN4VFubhseBPaSDv3sIMpCKyboHj3200tSV7VZiT2UHjBEltrsuDHzL43nvNBiYZTTZ iwLzxf3sxhCN4ljw+PfEzCPGByK/j1R6NIZ3/KzzhiDFD60wm+UvbdJflOvhrQG3nb2UaD cCdbkHkYvxoS91LEfTeebcj0m6aE3mQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700855907; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=qGzEJ9/paLrY7yN9mHnVDrutfQTfMGd2dXLSP1MKgTo=; b=6N1XaEBpIJeFMnj/coakTwo4OtVDr1qA17zfdgNfSB5diJTD0EwzWrvRhafTW9pU1Y0b7j HutLmei93GtJBKDw== Received: from localhost (dwarf.suse.cz [10.100.12.32]) by relay2.suse.de (Postfix) with ESMTP id 679982C145; Fri, 24 Nov 2023 19:58:25 +0000 (UTC) Date: Fri, 24 Nov 2023 20:58:25 +0100 From: Jiri Bohac To: Baoquan He , Vivek Goyal , Dave Young , kexec@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.cz Subject: [PATCH 4/4] kdump, documentation: describe craskernel CMA reservation Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spamd-Bar: +++++++++++++ X-Spam-Score: 13.49 X-Rspamd-Server: rspamd1 X-Rspamd-Queue-Id: 476CF1FE8F Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=pass (smtp-out2.suse.de: domain of jbohac@suse.cz designates 149.44.160.134 as permitted sender) smtp.mailfrom=jbohac@suse.cz X-Spamd-Result: default: False [13.49 / 50.00]; RDNS_NONE(1.00)[]; SPAMHAUS_XBL(0.00)[149.44.160.134:from]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:149.44.0.0/16:c]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; HFILTER_HELO_IP_A(1.00)[relay2.suse.de]; HFILTER_HELO_NORES_A_OR_MX(0.30)[relay2.suse.de]; RCPT_COUNT_FIVE(0.00)[6]; MID_RHS_MATCH_FROMTLD(0.00)[]; MX_GOOD(-0.01)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RDNS_DNSFAIL(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.cz]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HOSTNAME_UNKNOWN(2.50)[] X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 24 Nov 2023 11:58:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783476711456263013 X-GMAIL-MSGID: 1783476711456263013 Describe the new crashkernel ",cma" suffix in Documentation/ --- Documentation/admin-guide/kdump/kdump.rst | 10 ++++++++++ Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst index 5762e7477a0c..4ec08e5843dc 100644 --- a/Documentation/admin-guide/kdump/kdump.rst +++ b/Documentation/admin-guide/kdump/kdump.rst @@ -317,6 +317,16 @@ crashkernel syntax crashkernel=0,low +4) crashkernel=size,cma + + Reserves additional memory from CMA. A standard crashkernel reservation, as + described above, is still needed, but can be just small enough to hold the + kernel and initrd. All the memory the crash kernel needs for its runtime and + for running the kdump userspace processes can be provided by this CMA + reservation, re-using memory available to the production system's userspace. + Because of this re-using, the CMA reservation should not be used if it's + intended to dump userspce memory. + Boot into System Kernel ----------------------- 1) Update the boot loader (such as grub, yaboot, or lilo) configuration diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 65731b060e3f..ee9fc40a97fd 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -914,6 +914,13 @@ 0: to disable low allocation. It will be ignored when crashkernel=X,high is not used or memory reserved is below 4G. + crashkernel=size[KMG],cma + [KNL, X86] Reserve additional crash kernel memory from CMA. + This reservation is usable by the 1st system's userspace, + so this should not be used if dumping of userspace + memory is intended. A standard crashkernel reservation, + as described above, is still needed to hold the crash + kernel and initrd. cryptomgr.notests [KNL] Disable crypto self-tests