From patchwork Wed Jul 1 22:14:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 11637431 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 52FE692A 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 2D05620870 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="nLg32y36"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PK1CPkUt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D05620870 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=FOVezd25qK9YGGAcR7a5/+pPTti4wBiNVlW00v2UOso=; b=nLg32y36zjwnyYRP2fpEKM7/5e e7E5qJFn/boXfMCLnwKrXgGl5G7C0adfHuep09vXLdPbLhkx2goOoeXs48mKkrHyhHqAN3J3UKnwb C6xhB4pQFP1x3XIDJSpqmjpos9CG+IErYPrksyaZhvJrp2bl5HKR6I5I3GLVlJKzfrtsEdPUYsLRQ 5HPudkh+fpdq0CeOuZQeFiGb8Ufdn1RJoGyJ0e1NfPfZsZjRHLNqgVlENZHbTiHKmJ28O+fGRxbTV EhScy5MxAzhV7bEoxdaBCcJUoVUZ0pgasqs+ex0CRnPYXQHA8vVXcqf/7Tqqs5zCbJnsArqqRNdnc IOMUDByg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jql1r-000254-K0; Wed, 01 Jul 2020 22:16:31 +0000 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jql1i-00022Y-Oy 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=bQb32/SaJZufmc/q7s+tyKjNogq0Gy4EIBWlQy//p8M=; b=PK1CPkUtG+2w28X9wnCVEZeVW5tC6li9MCFNSx0mTtpGqc2MHO3Zv3OQZ61gymPwouJP+E Z+jC71YLlwDmHhgRFO39xfx6gWVqJmKhzWWt34NNxRy6WJtICmuTXdJrEHcQmFjhGpBNR+ MipHvMA+skPUl61IoetE+SxQlLQ1B38= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-rGBUulTtO0WInpqG7ez85g-1; Wed, 01 Jul 2020 18:14:47 -0400 X-MC-Unique: rGBUulTtO0WInpqG7ez85g-1 Received: by mail-pg1-f200.google.com with SMTP id j9so15446118pgm.8 for ; Wed, 01 Jul 2020 15:14:47 -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=bQb32/SaJZufmc/q7s+tyKjNogq0Gy4EIBWlQy//p8M=; b=c3tzQ5i5/Xygvs9Zs67pbI0gbK3nHTHZTNwzn111nJeFvAEkZ80usBQn2V4LwRf1sV KFf8F0LOqIAn1pX4c61RYhj5ot0mChwamfWommekDP9G+9tZtR8zi08wJf6IujSZgKWH PyVqDEw7Ah8FbmFaHQeHkdqZ5d0IF1ibIBOFKx+wj/eaYioKhYEkvNDiMwQFD2rTlmms isFJMG91p0KB3o6bsPBTkXYB7IR79EPb1PC/jJeSdufnCib63Np1wuG92xOFElhhCyuv obBorw5YsXfx1JJ+u/2lFAXkDt/D8lFc1oQx8EqUHthy7KQbrEqQJhwjrCrX6ZGSsKXv XFuQ== X-Gm-Message-State: AOAM533ZgHfRh2CD2mpWFGKE2/iL3+R8YthZTutPTFNnt05FYPgToLcQ 2EEkcrejk2hWIXsjaREFCeDcPs3jUxTnOMYA2nWBSJVYZ3UCSWkThZCXffW3rJH1NmUMHDYdiAo BS618gcPpypL1cUmHeUnQHbjZTAleBvClO38= X-Received: by 2002:a17:902:fe11:: with SMTP id g17mr24013381plj.145.1593641684953; Wed, 01 Jul 2020 15:14:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFdvc/WtQ+mMt1LPHoxqyDf9VjA9s5BpTGQK1trOcKSTKxk2LHBrXcJPTmY4MjY2gBSv/yxw== X-Received: by 2002:a17:902:fe11:: with SMTP id g17mr24013361plj.145.1593641684671; Wed, 01 Jul 2020 15:14:44 -0700 (PDT) Received: from localhost ([110.227.183.4]) by smtp.gmail.com with ESMTPSA id m12sm6091920pjf.17.2020.07.01.15.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2020 15:14:44 -0700 (PDT) From: Bhupesh Sharma To: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] mm/memcontrol: Fix OOPS inside mem_cgroup_get_nr_swap_pages() Date: Thu, 2 Jul 2020 03:44:19 +0530 Message-Id: <1593641660-13254-2-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_015537_5C87EEE6 X-CRM114-Status: GOOD ( 20.52 ) 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 [205.139.110.120 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [205.139.110.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 Prabhakar reported an OOPS inside mem_cgroup_get_nr_swap_pages() function in a corner case seen on some arm64 boards when kdump kernel runs with "cgroup_disable=memory" passed to the kdump kernel via bootargs. The root-cause behind the same is that currently mem_cgroup_swap_init() function is implemented as a subsys_initcall() call instead of a core_initcall(), this means 'cgroup_memory_noswap' still remains set to the default value (false) even when memcg is disabled via "cgroup_disable=memory" boot parameter. This may result in premature OOPS inside mem_cgroup_get_nr_swap_pages() function in corner cases: [ 0.265617] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000188 [ 0.274495] Mem abort info: [ 0.277311] ESR = 0x96000006 [ 0.280389] EC = 0x25: DABT (current EL), IL = 32 bits [ 0.285751] SET = 0, FnV = 0 [ 0.288830] EA = 0, S1PTW = 0 [ 0.291995] Data abort info: [ 0.294897] ISV = 0, ISS = 0x00000006 [ 0.298765] CM = 0, WnR = 0 [ 0.301757] [0000000000000188] user address but active_mm is swapper [ 0.308174] Internal error: Oops: 96000006 [#1] SMP [ 0.313097] Modules linked in: <..snip..> [ 0.331384] pstate: 00400009 (nzcv daif +PAN -UAO BTYPE=--) [ 0.337014] pc : mem_cgroup_get_nr_swap_pages+0x9c/0xf4 [ 0.342289] lr : mem_cgroup_get_nr_swap_pages+0x68/0xf4 [ 0.347564] sp : fffffe0012b6f800 [ 0.350905] x29: fffffe0012b6f800 x28: fffffe00116b3000 [ 0.356268] x27: fffffe0012b6fb00 x26: 0000000000000020 [ 0.361631] x25: 0000000000000000 x24: fffffc00723ffe28 [ 0.366994] x23: fffffe0010d5b468 x22: fffffe00116bfa00 [ 0.372357] x21: fffffe0010aabda8 x20: 0000000000000000 [ 0.377720] x19: 0000000000000000 x18: 0000000000000010 [ 0.383082] x17: 0000000043e612f2 x16: 00000000a9863ed7 [ 0.388445] x15: ffffffffffffffff x14: 202c303d70617773 [ 0.393808] x13: 6f6e5f79726f6d65 x12: 6d5f70756f726763 [ 0.399170] x11: 2073656761705f70 x10: 6177735f726e5f74 [ 0.404533] x9 : fffffe00100e9580 x8 : fffffe0010628160 [ 0.409895] x7 : 00000000000000a8 x6 : fffffe00118f5e5e [ 0.415258] x5 : 0000000000000001 x4 : 0000000000000000 [ 0.420621] x3 : 0000000000000000 x2 : 0000000000000000 [ 0.425983] x1 : 0000000000000000 x0 : fffffc0060079000 [ 0.431346] Call trace: [ 0.433809] mem_cgroup_get_nr_swap_pages+0x9c/0xf4 [ 0.438735] shrink_lruvec+0x404/0x4f8 [ 0.442516] shrink_node+0x1a8/0x688 [ 0.446121] do_try_to_free_pages+0xe8/0x448 [ 0.450429] try_to_free_pages+0x110/0x230 [ 0.454563] __alloc_pages_slowpath.constprop.106+0x2b8/0xb48 [ 0.460366] __alloc_pages_nodemask+0x2ac/0x2f8 [ 0.464938] alloc_page_interleave+0x20/0x90 [ 0.469246] alloc_pages_current+0xdc/0xf8 [ 0.473379] atomic_pool_expand+0x60/0x210 [ 0.477514] __dma_atomic_pool_init+0x50/0xa4 [ 0.481910] dma_atomic_pool_init+0xac/0x158 [ 0.486220] do_one_initcall+0x50/0x218 [ 0.490091] kernel_init_freeable+0x22c/0x2d0 [ 0.494489] kernel_init+0x18/0x110 [ 0.498007] ret_from_fork+0x10/0x18 [ 0.501614] Code: aa1403e3 91106000 97f82a27 14000011 (f940c663) [ 0.507770] ---[ end trace 9795948475817de4 ]--- [ 0.512429] Kernel panic - not syncing: Fatal exception [ 0.517705] Rebooting in 10 seconds.. 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 Acked-by: Michal Hocko --- mm/memcontrol.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 19622328e4b5..8323e4b7b390 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7186,6 +7186,13 @@ static struct cftype memsw_files[] = { { }, /* terminate */ }; +/* + * If mem_cgroup_swap_init() is implemented as a subsys_initcall() + * instead of a core_initcall(), this could mean cgroup_memory_noswap still + * remains set to false even when memcg is disabled via "cgroup_disable=memory" + * boot parameter. This may result in premature OOPS inside + * mem_cgroup_get_nr_swap_pages() function in corner cases. + */ static int __init mem_cgroup_swap_init(void) { /* No memory control -> no swap control */ @@ -7200,6 +7207,6 @@ static int __init mem_cgroup_swap_init(void) return 0; } -subsys_initcall(mem_cgroup_swap_init); +core_initcall(mem_cgroup_swap_init); #endif /* CONFIG_MEMCG_SWAP */ 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;