Received: by 10.223.164.221 with SMTP id h29csp237068wrb; Mon, 23 Oct 2017 22:42:25 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T4rZt1xrSAt+J2IJUyX2gUuJ8E9ovkOK2HYGFiE5G+7aMvh3t59kQzdSYEPpqVd+XGrhwD X-Received: by 10.101.66.197 with SMTP id l5mr827253pgp.240.1508823745599; Mon, 23 Oct 2017 22:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508823745; cv=none; d=google.com; s=arc-20160816; b=o1vlnGCeGVkfNtfiqw5ytUHMLKFh9rOmyq72Pn8rnHMmL5URtWSuYTALDVRUymR5Qj ITS1PUFZL3h21O9xHmtBMLg5rGCl40zTzOLtwaUz9JmJ/4ksKLK72FBVmEoy9sxz908D Ff89wmaxqVZKSOEzGSvkcotfMWQLyK1HcKoh5NQ9TQm/E12iP5kqvKy4Vom5Nfx+ec6X 8Ra8t6RHP/dGrCYgEkoB+4gIzrA8SQ0z9BWcl4zHmxl1BNK65u4l6HEN97DxhuHn1mOe FSf4mlk1KK+7Tmdc/NFcuJPZJZNvTMsAzdNbn2deRoCG4K1/NHjn6uCvqu8b3h47KjVQ NJ8A== 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=a4NpTg/tM+sEoqoBylV9gcKtRsh/BDG2EZgkrbfYIos=; b=dvsM89YpihDlBBeMKZqlRriHxJ9c9l5FSP4Pdqq4ugqeJNmBfHErkqfRKS617JRSF0 bVOSpoR4GXjK6PRFMX3XNa6+RreHWy7n00bCH67jzxNWLhUlHMGVOKFbhMgqtdYguCCz u41xRua4klORZBd21G5tiANWR2vrCmmmIL3pe5Czw4BWkbuKo4aOn3MCxgEQIuzDvOgC nujseGn7ZDiA2RfZkziHfMz6qdfxtqnvQuCpdV8nm7B39S/lmu2tCG2TjHdvC0D/I+th hBYb2bTgeCdjNu7g+OyBIfeP1NKgVcl06FUZiKr2SVhK0atE98LtFk8IQDLD+LqZp5lp fMXQ== 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 t9si5953463pgf.185.2017.10.23.22.42.12; Mon, 23 Oct 2017 22:42:25 -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 S1751504AbdJXFkc (ORCPT + 99 others); Tue, 24 Oct 2017 01:40:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59524 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750791AbdJXFk3 (ORCPT ); Tue, 24 Oct 2017 01:40:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BD53624A8; Tue, 24 Oct 2017 05:40:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7BD53624A8 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.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 2C40C60F9D; Tue, 24 Oct 2017 05:40:24 +0000 (UTC) X-Mailbox-Line: From dyoung@redhat.com Tue Oct 24 13:39:01 2017 Message-Id: <20171024053901.813846011@redhat.com> User-Agent: quilt/0.65 Date: Tue, 24 Oct 2017 13:31:50 +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 3/3] kdump: round up the total memory size to 128M for crashkernel reservation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=kdump-crashkernel-roundup-total-mem.patch X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 24 Oct 2017 05:40:29 +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 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 we choose to round up total size to 128M to workaround this problem. This is a best effort workaround, will improve it when we have better way in the future. Signed-off-by: Dave Young --- kernel/crash_core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) --- linux.orig/kernel/crash_core.c +++ linux/kernel/crash_core.c @@ -42,6 +42,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, 0x8000000); /* for each entry of the comma-separated list */ do { @@ -86,13 +95,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 +135,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 1582941158846361828@xxx Thu Nov 02 08:12:07 +0000 2017 X-GM-THRID: 1582941158846361828 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread