Received: by 10.223.164.221 with SMTP id h29csp257972wrb; Mon, 23 Oct 2017 23:11:59 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SboMmHOJP+fr0sbBBg5QilrDzz71eQB1o13WNhUtsl3NPAlJ0uWCDG5bGPpPolBfg9Qb2h X-Received: by 10.98.192.195 with SMTP id g64mr15207265pfk.95.1508825519372; Mon, 23 Oct 2017 23:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508825519; cv=none; d=google.com; s=arc-20160816; b=mBL+racqTofg21TLTS6HFkDO86+KLQX0rrBD8ekfqySi+bxngwjGlNPnQYAJSevEMR /2svJwV0ifcXAzP5B7yohlKBn9DBKkHrsOTSwnEIC7TjLzcXgitVthuCq8BYXogvI/YB qU6ZTmB/dBZwRR+vKBwN/Rzg28WjMX6X2Raz0AyaUNGlRdaBFugIMUI6Qcf7LL3s2tkH MIs6beYnyI23uej3h0nZzhk4GZWNMW9PnP5rM2U300lPQ13fejgwchUjcPCEge4iwxM8 Q+rXK2j//rF+nf3G/ebbUOOs620VHHo57FeB8upqBDsHcZtIxoCr30FLr+mSaprSRyJs s5Lw== 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=Wn9W4USIkdpJETGTLdnUTxknnCcCnkBDNJbw8HvKAyU=; b=LZ4CjI8UIrjy56fGxgRmbZLqmtSB9O4ZMC3oRcNMq7AoKblVtt5xsxm3vmLkAWIBQa EnEgL+VYw0vI5bgUWu36xGGeSF0KAqKNvtG32ymMDmCbTQgjiQCTwdUdaX7E0jDDjwQ5 2IjRiuW4L8SBQFQkjRIZL3obG4PX5OIcylC0Sk9Lu0A/CIj9ebaV3kThqYk4icRuKQxe ANsTCZDxjQnGmmFWpUrWlxVYV0fidZl+FOHPlncxeaIfQaNA+wtbEJ9czqWQ9Gm1Gj9a yejOipnOPTr1l5a3boL5fWPmZ3vOFfnngr6LHodmcaXo+XahG540EDHjAjOnnysdOQrj 0yYw== 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 i7si5910860pgs.125.2017.10.23.23.11.44; Mon, 23 Oct 2017 23:11:59 -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 S1751559AbdJXGJz (ORCPT + 99 others); Tue, 24 Oct 2017 02:09:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54474 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbdJXGJv (ORCPT ); Tue, 24 Oct 2017 02:09:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B1E6C04AC4F; Tue, 24 Oct 2017 06:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B1E6C04AC4F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dyoung@redhat.com Received: from dhcp-128-65.nay.redhat.com (ovpn-12-114.pek2.redhat.com [10.72.12.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AAD68387D; Tue, 24 Oct 2017 06:09:48 +0000 (UTC) Date: Tue, 24 Oct 2017 14:09:44 +0800 From: Dave Young To: Baoquan He Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, vgoyal@redhat.com, yinghai@kernel.org, corbet@lwn.net Subject: Re: [PATCH 3/3] kdump: round up the total memory size to 128M for crashkernel reservation Message-ID: <20171024060944.GB8585@dhcp-128-65.nay.redhat.com> References: <20171024053901.813846011@redhat.com> <20171024055722.GG27757@x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171024055722.GG27757@x1> User-Agent: Mutt/1.8.3 (2017-05-23) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 24 Oct 2017 06:09:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baoquan, On 10/24/17 at 01:57pm, Baoquan He wrote: > Hi Dave, > > On 10/24/17 at 01:31pm, Dave Young wrote: > > 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. > > Thanks for this posting. While I don't get the point of this patch. So > firmware take piece of memory, then why we need to count it into the > total memory which we want to calculate a crashkernel memory based on. > > Not counting that, is there anyting incorrect? Yes, considering 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. User will never know that, it is hard to let user to know the exact total value we get in kernel.. > > Thanks > Baoquan > > > > > 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 > > > > Thanks Dave From 1582117357809626953@xxx Tue Oct 24 05:58:09 +0000 2017 X-GM-THRID: 1582116367860828786 X-Gmail-Labels: Inbox,Category Forums