Received: by 10.223.164.221 with SMTP id h29csp2852003wrb; Thu, 2 Nov 2017 19:47:30 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SwO/Pe/iqHJOMVluHSd8BsFoEj863P5u/f2cG/8lfYIz60zcI6xwQMRUrheB5dy0QZ2V+E X-Received: by 10.84.242.74 with SMTP id c10mr5468123pll.141.1509677250604; Thu, 02 Nov 2017 19:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509677250; cv=none; d=google.com; s=arc-20160816; b=DpS5nhWTtc9kiEm+8H2iFgF4UkKU5u5vpdtaK1s4DubQRnbz9x5OFYwxdYcc+Rp2Q3 NKUjcC3OclcD19YlH9dTDpVAIG+HZyygXnPueaPUgIekgFkCEGA6HMn2QG/3vv3PZOYI ffwrFnHYORfUHmnFfRp5G0HSRcncj6jK4QYcsB3MBL81ZLMkjnk7zo/ENhVcKd675zyY ntQq1ZwPKBHm6eyh9Gx713DKcGOVDJ/mpVPsAm5hZ3oq3AdwMvw4hXaIYdKJNXv92Z+F tRE1sbYN+shu6+TBzIfw/fD7DUTy1Di/LIJKSnUD4HkltYu/MX+L2qezITAtQnx3T2Ai 9bLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=GIIeBLwZpXIbZDglrbJ5/GVLlCvU1ExIOsnqj2A0twQ=; b=Rin9B08C5n2y9aQMwEPHvMRtdOmhn3WxiYShQupgOTjPTIcxGGbEPOpK04bMdi2bi/ /w7oSpiAz7flLGk4b3DqCuLggb5F69w9gVBEJpvVSY+9jOSCVHxfYKmZqn0dG2y2yg6Z 6JQHbclO1xBAVsM5GcMRbvDe5UMVzNqe1B/OVTLgH8LHFX2ptRQ5anuTh3+qa1pp3j6S H1LlWpCp5Oc/13shHgrT2ERCSsweWatSGGm85EEqJkkQJby5EzazznG8sWdO4XNPJSOU Oi5/vphm4ws4yKZO4CRwNHdt072HjOF++07k0/wYqSfj25Ohly07LfJ9+P5u7riJCote eJLw== 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 t85si4741368pgb.258.2017.11.02.19.47.17; Thu, 02 Nov 2017 19:47:30 -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 S965084AbdKCCqc (ORCPT + 96 others); Thu, 2 Nov 2017 22:46:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34820 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751507AbdKCCqb (ORCPT ); Thu, 2 Nov 2017 22:46:31 -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 C462185376; Fri, 3 Nov 2017 02:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C462185376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dyoung@redhat.com Received: from dhcp-128-65.nay.redhat.com (ovpn-12-72.pek2.redhat.com [10.72.12.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 506FB60478; Fri, 3 Nov 2017 02:46:27 +0000 (UTC) Date: Fri, 3 Nov 2017 10:46:22 +0800 From: Dave Young To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: bhe@redhat.com, corbet@lwn.net, yinghai@kernel.org, akpm@linux-foundation.org, vgoyal@redhat.com, bhsharma@redhat.com Subject: [PATCH 3/3 update] kdump: round up the total memory size to 128M for crashkernel reservation Message-ID: <20171103024622.GA5584@dhcp-128-65.nay.redhat.com> References: <20171024053901.813846011@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171024053901.813846011@redhat.com> User-Agent: Mutt/1.8.3 (2017-05-23) 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.25]); Fri, 03 Nov 2017 02:46:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The total memory size we get in kernel is usually slightly less than 2G with a 2G memory module machine. The main reason is bios/firmware reserve some area it will not export all memory as usable to Linux. 2G memory X86 kvm guest test result of the total_mem value: UEFI boot with ovmf: 0x7ef10000 Legacy boot kvm guest: 0x7ff7cc00 This is also a problem on arm64 UEFI booted system according to my test. Thus for example crashkernel=1G-2G:128M, if we have a 1G memory machine, we get total size 1023M from firmware then it will not fall into 1G-2G thus no memory reserved. An option is to use dmi/smbios to get physical memory size, but it's not reliable as well. According to Prarit hardware vendors sometimes screw this up. Thus round up total size to 128M to workaround this problem. Signed-off-by: Dave Young --- Changes from previous version of 3/3: 1. improve changelog: add examples why this is a problem (comment from Baoquan He) 2. change to use SZ_128M (comment from Bhupesh Sharma) kernel/crash_core.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- linux-x86.orig/kernel/crash_core.c +++ linux-x86/kernel/crash_core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,15 @@ static int __init parse_crashkernel_mem( { char *cur = cmdline, *tmp; bool infinite_end = false; + unsigned long long total_mem = system_ram; + + /* + * Firmware usually reserves some memory regions for it's own use. + * so we get less than actual system memory size. + * We workaround this by round up the total size to 128M which is + * enough for most test cases. + */ + total_mem = roundup(total_mem, SZ_128M); /* for each entry of the comma-separated list */ do { @@ -86,13 +96,13 @@ static int __init parse_crashkernel_mem( return -EINVAL; } cur = tmp; - if (size >= system_ram) { + if (size >= total_mem) { pr_warn("crashkernel: invalid size\n"); return -EINVAL; } /* match ? */ - if (system_ram >= start && system_ram < end) { + if (total_mem >= start && total_mem < end) { *crash_size = size; if (end == ULLONG_MAX) infinite_end = true; @@ -126,9 +136,9 @@ static int __init parse_crashkernel_mem( pr_warn("Memory reservation scale order expected after '^'\n"); return -EINVAL; } - size = (system_ram - *crash_size) >> shift; + size = (total_mem - *crash_size) >> shift; size = *crash_size + roundup(size, 1ULL << 20); - if (size < system_ram) + if (size < total_mem) *crash_size = size; cur = tmp; } else From 1582847415761532239@xxx Wed Nov 01 07:22:07 +0000 2017 X-GM-THRID: 1582116367860828786 X-Gmail-Labels: Inbox,Category Forums