From patchwork Tue Oct 8 13:27:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13826481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C23ACEF173 for ; Tue, 8 Oct 2024 13:27:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9022A6B0083; Tue, 8 Oct 2024 09:27:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B1FB6B0085; Tue, 8 Oct 2024 09:27:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 779CE6B0088; Tue, 8 Oct 2024 09:27:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5A7F56B0083 for ; Tue, 8 Oct 2024 09:27:42 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ED94414123B for ; Tue, 8 Oct 2024 13:27:40 +0000 (UTC) X-FDA: 82650512322.12.86A27F7 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf04.hostedemail.com (Postfix) with ESMTP id 117214000F for ; Tue, 8 Oct 2024 13:27:39 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JM7qbQqF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728394017; a=rsa-sha256; cv=none; b=8Xn69ifPRu+aPx+Un7iJscgYl4JnbyT7wM9IoaYsy08fdDCfTKBo3PuXvNqUhp6mJUXMa3 LZYZK8t5gdxRBuoVTRISfJsYYslN6E7fkzH1aS6m0/sPstnexwGL5lDIjeM+nlbFh53+m5 SqfHFZQVVvzVigR+L8JDEpqJ+Ag8U6E= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JM7qbQqF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728394017; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=GNRTK4GY4M/5SnKSdR40yf4xxmnZc4ktxUmJ5/TaZVA=; b=i3fj+HPL8PM6hXVVPRkobZpyzdNX84msH5PBTCfcP++T87Ph5y6+RLzjf1M+wwLD2oQGkw opGEZW0fMPGTVO5GFZl2nsP8UJYOHrkfff0mLo7m+ceAwVtqYiXFVonSy0+qxG5WcapQ9h bwAMQPTRWuPtUzb/cCB/dzg2MptZgwQ= Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7c3e1081804so2651507a12.3 for ; Tue, 08 Oct 2024 06:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728394059; x=1728998859; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GNRTK4GY4M/5SnKSdR40yf4xxmnZc4ktxUmJ5/TaZVA=; b=JM7qbQqFmu6CBA6J8Ilg5b0NYukMW/p2JBKmMjY/5abr4Y5/u5oJoMjrgql5Klt9H0 c5PZeWMEpOWYNxbOA+9Lh9bPWL/tnc5KnVqVOk9qspwZoe3FQWyEPMmQA1kSgUfEZTj9 bz6Lg7SEp3tkYmeezlhB8fMUHOFugvJ58fZ+YHJ26ksOX8tr10olBW5jrnUprXUdjcuy drVKvuexoVaBPczEsFnJ57CAOu6vMze7hK78tGgm0oLez2mMyhioX8TOOc4W6fPO4bYn Jk8pOcLd9bWaCBL6LSdyr/1nEDO2AhmAEpwWclOx5NugBCssbjmTX0xKLidQ1EHZqLiF W62A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728394059; x=1728998859; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GNRTK4GY4M/5SnKSdR40yf4xxmnZc4ktxUmJ5/TaZVA=; b=X0uz2P5scE1bALN1kI1axiq+MyuQPqaChP3hWVhj0yjVV810qu3gitFql+EJ+lhAnG N1WA9xG1N+l881YYvDEahmM4SVhw2DmKWneWt/OHydNHHjTAW40RFXxrWYNzixlDqMkM pjf7qmJ6L//c39eDlMULSnopp5wngfShxenRoMaQGhDSuqfwSNMs7QkuT4ayxrijbiwt JMWaRihlBAamHuNeaBQ6SV6lwardhPirxkcdHhU2FuiXjgng8d8Rit3rJ+iDM8FHkCJS XYUYACJvnh942zhrS4ByKM8Vh3glYOcKxXCbc23X1SYJbZqgZKjy7rX3AFn/dt7ePSVi 45NQ== X-Gm-Message-State: AOJu0YwIXTaY7p8IhaGhOdGbEkx57pyxGpQLbirfOOx1WRvOrzshjESr ob8ssbQD/e0T2GkPs2SnZyt7rNnT6eJoPAmf6yEUi0+v5ccWW9D2 X-Google-Smtp-Source: AGHT+IEPBSY9n6qD6ZyvnmB52+tWd6fPMTLLVgOtWzgpTHXZv6NjkRb9kArISqSlxpL+qPUzVtYrRA== X-Received: by 2002:a05:6a20:c886:b0:1cc:da34:585e with SMTP id adf61e73a8af0-1d6dfaee214mr21301979637.46.1728394058567; Tue, 08 Oct 2024 06:27:38 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.87.188]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20af4655dsm7628992a91.27.2024.10.08.06.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 06:27:37 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Sourabh Jain , Hari Bathini , Zi Yan , David Hildenbrand , "Kirill A . Shutemov" , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , "Ritesh Harjani (IBM)" , Sachin P Bappalige Subject: [RFC 1/2] cma: Fix CMA_MIN_ALIGNMENT_BYTES during early_init Date: Tue, 8 Oct 2024 18:57:18 +0530 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 117214000F X-Rspamd-Server: rspam01 X-Stat-Signature: pbhnae3qgqdr5h7j8x6r99krgiywgtgc X-HE-Tag: 1728394059-329132 X-HE-Meta: U2FsdGVkX1881/zcvFdOda2NR19ACGLt5tumQxYnimiyYMPn03WgamREGe6lUT+N31sq/oPowbGo5GGjhdMmDASelEvUDgLjeb30teC6365b692/VULJqGPr2kn2AgVTaKCFe0WYRiDZaDOau6mhg/Sghiok2UmOvvmR5tko5Ius8LotIpwmHHr6x3cyBfSKFSLGgyBYjDF6axHhxhScADxFz0fhN5szdnC5H0+GSJmUpDf5FXg4+ftCMYJs2AaAdpbNDW2xSRwbbNI7AEVEt+Antg5NPJeIXKdoxS0c+2rOD4ccEfak/H4FY8hKgPH3FlqNIdClk5aAJ9dCISzGCzraOb/mJQSxVJK2JlFgnyQ/qND80FSgi655/JQKN/ncwHaWflCOMKJoCqbe7fqz4WMXUtGM2NhYBvoyy3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XWTpi/12cwIc+diDuaN4feiQWzs1w/F4l0RQsvOY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: During early init CMA_MIN_ALIGNMENT_BYTES can be PAGE_SIZE, since pageblock_order is still zero and it gets initialized later during paging_init() e.g. paging_init() -> free_area_init() -> set_pageblock_order(). One such use case is - early_setup() -> early_init_devtree() -> fadump_reserve_mem() This causes CMA memory alignment check to be bypassed in cma_init_reserved_mem(). Then later cma_activate_area() can hit a VM_BUG_ON_PAGE(pfn & ((1 << order) - 1)) if the reserved memory area was not pageblock_order aligned. Instead of fixing it locally for fadump case on PowerPC, I believe this should be fixed for CMA_MIN_ALIGNMENT_BYTES. ============== page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10010 flags: 0x13ffff800000000(node=1|zone=0|lastcpupid=0x7ffff) CMA raw: 013ffff800000000 5deadbeef0000100 5deadbeef0000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: VM_BUG_ON_PAGE(pfn & ((1 << order) - 1)) ------------[ cut here ]------------ kernel BUG at mm/page_alloc.c:778! Call Trace: __free_one_page+0x57c/0x7b0 (unreliable) free_pcppages_bulk+0x1a8/0x2c8 free_unref_page_commit+0x3d4/0x4e4 free_unref_page+0x458/0x6d0 init_cma_reserved_pageblock+0x114/0x198 cma_init_reserved_areas+0x270/0x3e0 do_one_initcall+0x80/0x2f8 kernel_init_freeable+0x33c/0x530 kernel_init+0x34/0x26c ret_from_kernel_user_thread+0x14/0x1c Reported-by: Sachin P Bappalige Signed-off-by: Ritesh Harjani (IBM) --- include/linux/cma.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.46.0 diff --git a/include/linux/cma.h b/include/linux/cma.h index 9db877506ea8..20abc6561bcd 100644 --- a/include/linux/cma.h +++ b/include/linux/cma.h @@ -5,6 +5,7 @@ #include #include #include +#include #ifdef CONFIG_CMA_AREAS #define MAX_CMA_AREAS CONFIG_CMA_AREAS @@ -17,7 +18,8 @@ * -- can deal with only some pageblocks of a higher-order page being * MIGRATE_CMA, we can use pageblock_nr_pages. */ -#define CMA_MIN_ALIGNMENT_PAGES pageblock_nr_pages +#define CMA_MIN_ALIGNMENT_PAGES \ + (1ULL << min_not_zero(MAX_PAGE_ORDER, pageblock_order)) #define CMA_MIN_ALIGNMENT_BYTES (PAGE_SIZE * CMA_MIN_ALIGNMENT_PAGES) struct cma; From patchwork Tue Oct 8 13:27:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13826482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1148CEF172 for ; Tue, 8 Oct 2024 13:27:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46FCA6B0088; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 420416B0089; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2983A6B008A; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 09E686B0088 for ; Tue, 8 Oct 2024 09:27:48 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B465E160C6D for ; Tue, 8 Oct 2024 13:27:46 +0000 (UTC) X-FDA: 82650512574.16.28E9D46 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf11.hostedemail.com (Postfix) with ESMTP id BA15640016 for ; Tue, 8 Oct 2024 13:27:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Qktk4Alp; spf=pass (imf11.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728393997; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=EXrIPW3pgICk2LtzkTwSYks29h8pSEh70VfQM8efFygg2O7hD5ryBk4ycAgq98LAFin0YS Y53coVJs+G06OQiO/5r60tOMuUBBQFPKyyRRES8xUOK2ocsp/OvA2QILdcvc//PtrjrI3G XhvMekGKRmrNBxigkO+8yg1GJ299Oi4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Qktk4Alp; spf=pass (imf11.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728393997; a=rsa-sha256; cv=none; b=XrN5dNkNf/8OKLvxxPgxGjVF/S3de4Os+CKpbt3ZwvUkb8k9u1j3VxvL63z5q95Ax+Bji7 rO2TD7ERxy/doUAZh4S+/uCzJ2TvNYG/XBIhVGZ20itWR7+zpVDlwCkPV6vmyxFNiBnGsr Vx+EdS1GAqSMfR8U2dwyCMoj9gIGKUQ= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ea03ecf191so2025922a12.0 for ; Tue, 08 Oct 2024 06:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728394064; x=1728998864; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=Qktk4Alp8VFPmnvU6WeQScqkwf8PBR2k5uLIGFFH16b0QMJWRnSVnaRLnBUSip9TJa td0GoZpbzuHrXjzUmyzdr3EvNzOQv+LA/WeEkq/8beuxa/p36lREDHu6TIVfaTRHd/t7 YJuxLwYjn6EdfWsEgXFuNt2S2k4Zn9PtjgVoJW8rFVPGXquC9sEIslyeCfst5YbPG472 QRtqjtOGt6IKj/KQ+d9LTQx1F+S22fiuKQB1WUJvvxzy03t0EC2nkBdzlHAj/zgcdHZM 7sCftUr2PThx/L41VRc8u2WNx2MW5e+5CX0pAMpu8dk8FqolP7gPqsUbgl85kt6OgxSJ NFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728394064; x=1728998864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iORC/3+gFiV4oQN4Aw7kbFgz84yNOuZ0Gq1M6ocZ+00=; b=Hr0I9dz59sHnLIflwMCSQH8UmX/ihZZYuUAZbxsEtPjKijGY2mDD0gUn2Df7f/WTCb B+WwQkhASEPW3gHsugS8gGzjG69j9rg8Kh73BwQ193+CCsIBNDmszxd+i97e6VcamBvq dEDqqyGlUgJKU4mxNROSY34bA7QPLiElP9VLhs8/eHnjNcDWFR+jwcZ1mQbV3mu1SI97 SvdUWQSn7vjiTJCXR9/2L6KMprVshe8bPKuE2i4XqiMktI5EQTm/dM1SxA6VfSnZQak6 v2JLZaKYeNVdVfRdfprgaGeJ6NgLuxLQEK9h1sA9AqcLAUjAEYDZejWCD7L+ArhiFcQS ZzfQ== X-Gm-Message-State: AOJu0YyZeh3UNljp6astMVVoA9aXTBrUs1x0Z1d3kBd/bIZxUeocTx6o 1GU1x6/T8dDoT1GWG91f+el/PYxhLjF9+e8aoUO4GnhZCXYotXfK X-Google-Smtp-Source: AGHT+IFUSmB5qj013ukPWcd2PnqbxEbtyk9xGORICVlDGwgM/Alk+7OzaNIs/iU7kZlzw9YIiIXvNQ== X-Received: by 2002:a17:90b:360f:b0:2d8:8175:38c9 with SMTP id 98e67ed59e1d1-2e1e626c076mr18806026a91.20.1728394064555; Tue, 08 Oct 2024 06:27:44 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.87.188]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20af4655dsm7628992a91.27.2024.10.08.06.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 06:27:43 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Sourabh Jain , Hari Bathini , Zi Yan , David Hildenbrand , "Kirill A . Shutemov" , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , "Ritesh Harjani (IBM)" Subject: [RFC 2/2] fadump: Make fadump reserve_dump_area_start CMA aligned in case of holes Date: Tue, 8 Oct 2024 18:57:19 +0530 Message-ID: <7950c20ae9f771a39eb0c0d568beb8681fee0209.1728386179.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: BA15640016 X-Stat-Signature: nqeftae6kwftp8ic4u9ic89sa1nsns4n X-HE-Tag: 1728394065-43924 X-HE-Meta: U2FsdGVkX18a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NzJ/ZW6z/U+gtOmPM8md1o/SzXNCHYZAdZLhv87cCpDkeOI7UiKWsUB8p44F4CHGMswn85zL6ATyyoKlMDPoYxLD5qYz5Or98ke72uQGxMqKTNAEbKLBbs+EaAixvXobimflGXWKAr1sVcm8s32wXsXDYpTHR1yv2XNoXgYmU4we1iv3Y6q0skWBTF5FtFaEL6RL2OAhnA4In03jJx5x2XJBCoo/arivEA15/VFbfWoYEmwVnHCBjwCB4liv7hgW4qmRdDTjepgXnBdE1flnP8E2qYUkZ2B1G/qBoj7CJG5En3Yg+eYEC+e4L0MhiNUGBPOIiAxU7St7H+RbR0KMtaBlZjNyOyZwoiDmwRfDJizE0Zd44i6WxBioTJmgvx/AWX0A4yJ55nxO4dip+KQl/EJE5iu812YOZD55Gp5tPfAbfbZf9qLxfS8PBf2JDQIPoVJdf1AUumIqgo= 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: List-Subscribe: List-Unsubscribe: Consider cma alignment into account while calculating base address for fadump memory allocation. Physical memory ranges can have holes and fadump_locate_reserve_mem() tries to find a suitable base address. If CMA is enabled and fadump nocma is false then we need to consider CMA_MIN_ALIGNMENT_BYTES for reserve_dump_area_start. For e.g. in case of below memory layout, the most suitable base address is 0x00000501000000 for crashkernel=4097M which is 16M (order 8) aligned as expected by CMA_MIN_ALIGNMENT_BYTES on PPC64 during early boot (when pageblock_order is still not initialized) ~ # cat /proc/iomem 00000000-1fffffff : System RAM 100000000-1ffffffff : System RAM 300000000-3ffffffff : System RAM 500200000-9001fffff : System RAM ~ # dmesg |grep -Ei "fadump|cma" fadump: Reserved 4112MB of memory at 0x00000501000000 (System RAM: 25088MB) fadump: Initialized 0x101000000 bytes cma area at 20496MB from 0x1010002a8 bytes of memory reserved for firmware-assisted dump Kernel command line: root=/dev/vda1 console=ttyS0 nokaslr slub_max_order=0 norandmaps noreboot crashkernel=4097M fadump=on disable_radix=no debug_pagealloc=off Memory: 21246656K/25690112K available (31872K kernel code, 4544K rwdata, 17280K rodata, 9216K init, 2212K bss, 218432K reserved, 4210688K cma-reserved) Reported-by: Sourabh Jain Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/kernel/fadump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index a612e7513a4f..15ea9c80bc03 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -512,6 +512,10 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) phys_addr_t mstart, mend; int idx = 0; u64 i, ret = 0; + unsigned long align = PAGE_SIZE; + + if (IS_ENABLED(CONFIG_CMA) && !fw_dump.nocma) + align = CMA_MIN_ALIGNMENT_BYTES; mrngs = reserved_mrange_info.mem_ranges; for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, @@ -520,7 +524,7 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) i, mstart, mend, base); if (mstart > base) - base = PAGE_ALIGN(mstart); + base = ALIGN(mstart, align); while ((mend > base) && ((mend - base) >= size)) { if (!overlaps_reserved_ranges(base, base+size, &idx)) { @@ -529,7 +533,7 @@ static u64 __init fadump_locate_reserve_mem(u64 base, u64 size) } base = mrngs[idx].base + mrngs[idx].size; - base = PAGE_ALIGN(base); + base = ALIGN(base, align); } }