From patchwork Wed Jul 1 22:14:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 11637429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38AF3912 for ; Wed, 1 Jul 2020 22:17:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 123DE20853 for ; Wed, 1 Jul 2020 22:17:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="J9ATsRKr"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DS7XH+Bz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 123DE20853 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=POeU9jg3wFLibVCTJru8iDXR7IVrSaN8BGLeFu73KX4=; b=J9ATsRKrVCP+RRyOTVIzgcKcyG gvTl5ni+455zW0gLduhIEDcO1qHf8Ur2KK74DSf8mn/cLhFLWuIX2Pwf1BKOgAnHTSpR4Ng4Z091x iRJM/lsaDvtOA1aSYOBHws4p0ZzI6VLhzK/XlTes28KCKBDeSPC+hP6r/mGcNpsxJihePm/g749yp sJsKH5VtVlG6D5FlNX1RcL5W/DJrAsy5YlM4/4R0YtZytPfbmZDNPSvk4riMmg8uwmgYh0kC2gVr5 /udK3uuoJFo/jMGhL0ra3Nczo467VbHVxJpynhcYWysTJvteoRzCzLgR+0UOxu4+IhUeL7NlXUQ7b uWZ1Uh9w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jql1u-00025p-56; Wed, 01 Jul 2020 22:16:34 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jql1i-00022b-W6 for linux-arm-kernel@lists.infradead.org; Wed, 01 Jul 2020 22:16:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593641782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=xoqk9QTtScU+aPGKHoCc+VNYKEEQhDvkQeRwCbimQV8=; b=DS7XH+Bza1e1DPzMwlYd79ZaFkvY6WkbYsMYIYz4mokdWCoNfkoq0GN2FV/GNohqYG+ktq 3JEJvURZhsLCNle61vOR4cbQd9MMKHod4xi6bZuy9tyS4x4xVlzdGAThnJdzLLr+dY3+nC t7TELj7xlxuCi5E/7RUyeVtFsQembqM= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-PzPf9OYyMgmuiNKITwHfBg-1; Wed, 01 Jul 2020 18:14:48 -0400 X-MC-Unique: PzPf9OYyMgmuiNKITwHfBg-1 Received: by mail-pj1-f72.google.com with SMTP id h93so19367481pjb.2 for ; Wed, 01 Jul 2020 15:14:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xoqk9QTtScU+aPGKHoCc+VNYKEEQhDvkQeRwCbimQV8=; b=JXUAV9UvDxP/U6Q3IbY5PKkyXfZ7cHPXWfY3hmA87ial3QV54n7QM4wubRpshciTWA X5CTAHih/ha4YJsFh1L7qqDXbH9OEORfJa8/mVq3yNgdY9STyZeSZb072oElxBiHy/Wq e9PoFiv4WF68qAL9kbR/GZ77vX9ybyCQlAkLJhyRcIUlr0EaohRKTYWSmcZwxaCe/78R 6YyYN488ghWO+d5Fr6K/GuNIEu63GFzAM143OLI198oG+hFUcH6Jo2M3olSbJv4LKfgV jAo8dNNCZtpu8kkKAI4NLhUp51NEMhmOWKNBrdXSDShLkY+iNePvlXYjQQjRTlbYa4Ob 2f0Q== X-Gm-Message-State: AOAM530cvXYyHsTl4Tfpn50/mJLFDbna+jg99SKFYTUFaQdOySJzCypK 2n5dXcDMUC7O0Nfy29Y9woEo2KOq2zntidRJ0Ptix0N60UjNhJ5hMYyYYSa/lylDz0vSAffq+1L z8gttHxrJpkhnYZ4dZ80/4fQR/YfG9/JBaDI= X-Received: by 2002:a17:902:148:: with SMTP id 66mr23151073plb.308.1593641687740; Wed, 01 Jul 2020 15:14:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSel1QkbgREE+b1y+g1hJfoMILEzByCbKnUpkCkK6gLrD4a7/08WiZHMyUAY4DMfVWE25z8w== X-Received: by 2002:a17:902:148:: with SMTP id 66mr23151046plb.308.1593641687475; Wed, 01 Jul 2020 15:14:47 -0700 (PDT) Received: from localhost ([110.227.183.4]) by smtp.gmail.com with ESMTPSA id h6sm6973231pfg.25.2020.07.01.15.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2020 15:14:47 -0700 (PDT) From: Bhupesh Sharma To: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] arm64: Allocate crashkernel always in ZONE_DMA Date: Thu, 2 Jul 2020 03:44:20 +0530 Message-Id: <1593641660-13254-3-git-send-email-bhsharma@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593641660-13254-1-git-send-email-bhsharma@redhat.com> References: <1593641660-13254-1-git-send-email-bhsharma@redhat.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bhsharma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200701_181623_133122_BDFDBE2C X-CRM114-Status: GOOD ( 18.96 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [207.211.31.120 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [207.211.31.120 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , bhsharma@redhat.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Hocko , James Morse , Vladimir Davydov , Johannes Weiner , bhupesh.linux@gmail.com, Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org commit bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32") allocates crashkernel for arm64 in the ZONE_DMA32. However as reported by Prabhakar, this breaks kdump kernel booting in ThunderX2 like arm64 systems. I have noticed this on another ampere arm64 machine. The OOM log in the kdump kernel looks like this: [ 0.240552] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations [ 0.247713] swapper/0: page allocation failure: order:1, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0 <..snip..> [ 0.274706] Call trace: [ 0.277170] dump_backtrace+0x0/0x208 [ 0.280863] show_stack+0x1c/0x28 [ 0.284207] dump_stack+0xc4/0x10c [ 0.287638] warn_alloc+0x104/0x170 [ 0.291156] __alloc_pages_slowpath.constprop.106+0xb08/0xb48 [ 0.296958] __alloc_pages_nodemask+0x2ac/0x2f8 [ 0.301530] alloc_page_interleave+0x20/0x90 [ 0.305839] alloc_pages_current+0xdc/0xf8 [ 0.309972] atomic_pool_expand+0x60/0x210 [ 0.314108] __dma_atomic_pool_init+0x50/0xa4 [ 0.318504] dma_atomic_pool_init+0xac/0x158 [ 0.322813] do_one_initcall+0x50/0x218 [ 0.326684] kernel_init_freeable+0x22c/0x2d0 [ 0.331083] kernel_init+0x18/0x110 [ 0.334600] ret_from_fork+0x10/0x18 This patch limits the crashkernel allocation to the first 1GB of the RAM accessible (ZONE_DMA), as otherwise we might run into OOM issues when crashkernel is executed, as it might have been originally allocated from either a ZONE_DMA32 memory or mixture of memory chunks belonging to both ZONE_DMA and ZONE_DMA32. Fixes: bff3b04460a8 ("arm64: mm: reserve CMA and crashkernel in ZONE_DMA32") Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: James Morse Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org Reported-by: Prabhakar Kushwaha Signed-off-by: Bhupesh Sharma --- arch/arm64/mm/init.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 1e93cfc7c47a..02ae4d623802 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -91,8 +91,15 @@ static void __init reserve_crashkernel(void) crash_size = PAGE_ALIGN(crash_size); if (crash_base == 0) { - /* Current arm64 boot protocol requires 2MB alignment */ - crash_base = memblock_find_in_range(0, arm64_dma32_phys_limit, + /* Current arm64 boot protocol requires 2MB alignment. + * Also limit the crashkernel allocation to the first + * 1GB of the RAM accessible (ZONE_DMA), as otherwise we + * might run into OOM issues when crashkernel is executed, + * as it might have been originally allocated from + * either a ZONE_DMA32 memory or mixture of memory + * chunks belonging to both ZONE_DMA and ZONE_DMA32. + */ + crash_base = memblock_find_in_range(0, arm64_dma_phys_limit, crash_size, SZ_2M); if (crash_base == 0) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n", @@ -101,6 +108,11 @@ static void __init reserve_crashkernel(void) } } else { /* User specifies base address explicitly. */ + if (crash_base + crash_size > arm64_dma_phys_limit) { + pr_warn("cannot reserve crashkernel: region is allocatable only in ZONE_DMA range\n"); + return; + } + if (!memblock_is_region_memory(crash_base, crash_size)) { pr_warn("cannot reserve crashkernel: region is not memory\n"); return;