Received: by 10.223.164.221 with SMTP id h29csp237091wrb; Mon, 23 Oct 2017 22:42:27 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T3BBtrMkICgmLgjmibtGL8Zb213SeG70NSCHoczvZkANY2PX7fSNEhW72mnwPl+rBdy3Aw X-Received: by 10.159.253.9 with SMTP id p9mr4066086pls.344.1508823747249; Mon, 23 Oct 2017 22:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508823747; cv=none; d=google.com; s=arc-20160816; b=NNDZyDXRTLs0d0MQAOM1ktnp+15C5MtGFQfUSb82cz1Z0zOMP9nooSAyXANDyfJOtU 4XlV4OrnBB+h2MSQzWD9gldQjGMxLguw9mvfMa/vBLBfdhciBPRgYQfm9mYHrAO8FnM8 dsY31mhp0Y1yWDr8Kp9nWekzZiuxkgkCtsgRqvqlZ38ce3l71XXOPIQfeX8Ex63A5U9H oPlBoNDGW3hM1A/riOZoSGbUzKmmfWauL5h1/Ff6uYsuEW9NeBmOxibQbJHGL+sVeLUN gJur6m29ahxP2g9jZECV2aALhYXpLygBAZtAmmiuNDi1HfNJ+OdXqBdSOfyHvx7N/2ZL KN2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version:subject :cc:to:from:date:user-agent:message-id:dmarc-filter :arc-authentication-results; bh=LSB4AV8IL5u/u5MNEYk4iMQYzUEH6WuvcgJDZA1IzV0=; b=WvNXX+kOQW1l6b0XTaGOAT+HfOosoCgrLBv99/k1HMdRZi3RzO1g3EfwormOLw5iCo sQfN6h87pzoZDGJp1Tm102f96zbkpeWxplklNcCsbdJ6kDgrZVDuZPl7iHK7Pd5d0aqo kK/Kp1FLI71laRXj2A8JVlr2SJ1vUNwKp4wAzn9Jzo+G3u38Nkjf/5Y24dyVFODADTp5 +D+pXRgQXfUYuRKbzcICl6Z3r5qo1H7d3uEtg7M4ohq3PJtDultRU1vc5gw+p4hA4gJJ u9CXu6BUnUp/eJcdLiAaNepEdv5sW9Ty7J/jIHWhP3jWz0MwmlQ+NFJ1qLbvkPsWW2wF srdg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l30si4946826plg.363.2017.10.23.22.42.13; Mon, 23 Oct 2017 22:42:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbdJXFkr (ORCPT + 99 others); Tue, 24 Oct 2017 01:40:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60788 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751417AbdJXFkX (ORCPT ); Tue, 24 Oct 2017 01:40:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 524BB356D0; Tue, 24 Oct 2017 05:40:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 524BB356D0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dyoung@redhat.com Received: from localhost (ovpn-12-114.pek2.redhat.com [10.72.12.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB7A560BCB; Tue, 24 Oct 2017 05:40:19 +0000 (UTC) X-Mailbox-Line: From dyoung@redhat.com Tue Oct 24 13:39:01 2017 Message-Id: <20171024053901.757504190@redhat.com> User-Agent: quilt/0.65 Date: Tue, 24 Oct 2017 13:31:49 +0800 From: dyoung@redhat.com To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, bhe@redhat.com, vgoyal@redhat.com, yinghai@kernel.org, corbet@lwn.net, dyoung@redhat.com Subject: [PATCH 2/3] X86/kdump: crashkernel=X try to reserve below 896M first then below 4G and MAXMEM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=x86-kdump-crashkernel-X-try-to-reserve-below-896M-fi.patch X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 24 Oct 2017 05:40:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now crashkernel=X will fail if there's not enough memory at low region (below 896M) when trying to reserve large memory size. One can use crashkernel=xM,high to reserve it at high region (>4G) but it is more convinient to improve crashkernel=X to: - First try to reserve X below 896M (for being compatible with old kexec-tools). - If fails, try to reserve X below 4G (swiotlb need to stay below 4G). - If fails, try to reserve X from MAXMEM top down. It's more transparent and user-friendly. If crashkernel is large and the reserved is beyond 896M, old kexec-tools is not compatible with new kernel because old kexec-tools can not load kernel at high memory region, there was an old discussion below: https://lkml.org/lkml/2013/10/15/601 But actually the behavior is consistent during my test. Suppose old kernel fail to reserve memory at low areas, kdump does not work because no meory reserved. With this patch, suppose new kernel successfully reserved memory at high areas, old kexec-tools still fail to load kdump kernel (tested 2.0.2), so it is acceptable, no need to worry about the compatibility. Here is the test result (kexec-tools 2.0.2, no high memory load support): Crashkernel over 4G: # cat /proc/iomem|grep Crash be000000-cdffffff : Crash kernel 213000000-21effffff : Crash kernel # ./kexec -p /boot/vmlinuz-`uname -r` Memory for crashkernel is not reserved Please reserve memory by passing "crashkernel=X@Y" parameter to the kernel Then try loading kdump kernel crashkernel: 896M-4G: # cat /proc/iomem|grep Crash 96000000-cdefffff : Crash kernel # ./kexec -p /boot/vmlinuz-4.14.0-rc4+ ELF core (kcore) parse failed Cannot load /boot/vmlinuz-4.14.0-rc4+ Signed-off-by: Dave Young --- arch/x86/kernel/setup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- linux-x86.orig/arch/x86/kernel/setup.c +++ linux-x86/arch/x86/kernel/setup.c @@ -568,6 +568,22 @@ static void __init reserve_crashkernel(v high ? CRASH_ADDR_HIGH_MAX : CRASH_ADDR_LOW_MAX, crash_size, CRASH_ALIGN); +#ifdef CONFIG_X86_64 + /* + * crashkernel=X reserve below 896M fails? Try below 4G + */ + if (!high && !crash_base) + crash_base = memblock_find_in_range(CRASH_ALIGN, + (1ULL << 32), + crash_size, CRASH_ALIGN); + /* + * crashkernel=X reserve below 4G fails? Try MAXMEM + */ + if (!high && !crash_base) + crash_base = memblock_find_in_range(CRASH_ALIGN, + CRASH_ADDR_HIGH_MAX, + crash_size, CRASH_ALIGN); +#endif if (!crash_base) { pr_info("crashkernel reservation failed - No suitable area found.\n"); return; From 1584100287872842673@xxx Wed Nov 15 03:15:59 +0000 2017 X-GM-THRID: 1584100287872842673 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread