From patchwork Fri Dec 28 03:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 10744107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5C8613A4 for ; Fri, 28 Dec 2018 03:00:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB2BC28DF3 for ; Fri, 28 Dec 2018 03:00:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF43428DF7; Fri, 28 Dec 2018 03:00:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56F7F28DF3 for ; Fri, 28 Dec 2018 03:00:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10E768E002B; Thu, 27 Dec 2018 22:00:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 095508E0001; Thu, 27 Dec 2018 22:00:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78F08E002B; Thu, 27 Dec 2018 22:00:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id A1E168E0001 for ; Thu, 27 Dec 2018 22:00:39 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id q64so22168282pfa.18 for ; Thu, 27 Dec 2018 19:00:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=P0OefrDCdHfbwKHsy88ZHJA55EsjPCyehr3d+WFCOV4=; b=fileCt/5fLdYYT7UcxgPBp1OctFwPhyNJOiq+uYF/p7rRRHnBcAiYJz4OVZ6TjDa3C xBMtwJTzQEPFKjuysEJWhbMOrpR1VrebaYo9enU9UunZN03B1xHHqakR+7VcKVHbjzoF wAnoJuFbPiAjBAX8tQV6a1IGnDHs7bz8FzhWf2PwOxH7TlQ0DZ0QQ2JYOEEUHVjt7ln2 STBSAGJciW44mj40UHLzofO+Jcnu9BaApmIO8OhJyuupwqjD7Lzt8AdxEgYR50aZfvvN hkWKduP239xmwZ9pj/OVNIiY7TdjCjHvjOiddl05otX7PH3rBWJkhV2aFfrbnQ01TVsj lQZA== X-Gm-Message-State: AA+aEWZ1XHi/rrbvrvfkmMFM/2XyW2Wj0iBEplgQYldC9f2nNjUnJHvT kSsOTwRSYjDPV6oHgNRCa8X/gKsX0hjCORSh8BF1/EG+jdAhb2wqmUbqrh/PUKASkgzkbafU8eR xghmRwDvft1SZ+oV9I0+gppgM0PhkRE2Nsg1pwbgQRLsqnLED8Jf75nv1bDWAhR82kShYmhiZ60 Sqc65YiKN8hrS2eUAZn/EeHPlTwRKbVUMSaaYVw6h9Fxhw28Lrzn9p/FgM3hdag7ewuwgNChwgc 2X3sTM/pJJ69VuoYfqdzScMOu12es3XekTlV375qiC2jzCySGGdJQ8L/bDDxfzepWgZdx0oNcHH ef3sGsEML6ygwCO+s7iiPK7LYk1MltX3shyzWSg2RXRQ7Aj87Vz+6MnCxfdTTW2OHFoSvvgJdBe / X-Received: by 2002:a62:a1a:: with SMTP id s26mr26571211pfi.31.1545966039222; Thu, 27 Dec 2018 19:00:39 -0800 (PST) X-Received: by 2002:a62:a1a:: with SMTP id s26mr26571153pfi.31.1545966038379; Thu, 27 Dec 2018 19:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545966038; cv=none; d=google.com; s=arc-20160816; b=CqI7RjfY9dNv3L9k/ftRZSD2KyA87cwFQ198698McugpkS+24tmJkcokgBhKruo/7j YxMkhBv6YiRonLNtHtXeFgUZZhyT211CFBxQdd2QHm8GxmXZTy3kva8ZLUe2K64XCFJ7 CTKELvRrw8bSuEEb1ucuIL5glwQTM6PWPSb0PUh8eg0WboMFrlQT/pmKhM3vXKlj/pl3 GadqleQkDZScYlMMARYbOilZK9SYF4WIgmvYMPjFUPT1Hr8sWxL1fdrowEgelMuv6KZE JXnYffsvvpj3UptS0+MvVLoa8O+aN3BxpSs59+sKF4JaqJcL2C7OO8xzI9vTaPr9AsrU Qn4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P0OefrDCdHfbwKHsy88ZHJA55EsjPCyehr3d+WFCOV4=; b=M8sPHKYHg2dmmr0TUdiI04lczkC3Ivo/EnKUFxCStgSoqFkvCzbTGvM5ord+GM9wU+ er74/WFa0mt9vA1xndN+G9StWpj9jyYmwg6OX5Hg7v4sqssp0UiDlbfArkGjzfRmR88K gaV/Xyd5ujP1xI83VPfg9XhCbR0w3tJ0ycDywVbZjAdZyiezytPVVKv1O9kQfOuXB0eZ QSNGaz5PVaZKQV04DAbsNP+J2r567AVrbanclMNWSaQPP7xtTshrPWSCEaPkkEIBvhyY MgJXCiHMNsYt1XaumTOaDixRhdcH4k5sL1460KeJmJJD2k4t6VMh6ulR4Y0EnpBxtPhp Pb5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hVquMnSv; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n15sor1283036plp.65.2018.12.27.19.00.37 for (Google Transport Security); Thu, 27 Dec 2018 19:00:38 -0800 (PST) Received-SPF: pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hVquMnSv; spf=pass (google.com: domain of kernelfans@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=kernelfans@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P0OefrDCdHfbwKHsy88ZHJA55EsjPCyehr3d+WFCOV4=; b=hVquMnSv0Ml5RfLfRRlUw5ccjVZO8IO58JCttGnW+Xd4z+HbnLWdfE+l5K8XbJJpJy VxM0kcA1U/nrXNjez2VlBCrlByGCzIMoGAdhXHAKCkWynwgoZgvGhQELg8dAJe+HdTse hE22hYcqs0L5G0MhYhbtnY4xNrcOAOHkT5olYNqHKiJv+ccSWBRN+cDxG+7l73SS2vF7 HE0K9pl1zIb+2Hc1bsWSKL196UTxLswmt1CYk8zwR5fVVsGoTtvG80cLIgsdzhKgXi8l /iT50X6mgDQUwoG/KLgnGGaHq7yb03JIZ3F8BVEHGw4Z7hLlWrmQSnDAOV8OPxqYjp5B 3Klw== X-Google-Smtp-Source: ALg8bN5NGXBadvb4zjPp8Ma6rh/JW4c0pihJ5b2zJkj0mgku8l+owH6L8c5esFok507v7A7TXYWjNw== X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr26364353plp.34.1545966037745; Thu, 27 Dec 2018 19:00:37 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 202sm80185958pfy.87.2018.12.27.19.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Dec 2018 19:00:36 -0800 (PST) From: Pingfan Liu To: linux-acpi@vger.kernel.org, linux-mm@kvack.org, kexec@lists.infradead.org Cc: Pingfan Liu , Tang Chen , "Rafael J. Wysocki" , Len Brown , Andrew Morton , Mike Rapoport , Michal Hocko , Jonathan Corbet , Yaowei Bai , Pavel Tatashin , Nicholas Piggin , Naoya Horiguchi , Daniel Vacek , Mathieu Malaterre , Stefan Agner , Dave Young , Baoquan He , yinghai@kernel.org, vgoyal@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCHv3 2/2] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr Date: Fri, 28 Dec 2018 11:00:02 +0800 Message-Id: <1545966002-3075-3-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545966002-3075-1-git-send-email-kernelfans@gmail.com> References: <1545966002-3075-1-git-send-email-kernelfans@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Customer reported a bug on a high end server with many pcie devices, where kernel bootup with crashkernel=384M, and kaslr is enabled. Even though we still see much memory under 896 MB, the finding still failed intermittently. Because currently we can only find region under 896 MB, if w/0 ',high' specified. Then KASLR breaks 896 MB into several parts randomly, and crashkernel reservation need be aligned to 128 MB, that's why failure is found. It raises confusion to the end user that sometimes crashkernel=X works while sometimes fails. If want to make it succeed, customer can change kernel option to "crashkernel=384M, high". Just this give "crashkernel=xx@yy" a very limited space to behave even though its grammer looks more generic. And we can't answer questions raised from customer that confidently: 1) why it doesn't succeed to reserve 896 MB; 2) what's wrong with memory region under 4G; 3) why I have to add ',high', I only require 384 MB, not 3840 MB. This patch simplifies the method suggested in the mail [1]. It just goes bottom-up to find a candidate region for crashkernel. The bottom-up may be better compatible with the old reservation style, i.e. still want to get memory region from 896 MB firstly, then [896 MB, 4G], finally above 4G. There is one trivial thing about the compatibility with old kexec-tools: if the reserved region is above 896M, then old tool will fail to load bzImage. But without this patch, the old tool also fail since there is no memory below 896M can be reserved for crashkernel. [1]: http://lists.infradead.org/pipermail/kexec/2017-October/019571.html Signed-off-by: Pingfan Liu Cc: Tang Chen Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Andrew Morton Cc: Mike Rapoport Cc: Michal Hocko Cc: Jonathan Corbet Cc: Yaowei Bai Cc: Pavel Tatashin Cc: Nicholas Piggin Cc: Naoya Horiguchi Cc: Daniel Vacek Cc: Mathieu Malaterre Cc: Stefan Agner Cc: Dave Young Cc: Baoquan He Cc: yinghai@kernel.org, Cc: vgoyal@redhat.com Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/setup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d494b9b..165f9c3 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -541,15 +541,18 @@ static void __init reserve_crashkernel(void) /* 0 means: find the address automatically */ if (crash_base <= 0) { + bool bottom_up = memblock_bottom_up(); + + memblock_set_bottom_up(true); /* * Set CRASH_ADDR_LOW_MAX upper bound for crash memory, * as old kexec-tools loads bzImage below that, unless * "crashkernel=size[KMG],high" is specified. */ crash_base = memblock_find_in_range(CRASH_ALIGN, - high ? CRASH_ADDR_HIGH_MAX - : CRASH_ADDR_LOW_MAX, - crash_size, CRASH_ALIGN); + (max_pfn * PAGE_SIZE), crash_size, CRASH_ALIGN); + memblock_set_bottom_up(bottom_up); + if (!crash_base) { pr_info("crashkernel reservation failed - No suitable area found.\n"); return;