Received: by 10.192.165.148 with SMTP id m20csp476552imm; Fri, 27 Apr 2018 02:11:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqnOlW8JxLS9I2TW3RTEWPmmqYjHrjwh4V6cWUTB18q0RWFRLQi8c0gIdI3NhVebN52ADkP X-Received: by 2002:a63:9612:: with SMTP id c18-v6mr1420781pge.361.1524820283762; Fri, 27 Apr 2018 02:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524820283; cv=none; d=google.com; s=arc-20160816; b=DQ1oAtrpY7QgKfajWpaDeo+U2jOcYLHHKch0rHf6RMNIqv7bVrb+d/9MVyXyLUGTlL vRpeJzHqCiC3dEKr5Dy69pDC8Ml+aTxDx5ZyuCW3Zk1ADErHaGi45YnNbKTGLht5IY8w Fztsq+hMwmNoSO/aF2bfEGCvsQuvSVUiJdMvtqwog/WMYPruVK9Et9Rjl+uBH49h8dOp yHHCfyreyOSmbNafodmiMXepTlNely7h+/oJXfisvk8Tf0t09IO8s1RFeX3Zt5QjaV4c I4eCGoyTHGbjtJZYMHsQdy66Sdh4ioLVLQ1JIL5V02g+0MZzjzQiAGKLrEC4fLnG2DGb 3vwg== 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:arc-authentication-results; bh=8gCtJp1KW3PSoIMDd4ekmugJd3T+5LMr0IDdOs/k+jE=; b=PLttXGFwIW1pnA7/WWn85lNdpYuMfU+GQ8FE8CL8boSafSI7U3MOlOwCD0z6pPj6Bv Upeev7xUUH0Tn4kOWRQbL3tXr/u3ho4s/paQSFUu0T1wCmUsWyBKRPSim9q9Q3yxURSD 1mE3/nX8AA6ZQzSfNjo4ahLEJ+lF2zU15vrx8E9YVWyfkFKdz+kHyVZSnmvGeYT6pyk4 yUYuSD+y2gk0Znc5MrReLQ7HyW8DYrxZp48FZzbVWJfYRcwIuuwBFcnfE16JXq47Evvz zmM755daFgG2dcGPvEiXF+TUq/t0L7zPn2EpBanNbO2sbX8z5I9H8ZO2+MONFhNlJ8Ty 9KlA== 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 s9-v6si854970pgr.392.2018.04.27.02.11.07; Fri, 27 Apr 2018 02:11:23 -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 S932415AbeD0JJx (ORCPT + 99 others); Fri, 27 Apr 2018 05:09:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932282AbeD0JJv (ORCPT ); Fri, 27 Apr 2018 05:09:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67FC8406C75C; Fri, 27 Apr 2018 09:09:51 +0000 (UTC) Received: from localhost (ovpn-12-63.pek2.redhat.com [10.72.12.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D92B8445F; Fri, 27 Apr 2018 09:09:47 +0000 (UTC) X-Mailbox-Line: From dyoung@redhat.com Fri Apr 27 17:00:45 2018 Message-Id: <20180427090045.532014306@redhat.com> User-Agent: quilt/0.65 Date: Fri, 27 Apr 2018 17:00:37 +0800 From: dyoung@redhat.com To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: bhe@redhat.com, yinghai@kernel.org, akpm@linux-foundation.org, dyoung@redhat.com, vgoyal@redhat.com Subject: [PATCH 1/2] kdump/x86: 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.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 27 Apr 2018 09:09:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 27 Apr 2018 09:09:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dyoung@redhat.com' RCPT:'' 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. 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 @@ -545,6 +545,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;