Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7035640ybi; Thu, 13 Jun 2019 08:29:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFkrurw3kKOFqUm6gpIDdW1fyS8fXR19/AXQo7+Qmcz3ttpxU9xoKBRLupjuLmfwL+VbFA X-Received: by 2002:a62:5105:: with SMTP id f5mr93846177pfb.127.1560439799009; Thu, 13 Jun 2019 08:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560439799; cv=none; d=google.com; s=arc-20160816; b=Ev2PAeBiydq1CP0NA+Amc4Ybh6OAPOJsmRA9bSooL33MfKcD3O6M7zcBJiIWWUyRxt xU1W7ys6UaANaDkxWk+9ggRZNgzOM256n5ThDzjXBisCtLaoQglzRZYRu0+AQt64YOvP kp6m4XUgJcYCGRgBh7O9DQYUhxJwDnItQ13/VJteRbbbfiRLgnfHL+w0/+V8BFuhB2PH vT2Tjq+VRZwhNKeu7u3VtYsfgaXHbCc21S8jlBp0sXt8pfuokg6yS5SP1WX8MbTwxbFd zHqhkCVCX+9EpOD8ySIqMaQ6XxhAGm+DSv3dqGOiSZYOPNgW+gEhKr8giF/M9kh80OfD YxAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=XP/LhBbf874xTDg1xV3WubxGK3gwdlGrut26QScYZtA=; b=S/cJldFGg3AdFilV2f1YDYT+NM5hpRTDgTXL8DnAY0nt4EfjEC1AtxhNtqL2cNYK3e T3hAxFOj1LQdJS8BrUPFh6ByDpdF/sCTyRpj0FlTEvQBE20DmFlkLEsofvlj0kNeJ1jt tiYEMjDGKB43aJH+rnMXHgdXIlbuYPiBbvyJNTbbsACD1SQUg227xTsPtRpAX9O6GMUj Ux+lXucTn0yWLJb+n+KP2vhjtplycwIjsQqFg0J1Dmlmvcug3rrxRYGVNndgp25vxA+h N5ANak/zp+PhOf6pzuAiyWa4vpR4DQfN7AOU4HGtcey+YcqHJREhigz0dDcV3H6qU8+8 JUGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si3265299plr.323.2019.06.13.08.29.43; Thu, 13 Jun 2019 08:29:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730918AbfFMP2r (ORCPT + 99 others); Thu, 13 Jun 2019 11:28:47 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33758 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727014AbfFML1M (ORCPT ); Thu, 13 Jun 2019 07:27:12 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3EE9C84A0E22CFC1DCFB; Thu, 13 Jun 2019 19:27:10 +0800 (CST) Received: from [127.0.0.1] (10.177.131.64) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Thu, 13 Jun 2019 19:26:59 +0800 Subject: Re: [PATCH 1/4] x86: kdump: move reserve_crashkernel_low() into kexec_core.c To: James Morse References: <20190507035058.63992-1-chenzhou10@huawei.com> <20190507035058.63992-2-chenzhou10@huawei.com> <6585f047-063c-6d6c-4967-1d8a472f30f4@arm.com> CC: , , , , , , , , , , , , , , , From: Chen Zhou Message-ID: <4716a864-9560-f198-5899-9a5dee1fac20@huawei.com> Date: Thu, 13 Jun 2019 19:26:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <6585f047-063c-6d6c-4967-1d8a472f30f4@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.131.64] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, Thanks for your review. On 2019/6/6 0:29, James Morse wrote: > Hello, > > On 07/05/2019 04:50, Chen Zhou wrote: >> In preparation for supporting reserving crashkernel above 4G >> in arm64 as x86_64 does, move reserve_crashkernel_low() into >> kexec/kexec_core.c. > > >> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c >> index 905dae8..9ee33b6 100644 >> --- a/arch/x86/kernel/setup.c >> +++ b/arch/x86/kernel/setup.c >> @@ -463,59 +460,6 @@ static void __init memblock_x86_reserve_range_setup_data(void) >> # define CRASH_ADDR_HIGH_MAX MAXMEM >> #endif >> >> -static int __init reserve_crashkernel_low(void) >> -{ >> -#ifdef CONFIG_X86_64 > > The behaviour of this #ifdef has disappeared, won't 32bit x86 now try and reserve a chunk > of unnecessary 'low' memory? > > [...] At present, reserve_crashkernel_low() is called only when reserving crashkernel above 4G, so i deleted this #ifdef. If we called reserve_crashkernel_low() at the beginning of reserve_crashkernel(), i need to add it back. > > >> @@ -579,9 +523,13 @@ static void __init reserve_crashkernel(void) >> return; >> } >> >> - if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) { >> - memblock_free(crash_base, crash_size); >> - return; >> + if (crash_base >= (1ULL << 32)) { >> + if (reserve_crashkernel_low()) { >> + memblock_free(crash_base, crash_size); >> + return; >> + } >> + >> + insert_resource(&iomem_resource, &crashk_low_res); > > > Previously reserve_crashkernel_low() was #ifdefed to do nothing if !CONFIG_X86_64, I don't > see how 32bit is skipping this reservation... > > >> } >> >> pr_info("Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n", >> diff --git a/include/linux/kexec.h b/include/linux/kexec.h >> index b9b1bc5..096ad63 100644 >> --- a/include/linux/kexec.h >> +++ b/include/linux/kexec.h >> @@ -63,6 +63,10 @@ >> >> #define KEXEC_CORE_NOTE_NAME CRASH_CORE_NOTE_NAME >> >> +#ifndef CRASH_ALIGN >> +#define CRASH_ALIGN SZ_128M >> +#endif > > Why 128M? Wouldn't we rather each architecture tells us its minimum alignment? Yeah, each architecture should tells us its minimum alignment. I added this default size to fix compiling error on some architecture which didn't define it. I will add x86_64 and arm64 restriction on reserve_crashkernel_low() and delete this define. > > >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index d714044..3492abd 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c >> @@ -39,6 +39,8 @@ >> #include >> #include >> #include >> +#include >> +#include >> >> #include >> #include >> @@ -96,6 +98,60 @@ int kexec_crash_loaded(void) >> } >> EXPORT_SYMBOL_GPL(kexec_crash_loaded); >> >> +int __init reserve_crashkernel_low(void) >> +{ >> + unsigned long long base, low_base = 0, low_size = 0; >> + unsigned long total_low_mem; >> + int ret; >> + >> + total_low_mem = memblock_mem_size(1UL << (32 - PAGE_SHIFT)); >> + >> + /* crashkernel=Y,low */ >> + ret = parse_crashkernel_low(boot_command_line, total_low_mem, >> + &low_size, &base); >> + if (ret) { >> + /* >> + * two parts from lib/swiotlb.c: >> + * -swiotlb size: user-specified with swiotlb= or default. >> + * >> + * -swiotlb overflow buffer: now hardcoded to 32k. We round it >> + * to 8M for other buffers that may need to stay low too. Also >> + * make sure we allocate enough extra low memory so that we >> + * don't run out of DMA buffers for 32-bit devices. >> + */ >> + low_size = max(swiotlb_size_or_default() + (8UL << 20), > > SZ_8M? > >> + 256UL << 20); > > SZ_256M? > There is compiling warning "warning: comparison of distinct pointer types lacks a cast" if just use SZ_8M or SZ_256M. We need cast swiotlb_size_or_default() to type int,so i kept the old as in x86_64. > >> + } else { >> + /* passed with crashkernel=0,low ? */ >> + if (!low_size) >> + return 0; >> + } >> + >> + low_base = memblock_find_in_range(0, 1ULL << 32, low_size, CRASH_ALIGN); >> + if (!low_base) { >> + pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n", >> + (unsigned long)(low_size >> 20)); >> + return -ENOMEM; >> + } >> + >> + ret = memblock_reserve(low_base, low_size); >> + if (ret) { >> + pr_err("%s: Error reserving crashkernel low memblock.\n", >> + __func__); >> + return ret; >> + } >> + >> + pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n", >> + (unsigned long)(low_size >> 20), >> + (unsigned long)(low_base >> 20), >> + (unsigned long)(total_low_mem >> 20)); >> + >> + crashk_low_res.start = low_base; >> + crashk_low_res.end = low_base + low_size - 1; >> + >> + return 0; >> +} > > > Thanks, > > James > > . > Thanks, Chen Zhou