From patchwork Wed Apr 3 03:05:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 10882585 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 4C05417E0 for ; Wed, 3 Apr 2019 02:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33E9522376 for ; Wed, 3 Apr 2019 02:54:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 278F22873A; Wed, 3 Apr 2019 02:54:52 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 82B5222376 for ; Wed, 3 Apr 2019 02:54:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DE9E6B0272; Tue, 2 Apr 2019 22:54:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 28F716B0274; Tue, 2 Apr 2019 22:54:48 -0400 (EDT) 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 10DC36B0276; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by kanga.kvack.org (Postfix) with ESMTP id CB3256B0274 for ; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) Received: by mail-ot1-f71.google.com with SMTP id w11so9495073otq.7 for ; Tue, 02 Apr 2019 19:54:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9vsSbmVCazVXk2p16cdSj8FEZujNbQEaLSgHoumtHQQ=; b=r0OD6G7yFNABeHAfPIn93DknO2Nsskia59scdejRd8t3Rxa0XZ+4iDt/fUwl+4n+8i 8iDGjb5iR0ImURrij5p+2tcigj5Ys6HgSkSOMZMOMvFFemRlgRefwEnfhTZAj/l37Wmv //jNA4HE77w+SDCiCKMHSnNqaw7bJqHL/HkaRcFa4baZLsp5JYKMTwPig4SSce2jOTPp ePUjaO9M7v9N0NgFLwzdV8xvnbYD4olFYo8RgEZqMjrA9Y/ybQrOsYAKLcL571yhqvP1 m2PIiNjKPlDzIzJo1NAwC4w1dMQK+MnNH9rLcQ5KOb7HTyUkEL3CRC9oGCcQ9TzR/tya xbcQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com X-Gm-Message-State: APjAAAU3aDLH+A3+UM1OfdwOcxTrQqQfAmY9pKP5LiDTzgOEpoRLfU1Y zJ8w+lywSbRfjLqbc1LuZWDOAGaurIR+AOXkai+f97QYYGVgJouTK+Q/zeIfaDf70LCxG9P8NMg Q2QEYlT58lsf9DYElg4WNxISPF7sCiOxWaDbxOCPpXdPlzD7jzegw4/Ilk/UfO9zsfA== X-Received: by 2002:aca:7215:: with SMTP id p21mr181564oic.81.1554260087516; Tue, 02 Apr 2019 19:54:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKgVQlLvxB4KTHVJnK4qvuIqMAsyUu7M60mSpzG9tTOw6J371kkx6A2V2H7Ni8hjc/hQal X-Received: by 2002:aca:7215:: with SMTP id p21mr181510oic.81.1554260086179; Tue, 02 Apr 2019 19:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554260086; cv=none; d=google.com; s=arc-20160816; b=EE8hdVGAJwiB0qNJ+OJx5XyIG26312LEAXLlHVPG+DlKKJrznTjiwCAP/oeI61btfP /ocw7w40c0bAmOpNF2CGM8ZNcCEltpPvmgqWgf86KNfmKTChheLig03AElRY7ZDGDzeR CYzRmaxmDkU3P8Mwqis4Fshc28BBzecgZfmp0xszIRXvuOwlUmEK/lEt8rZY/s7WVZnn lgo7LFlpnw0zCBcTpplC0gh/KSoBhTyxYTIVBaf4bluM68SuPw6QtQ36EESV6bg5ctSQ om2F21dLIVeqZYNUTkzRzuyfEqhOIUhsBYX2eeR6XDn3pu/Z4gXWG7xblAENsp5Kx3B6 gLMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=9vsSbmVCazVXk2p16cdSj8FEZujNbQEaLSgHoumtHQQ=; b=LTN0kKCA5KbPiOuK7TYyTZUdFIXVnuIzohrKueKLAn+m4D/ghdKCexJbthnK7aWEOM IIeIIkmd0wYvVcOkRZR4X+qZUMYCpRdbb1eujekZiVoUSu9dPtN/LCRLLTtOdTfQdr5W uJmrwgbmi9f17Oss5z38308rGHMlgA9qeWCqHspikXx53fazVgod1a7btteiQ4EQ0c9D BAvcOdSQP4ZoOvdmrbIdU9B0z6hFDu/aDhfr2sy7DDnU0+6W57BmAu0bdGCoc9mWCQvU 7/1DdGAVCL20l8hz4OUdrc81tCM/LAgg2Qt6eQMS8GHZMMOHwv9SA/bRnwRVxRjMcPdG q9KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from huawei.com (szxga04-in.huawei.com. [45.249.212.190]) by mx.google.com with ESMTPS id f62si6256086otb.305.2019.04.02.19.54.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 19:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.190 as permitted sender) client-ip=45.249.212.190; Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from DGGEMS408-HUB.china.huawei.com (unknown [10.3.19.208]) by Forcepoint Email with ESMTP id 0B3E5907F4EA0FB37403; Wed, 3 Apr 2019 10:54:42 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Wed, 3 Apr 2019 10:54:32 +0800 From: Chen Zhou To: , , , , , CC: , , , , , Chen Zhou Subject: [PATCH 1/3] arm64: kdump: support reserving crashkernel above 4G Date: Wed, 3 Apr 2019 11:05:44 +0800 Message-ID: <20190403030546.23718-2-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403030546.23718-1-chenzhou10@huawei.com> References: <20190403030546.23718-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] 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 When crashkernel is reserved above 4G in memory, kernel should reserve some amount of low memory for swiotlb and some DMA buffers. Kernel would try to allocate at least 256M below 4G automatically as x86_64 if crashkernel is above 4G. Meanwhile, support crashkernel=X,[high,low] in arm64. Signed-off-by: Chen Zhou --- arch/arm64/kernel/setup.c | 3 ++ arch/arm64/mm/init.c | 71 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 413d566..82cd9a0 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -243,6 +243,9 @@ static void __init request_standard_resources(void) request_resource(res, &kernel_data); #ifdef CONFIG_KEXEC_CORE /* Userspace will find "Crash kernel" region in /proc/iomem. */ + if (crashk_low_res.end && crashk_low_res.start >= res->start && + crashk_low_res.end <= res->end) + request_resource(res, &crashk_low_res); if (crashk_res.end && crashk_res.start >= res->start && crashk_res.end <= res->end) request_resource(res, &crashk_res); diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 6bc1350..ceb2a25 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -64,6 +64,57 @@ EXPORT_SYMBOL(memstart_addr); phys_addr_t arm64_dma_phys_limit __ro_after_init; #ifdef CONFIG_KEXEC_CORE +static int __init reserve_crashkernel_low(void) +{ + unsigned long long base, low_base = 0, low_size = 0; + unsigned long total_low_mem; + int ret; + + total_low_mem = memblock_mem_size(1UL << (32 - PAGE_SHIFT)); + + /* crashkernel=Y,low */ + ret = parse_crashkernel_low(boot_command_line, total_low_mem, &low_size, &base); + if (ret) { + /* + * two parts from lib/swiotlb.c: + * -swiotlb size: user-specified with swiotlb= or default. + * + * -swiotlb overflow buffer: now hardcoded to 32k. We round it + * to 8M for other buffers that may need to stay low too. Also + * make sure we allocate enough extra low memory so that we + * don't run out of DMA buffers for 32-bit devices. + */ + low_size = max(swiotlb_size_or_default() + (8UL << 20), 256UL << 20); + } else { + /* passed with crashkernel=0,low ? */ + if (!low_size) + return 0; + } + + low_base = memblock_find_in_range(0, 1ULL << 32, low_size, SZ_2M); + if (!low_base) { + pr_err("Cannot reserve %ldMB crashkernel low memory, please try smaller size.\n", + (unsigned long)(low_size >> 20)); + return -ENOMEM; + } + + ret = memblock_reserve(low_base, low_size); + if (ret) { + pr_err("%s: Error reserving crashkernel low memblock.\n", __func__); + return ret; + } + + pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System RAM: %ldMB)\n", + (unsigned long)(low_size >> 20), + (unsigned long)(low_base >> 20), + (unsigned long)(total_low_mem >> 20)); + + crashk_low_res.start = low_base; + crashk_low_res.end = low_base + low_size - 1; + + return 0; +} + /* * reserve_crashkernel() - reserves memory for crash kernel * @@ -74,19 +125,28 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init; static void __init reserve_crashkernel(void) { unsigned long long crash_base, crash_size; + bool high = false; int ret; ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), &crash_size, &crash_base); /* no crashkernel= or invalid value specified */ - if (ret || !crash_size) - return; + if (ret || !crash_size) { + /* crashkernel=X,high */ + ret = parse_crashkernel_high(boot_command_line, memblock_phys_mem_size(), + &crash_size, &crash_base); + if (ret || !crash_size) + return; + high = true; + } crash_size = PAGE_ALIGN(crash_size); if (crash_base == 0) { /* Current arm64 boot protocol requires 2MB alignment */ - crash_base = memblock_find_in_range(0, ARCH_LOW_ADDRESS_LIMIT, + crash_base = memblock_find_in_range(0, + high ? memblock_end_of_DRAM() + : ARCH_LOW_ADDRESS_LIMIT, crash_size, SZ_2M); if (crash_base == 0) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n", @@ -112,6 +172,11 @@ static void __init reserve_crashkernel(void) } memblock_reserve(crash_base, crash_size); + if (crash_base >= SZ_4G && reserve_crashkernel_low()) { + memblock_free(crash_base, crash_size); + return; + } + pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", crash_base, crash_base + crash_size, crash_size >> 20); From patchwork Wed Apr 3 03:05:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 10882583 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 BDA0413B5 for ; Wed, 3 Apr 2019 02:54:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5B8C22376 for ; Wed, 3 Apr 2019 02:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A17028721; Wed, 3 Apr 2019 02:54:49 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 F1E2922376 for ; Wed, 3 Apr 2019 02:54:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9DD56B026F; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E4DC66B0272; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) 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 D286E6B0275; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id A23926B026F for ; Tue, 2 Apr 2019 22:54:47 -0400 (EDT) Received: by mail-ot1-f72.google.com with SMTP id r23so9495585ota.17 for ; Tue, 02 Apr 2019 19:54:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UBAKnE8KUH0dKsvUsRf1caQt1pkMsYPo1KirROOGv/A=; b=Y+KdDJDocrRlTLZyesn1y09KCjpMJ+iGV+xDyWteDZZRCkdY29mj+QwdsqAM/1NMoN 7pexG3QYMTajQ2UjL2ydMfNYwOQx/xW8Nh3zl4O+Sg40B2M1af4J5TOU2FPEiyZ0JQri cFuU6BfHaBiCAeeHeyyo7M+lYZiTd3R71+S+T3ncilR0905E9SEpfH4WxV3pKdDlaren 5IjhfRFKjx0jp18BhS2ug71x1YfZHzoeMNhKJuKCSTI4QsczW+zEdMLcd8M8EMMVriz+ Et/eBB2GhGZA6aG2HfFJYy4PSP3HBiTrHbbyqVdZs/JHY7wWrwWF0rBtS8rjARkOBHV0 oCJg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com X-Gm-Message-State: APjAAAVgi8u2JSNwfqkJPbQBFLM32DPFwCCYnnlfeRydgwqb21ZP5Hnw 8ThQb1Hc2MWwgJYsviTQfqVdBDef+zVjM/OMnAz607HD9yvrFN4j9UipTKrFNv+YFeA8jf1DopI RygfhWWypoPYMgua4iu5xdUarA0WVca8qgBkF19qZYGPp/Bisy+CWoVKbwCUTzmDzAg== X-Received: by 2002:aca:b943:: with SMTP id j64mr206281oif.18.1554260087336; Tue, 02 Apr 2019 19:54:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBjVy9jz1Z1K2zGnfv1UNjQEbuvw3GVaPUedv4fwS3ipCGBLoTokf6qPlqdAhTv32Tsntj X-Received: by 2002:aca:b943:: with SMTP id j64mr206241oif.18.1554260086126; Tue, 02 Apr 2019 19:54:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554260086; cv=none; d=google.com; s=arc-20160816; b=0aRhhzzizI4/+XUkzay8g6dy9bOBlBmMgCXbLAhtzGB7PXrIXXkHpdXLIksjga7iB6 h93FjWGZm9F2t0TVK0K8yXojpVZMqv4AxN2T9vmtjq/APRZA4+BU9zYAGwMiojyyKObL HsxKtRjx3lASg9DrtKWpYs5kxxxA99MzIniaP3toCdPVdWtf21M3fsJ1XreckqLA9Cmr FiO0PmKsppwxR0AOqUmcsSrXUabuhsz4ApAwqfSaUCjOtgPcpW+SM54SGqHRECvXb2I7 JRK0aKe+dFYpeQ/qwjrREhVi8Boh86oMwjzAezfncBRzjpy8+PQUGLW3TMmMuOUtaf9i cWDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=UBAKnE8KUH0dKsvUsRf1caQt1pkMsYPo1KirROOGv/A=; b=HFdPRAEu0j/VlNjLUBYnN53MEIQ+hw5C9EkdbBZaQhf+5LD6wFm2xpts5okJGJFgxs MOPMlJ4HVFIJQoaFQxa4cP9g0cXfPJDEkfUz/RiK+Ry2s5ywg4+aOENOSlJ4KyNmpiaW m8z9er3m8GgdYvm9TKrD9UD3uD0N9HAyObM4Cw6noCyOr5/a+YtQOIo66JJVFESSo+h+ 24MhP2Q6zX4bZFlG0c3nyS5q7hNJRvRl54TQCQxcc9NubT2igo9wwuOO2ZTnJGV+0t0O we913L4MPNQ0JB3j+Amj4WbGIFQG7bRXmurfn/fVJdNP4A9Kyx5cVok5CbRWR7n0oMrT goIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from huawei.com (szxga05-in.huawei.com. [45.249.212.191]) by mx.google.com with ESMTPS id l16si6928456otn.154.2019.04.02.19.54.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 19:54:46 -0700 (PDT) Received-SPF: pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) client-ip=45.249.212.191; Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from DGGEMS408-HUB.china.huawei.com (unknown [10.3.19.208]) by Forcepoint Email with ESMTP id 3DFD7EFA4B81E6ED553E; Wed, 3 Apr 2019 10:54:42 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Wed, 3 Apr 2019 10:54:34 +0800 From: Chen Zhou To: , , , , , CC: , , , , , Chen Zhou Subject: [PATCH 2/3] arm64: kdump: support more than one crash kernel regions Date: Wed, 3 Apr 2019 11:05:45 +0800 Message-ID: <20190403030546.23718-3-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403030546.23718-1-chenzhou10@huawei.com> References: <20190403030546.23718-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] 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 After commit (arm64: kdump: support reserving crashkernel above 4G), there may be two crash kernel regions, one is below 4G, the other is above 4G. Crash dump kernel reads more than one crash kernel regions via a dtb property under node /chosen, linux,usable-memory-range = Signed-off-by: Chen Zhou --- arch/arm64/mm/init.c | 37 +++++++++++++++++++++++++------------ include/linux/memblock.h | 1 + mm/memblock.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ceb2a25..769c77a 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -64,6 +64,8 @@ EXPORT_SYMBOL(memstart_addr); phys_addr_t arm64_dma_phys_limit __ro_after_init; #ifdef CONFIG_KEXEC_CORE +# define CRASH_MAX_USABLE_RANGES 2 + static int __init reserve_crashkernel_low(void) { unsigned long long base, low_base = 0, low_size = 0; @@ -346,8 +348,8 @@ static int __init early_init_dt_scan_usablemem(unsigned long node, const char *uname, int depth, void *data) { struct memblock_region *usablemem = data; - const __be32 *reg; - int len; + const __be32 *reg, *endp; + int len, nr = 0; if (depth != 1 || strcmp(uname, "chosen") != 0) return 0; @@ -356,22 +358,33 @@ static int __init early_init_dt_scan_usablemem(unsigned long node, if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) return 1; - usablemem->base = dt_mem_next_cell(dt_root_addr_cells, ®); - usablemem->size = dt_mem_next_cell(dt_root_size_cells, ®); + endp = reg + (len / sizeof(__be32)); + while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { + usablemem[nr].base = dt_mem_next_cell(dt_root_addr_cells, ®); + usablemem[nr].size = dt_mem_next_cell(dt_root_size_cells, ®); + + if (++nr >= CRASH_MAX_USABLE_RANGES) + break; + } return 1; } static void __init fdt_enforce_memory_region(void) { - struct memblock_region reg = { - .size = 0, - }; - - of_scan_flat_dt(early_init_dt_scan_usablemem, ®); - - if (reg.size) - memblock_cap_memory_range(reg.base, reg.size); + int i, cnt = 0; + struct memblock_region regs[CRASH_MAX_USABLE_RANGES]; + + memset(regs, 0, sizeof(regs)); + of_scan_flat_dt(early_init_dt_scan_usablemem, regs); + + for (i = 0; i < CRASH_MAX_USABLE_RANGES; i++) + if (regs[i].size) + cnt++; + else + break; + if (cnt) + memblock_cap_memory_ranges(regs, cnt); } void __init arm64_memblock_init(void) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 47e3c06..aeade34 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -446,6 +446,7 @@ phys_addr_t memblock_start_of_DRAM(void); phys_addr_t memblock_end_of_DRAM(void); void memblock_enforce_memory_limit(phys_addr_t memory_limit); void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size); +void memblock_cap_memory_ranges(struct memblock_region *regs, int cnt); void memblock_mem_limit_remove_map(phys_addr_t limit); bool memblock_is_memory(phys_addr_t addr); bool memblock_is_map_memory(phys_addr_t addr); diff --git a/mm/memblock.c b/mm/memblock.c index 28fa8926..1a7f4ee7c 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1697,6 +1697,46 @@ void __init memblock_cap_memory_range(phys_addr_t base, phys_addr_t size) base + size, PHYS_ADDR_MAX); } +void __init memblock_cap_memory_ranges(struct memblock_region *regs, int cnt) +{ + int start_rgn[INIT_MEMBLOCK_REGIONS], end_rgn[INIT_MEMBLOCK_REGIONS]; + int i, j, ret, nr = 0; + + for (i = 0; i < cnt; i++) { + ret = memblock_isolate_range(&memblock.memory, regs[i].base, + regs[i].size, &start_rgn[i], &end_rgn[i]); + if (ret) + break; + nr++; + } + if (!nr) + return; + + /* remove all the MAP regions */ + for (i = memblock.memory.cnt - 1; i >= end_rgn[nr - 1]; i--) + if (!memblock_is_nomap(&memblock.memory.regions[i])) + memblock_remove_region(&memblock.memory, i); + + for (i = nr - 1; i > 0; i--) + for (j = start_rgn[i] - 1; j >= end_rgn[i - 1]; j--) + if (!memblock_is_nomap(&memblock.memory.regions[j])) + memblock_remove_region(&memblock.memory, j); + + for (i = start_rgn[0] - 1; i >= 0; i--) + if (!memblock_is_nomap(&memblock.memory.regions[i])) + memblock_remove_region(&memblock.memory, i); + + /* truncate the reserved regions */ + memblock_remove_range(&memblock.reserved, 0, regs[0].base); + + for (i = nr - 1; i > 0; i--) + memblock_remove_range(&memblock.reserved, + regs[i].base, regs[i - 1].base + regs[i - 1].size); + + memblock_remove_range(&memblock.reserved, + regs[nr - 1].base + regs[nr - 1].size, PHYS_ADDR_MAX); +} + void __init memblock_mem_limit_remove_map(phys_addr_t limit) { phys_addr_t max_addr; From patchwork Wed Apr 3 03:05:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 10882587 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 0223317E0 for ; Wed, 3 Apr 2019 02:54:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB5322376 for ; Wed, 3 Apr 2019 02:54:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D19F028736; Wed, 3 Apr 2019 02:54:54 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 7826922376 for ; Wed, 3 Apr 2019 02:54:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8ADB36B0274; Tue, 2 Apr 2019 22:54:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8344E6B0275; Tue, 2 Apr 2019 22:54:52 -0400 (EDT) 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 6FE686B0276; Tue, 2 Apr 2019 22:54:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id 424446B0274 for ; Tue, 2 Apr 2019 22:54:52 -0400 (EDT) Received: by mail-ot1-f72.google.com with SMTP id n2so9519368otk.19 for ; Tue, 02 Apr 2019 19:54:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=S2ig1be+sIFgRMbWQ0Djd4ujr3RZdZV0qfjf5c70x20=; b=QpBbTERbX62reT2VF2DM7l2ITyUjJ/huVnokwPSmFH8WVy+E8fdxBWt93Xw4ZFxDFm QOzwudk3l9T3dLvkvdQTmJc+kCC8WAt7E7SrEuB8SgJDstP5jzfauDp8saFwAoOVLHQB 3KVjosRdujqZbwm8Ys3VxjrSclowh7ptGKeGUFei7ox6fnknYWPxEJUOKTZ7LxWU9t3P X0NoFm04Qvma76/w+i5ztam8uz4iuj4xhOoNblf0KExH55ScmVnvg+JYn3o49IP6E/Gr 3sSNmBRqeU4rA/6Q5Nqwc3jmr2iJHqxa7zHOBnvZEFTntCOiglK+0kGvGKJtIv5Irzil tCBw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com X-Gm-Message-State: APjAAAUcm4LjulsByFVkvDvNyiMQCCKc5BNoFY+giFwkvtXLBO8HDOte LCmaIf0cNZLXFC+yDwSm+EeWyQiTdBZd92+nUp6+J/+iDfEHDZdPgzBJzYcsBCNEg2+3Fc1+GTw zhiGPlK57mP/aadYjea6geoedjCtDySa0eGohy4gcPIu1g1sVSW18in7WsxSxmxX6lA== X-Received: by 2002:aca:4085:: with SMTP id n127mr173426oia.93.1554260091908; Tue, 02 Apr 2019 19:54:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRoIseUQ8lIDovHTlStNVs/gnnd5cZfUR8qafDWe05ehuifaw2B4pGjI9jBHi2gUEgHMnW X-Received: by 2002:aca:4085:: with SMTP id n127mr173393oia.93.1554260090963; Tue, 02 Apr 2019 19:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554260090; cv=none; d=google.com; s=arc-20160816; b=mP5yL9XNI8UBzfvrJQqnx92ibP5vW5g57GK9BC7ac3HOHTSzDEP1iX7EiKzn/hSUII SvwuatxV2SmA7KIJIH4JQV1qxnetssN9jMVHFGEUMaam5QgVtIgpBcJrdfOzq3RPMvYG HFv4Xa+Sef8RVCeYDM485SpzViUcXLpVGEURATyzGCaBpS1zKkrPw9ysia83m9qecEDc H/XpC6KV6x2f1XYbUrBK6zm+DDEeSZTZ0pTGkwg67czio9+v1JL4PtKSYaGMiV/MZ1CT HoMXs+MxCHAHKW60tAua5fc1LW95dLW+w0dGgX5zSeBXbfpvH+h1BXpZwCmqT2jShiba P5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=S2ig1be+sIFgRMbWQ0Djd4ujr3RZdZV0qfjf5c70x20=; b=nm09XlZbJdU2f6YY+foFMPserI+dczj5zOl3UhJcd4qTf3maMKK1zJ2gEOzMsm1nqw Ger6PeCsDLvQwPS3SIZFQlaDQca8RLWLupMNbFFnreIuByRuHeLYhYVd5Tbv1chWhyaa P9UxCETCtkmdiNAPGBarqHrujy5RAOuPSpZDx8CM/mIRzY+GAIl5Icfbd6OyTmqDLrS4 Y4K21OJJqzuuOgMEbZMZMVcBzcQDucIkKtNmOf5W1VMeyFPdfxp5RC+OHxeTisus5Pnh p5ebk0tZhT+OGmgE4bCt/yPp4EKSj9/gaLJtEqcojphiwres3ZcE1eUC/ocE2xD5IiSz Sx6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from huawei.com (szxga05-in.huawei.com. [45.249.212.191]) by mx.google.com with ESMTPS id t133si6409246oib.55.2019.04.02.19.54.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 19:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) client-ip=45.249.212.191; Authentication-Results: mx.google.com; spf=pass (google.com: domain of chenzhou10@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=chenzhou10@huawei.com Received: from DGGEMS408-HUB.china.huawei.com (unknown [10.3.19.208]) by Forcepoint Email with ESMTP id 2330B9790E51A53BD62C; Wed, 3 Apr 2019 10:54:47 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Wed, 3 Apr 2019 10:54:36 +0800 From: Chen Zhou To: , , , , , CC: , , , , , Chen Zhou Subject: [PATCH 3/3] kdump: update Documentation about crashkernel on arm64 Date: Wed, 3 Apr 2019 11:05:46 +0800 Message-ID: <20190403030546.23718-4-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190403030546.23718-1-chenzhou10@huawei.com> References: <20190403030546.23718-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] 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 Now we support crashkernel=X,[high,low] on arm64, update the Documentation. Signed-off-by: Chen Zhou --- Documentation/admin-guide/kernel-parameters.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 27a5f8c..6772f4f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -715,14 +715,14 @@ Documentation/kdump/kdump.txt for an example. crashkernel=size[KMG],high - [KNL, x86_64] range could be above 4G. Allow kernel + [KNL, x86_64, arm64] range could be above 4G. Allow kernel to allocate physical memory region from top, so could be above 4G if system have more than 4G ram installed. Otherwise memory region will be allocated below 4G, if available. It will be ignored if crashkernel=X is specified. crashkernel=size[KMG],low - [KNL, x86_64] range under 4G. When crashkernel=X,high + [KNL, x86_64, arm64] range under 4G. When crashkernel=X,high is passed, kernel could allocate physical memory region above 4G, that cause second kernel crash on system that require some amount of low memory, e.g. swiotlb