From patchwork Fri Oct 11 07:23:09 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: 13832168 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 7C7AACEDDBD for ; Fri, 11 Oct 2024 07:23:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD6596B0099; Fri, 11 Oct 2024 03:23:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5FBD6B009A; Fri, 11 Oct 2024 03:23:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB3E16B009B; Fri, 11 Oct 2024 03:23:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 863A86B0099 for ; Fri, 11 Oct 2024 03:23:34 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1B200120F1B for ; Fri, 11 Oct 2024 07:23:30 +0000 (UTC) X-FDA: 82660481106.29.0E39197 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf07.hostedemail.com (Postfix) with ESMTP id B955640007 for ; Fri, 11 Oct 2024 07:23:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iztMqpOz; spf=pass (imf07.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.180 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=1728631228; 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=cFXU0lQKXMNLX0e10iqDZMzQn21Hy9EUBSVtGclHKC0=; b=5HNJam+t+SAXTb1/U97uGdpfVWC9TFGYRVIVw0DOe/6SsvCF54gg7/Y4+h8gbgHsYzlqpl 2KwwtAY8vAaSdcpbqFCwnXd7zpBpfSNRJdh81ZUHmhdGsNzr0f98W+Y1uIS7yHCGUwO+ix Cfo6L7IYlnSxtUJfpBIn3IQgUHUUZlc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iztMqpOz; spf=pass (imf07.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.180 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=1728631228; a=rsa-sha256; cv=none; b=LT42FrY4Jg5eg8r8kJVctil/ZQawZZJZr2y8oAYn5QzQxXlvYsD+aOBfXQOEY+wWQIQZwL IY2OlpIb1marVvygWi1SD+zwHswBKSTGrBL+AxSPgeiBvC+AyMYr4I2taZ1GCmhWJVATLO 485+Sb+nmQoxNrSqWVL5yzisH6mCqDU= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20c544d34bcso16337825ad.1 for ; Fri, 11 Oct 2024 00:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728631411; x=1729236211; 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=cFXU0lQKXMNLX0e10iqDZMzQn21Hy9EUBSVtGclHKC0=; b=iztMqpOzHMmWZkhctzxzbRNuNUDFgXDGFkZT/Q0kHFeqfDWEQeNA8AGGbXeN7IVeur adgcjutSU73JXgtvxJ8URNxso1TADjDYL97YqW/BK6+eZdpaoHTVtzDAkw0hHZFCes7d hTbipKMh7/BJtVU3vo8rhbIkgNXp/zQEVw1Ku+VtgEGKSxDo3vKYaZsRxxtWfjk9MrRA z+o63Ncs3bUAkhemlTY7CmEEfBm4m/96kDivrwqJZvssrc/HWnwbvtrt/4J6O+g1hd/a ovLiMnuidIRx99ogKUbQ7v9IAB8iOliiq9cHjAWV0QBvAEl6rYCaPEFtaVI7C9wwkNfq TTRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728631411; x=1729236211; 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=cFXU0lQKXMNLX0e10iqDZMzQn21Hy9EUBSVtGclHKC0=; b=dgjaFX63ZZcvO+X5hVuhWPx6950spt27Dg7ApM3k+iEFiHxQGWW/wyvAvVx3SzY0xZ T7XaXm8QH84B5Lr1k9+4F252LGLfy1X5DfgUoh1oSmV75TAGJVbDeU4JAXRdLmJZGRRr ggoXuoPKgYAGAY/9gVBQ13DeK6gtxP7tr/WJm6PWbikPTrzpZVT/N8LQg/1GrM+W2LGs JxgmO+zcyobQnQX4KE8EG3V26yR5x89w2WRSxRDDW6kG/6Xm1WcHBrhclH7yTYtEIUNb xv4kpTCbD05C5DY6visNoAoxejsarYx2qY9Sd8vgPs4rFpD+UKqTlmV395JmswLPP9yc E9EQ== X-Gm-Message-State: AOJu0Yzklj73enmlZbjvBmFMS5pfMMaMcG39f+raxryQDYUHteIQe4NZ 5T89kisDIzjrOuo7UffU+P0m/C0TKW67cZdc5RXNwyD3eUYGGPb3 X-Google-Smtp-Source: AGHT+IGQ8iq1sir1NebxPCSK/DS4CJ2zGOXIXoa+HRwjhD+gjsmYWNAElhY1mGxdYNMN7u4TdJpehw== X-Received: by 2002:a17:902:d2c8:b0:206:96bf:b0cf with SMTP id d9443c01a7336-20ca1315240mr25369385ad.0.1728631410877; Fri, 11 Oct 2024 00:23:30 -0700 (PDT) Received: from dw-tp.ibmuc.com ([49.205.218.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8bad335dsm18825155ad.50.2024.10.11.00.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 00:23:30 -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 , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [RFC v2 1/4] cma: Enforce non-zero pageblock_order during cma_init_reserved_mem() Date: Fri, 11 Oct 2024 12:53:09 +0530 Message-ID: <8579f887412720bd6f2fbce513c1c9904772ead4.1728585512.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B955640007 X-Stat-Signature: sjhb9n79ytf1jkj9uq1qqifycqyeoi1b X-Rspam-User: X-HE-Tag: 1728631408-97627 X-HE-Meta: U2FsdGVkX18FXjJHWphfOnHxPVGWUb8rMDoWamLoTObVoV7PMbej4R9W8O7azbbaTtoC3mYt+phmXDj9kVhz7WPOKaRs4pqjHL9L+M1+38uYE13pW6RlVE60hZ4+livIY/POwCHNPknHa/ylTcOdfBjaLaH0C7L94iNpS1Wbv22+kvTHf5Ab70hVSdZKqm9KbgYf1BWwh+6yr3SLsS6g5jcfl2BMrQGKyNEt2vEDF9O0o7Hea7m3U121uFWtOxftdZMxLU4AjQuBSA/0b+MhaaZvEnXx9mbmORjmzd7EkV53tqcpKoL0z/UlI5L9hPSb2DZHeys76B8mJOuG2B3kCPBLKYI+pEY4hgja83qhFg0GU9k05bqg4pn0RBLJS7gXD97d3kOXQ6NL1uvaB4DGaUH/DZmhrVAqHRt6/ijjOGqWaYJnils8IxK2PVuAzAd3ph/i5C4XkKmE3lLUhyonAww4JuPwx85EAZb8ka6m/E185oFeX/1LuvMTVQ+VO3sXyRFy+NaoN6E3KN8Au1R2B4UgLVdoTAbGOLfZ4hT1yBPTg1EsxiFDC/E/0/hM8CeLIyq7AuEI26yNu95kxT6hRiTwHBVvMzjdkLi4MnDksBYNsSYooUtWRYJDRblaDxJh57Rv7h+rwx0bfs5d+ZHGFRFgJRaWHiDb0TzY5BmytmingQDb8dp87lvobksLXGCkVn+QM3blmQNpyMy3RuPJ4SZ2kt79WWQof9gaR5TytChFKZQdzueb4xy79cJS973WiEPYcOYqzG+jiCP0R5JpCzrQsu2IWuwIOSssgGlNLLW8XTz1w8t+N5fmaSBHcTGtGzsacsUiCxfvthOF8xA9Q8OrCeA80+RD9H+04/gYbEA3C2AOXkOGq7g5weDr9zTM7CZdJxP+zyhdVQW2IhlDgDjIicGxulgkSu2uYu+DjsauWsE1uXliDDv3B0gQ46xBMST00Wdl9P6u+B30dr3 u0ZpB2dl wGAn8n7wvnnqYzFms76XFYc0177tMxe4QnVAle2yfIGEoX3yjGymmwnx4WVGPByRNZtwew7xWbQnoBbP2B3FkgX8Gy87EmhhSt61vjqd3f9MhTbUJ39QhnUIZLlFT3M3OHUjkSqMbkF/c3++koBy79dAl5eP7LDBBKczYQzVlEwI7sjZg/rUusqo10e0yRAVm+enDGR9oNu7NWyg5f8ZCDb/A6eOQqcmmHV9zJ/pVedbyUKAvqJEFTAb04VsD7gRXm5wsk5hk2+8/B+BA2HTSeAOcYxVySaYwMdDnNRM18Xv0vx/7HxohXVUZ9YDTVz9mtcdc3OiHLUumu0ovGfboe6ojIdAmRCSfDXcpWL4ymupbLXcXkpNy295Rt4D43PmA3LaYwiaWOXkjjFdKpIk2NrUHPWvRAnns+lk/QPDSeRxeT1KP/plSo0xSS0oJZ6jRooZicW6nrDgZSksmhxJmfuYH3RS2cZTxzidD4KbYBvtHahOGhCjoY/IS3sPDfCmZ6MzVo5FpyjqeE+BfYZrF+prHdA== 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: cma_init_reserved_mem() checks base and size alignment with CMA_MIN_ALIGNMENT_BYTES. However, some users might call this during early boot when pageblock_order is 0. That means if base and size does not have pageblock_order alignment, it can cause functional failures during cma activate area. So let's enforce pageblock_order to be non-zero during cma_init_reserved_mem(). Signed-off-by: Ritesh Harjani (IBM) Acked-by: David Hildenbrand --- mm/cma.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/cma.c b/mm/cma.c index 3e9724716bad..36d753e7a0bf 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -182,6 +182,15 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, if (!size || !memblock_is_region_reserved(base, size)) return -EINVAL; + /* + * CMA uses CMA_MIN_ALIGNMENT_BYTES as alignment requirement which + * needs pageblock_order to be initialized. Let's enforce it. + */ + if (!pageblock_order) { + pr_err("pageblock_order not yet initialized. Called during early boot?\n"); + return -EINVAL; + } + /* ensure minimal alignment required by mm core */ if (!IS_ALIGNED(base | size, CMA_MIN_ALIGNMENT_BYTES)) return -EINVAL; From patchwork Fri Oct 11 07:23:10 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: 13832169 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 5CA40CEDDBD for ; Fri, 11 Oct 2024 07:23:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC41C6B009B; Fri, 11 Oct 2024 03:23:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4A776B009C; Fri, 11 Oct 2024 03:23:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC40B6B009D; Fri, 11 Oct 2024 03:23:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 979B46B009B for ; Fri, 11 Oct 2024 03:23:40 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7315C80E65 for ; Fri, 11 Oct 2024 07:23:36 +0000 (UTC) X-FDA: 82660481316.17.B99EDA6 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 89DC4160017 for ; Fri, 11 Oct 2024 07:23:36 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hXLj4LOG; spf=pass (imf08.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.178 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=1728631281; 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=e0XcJo9JGEctgbuPEWvt7vh5Yz6kEP61gEF6kN7DKNI=; b=wBVt8kT2fMj7JH/Vu5c3P1iA9P8X6ty/idYXk66p9EKc4mgMdixvNrRvvo2XXnxC2tALE6 K8hDmcB0Vh/qHCMFQrpveyxUurwB1H18iceC7IZtrHYpfrFOlpFn/fpS65K/s3PXhPcst8 /GfGKsuc4DKPJiWWcI39ReM6uRtRwdA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728631281; a=rsa-sha256; cv=none; b=puSvftnn8bCjQur+OFHUSwEjAKRp4R9NXxKlMwrK9mwru5UFuT/bl+F6ySNoL2UqAEQ4d/ uZ7Fg+ravuaUS+BOsyUvqSNFtG2bTJguUo3EWvWmL3n4r7X2hDuX77/+bCZA7SPyyE4v/j lghjWd6/aFSVyG+B7HGQS02yO4CHr2s= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hXLj4LOG; spf=pass (imf08.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71dec1cf48fso1511813b3a.0 for ; Fri, 11 Oct 2024 00:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728631417; x=1729236217; 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=e0XcJo9JGEctgbuPEWvt7vh5Yz6kEP61gEF6kN7DKNI=; b=hXLj4LOG69YxaYnJMtyH7nlRvdMz3LizPLrUT5VaZ1ORqA0s8braICJjjSCQyeOLLc a/MkqTWzyGpJYc8f7sJpXlRt1tXFAA6+DG1Nt/RQdtwJ9/fZgiqwBLt8As+aKR/rmvyK 9SQzjFDsUOpR++2f021mq+DAJb2hwSbC13C1mVv6h42z8BZfuyeVINyttEXCEHmxueaZ i4z5hjmy3yaAvHyLqolIejYFigd7Id1Mr9FtJHRSS5R6cB12iZssXbWp1KEaxY+fQ3kG ZUs5znNROrtd7kn/HKk7GYsoJUBjcwBPX7zinz+uArQP72sY4MGvdPGBFDFkgbL/UcHi xfWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728631417; x=1729236217; 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=e0XcJo9JGEctgbuPEWvt7vh5Yz6kEP61gEF6kN7DKNI=; b=BvpdDRya+P/dGUhC8t4QxL4NcL0rgZpg/ZwfI+p+KElj/VFNsvV6aMDejX3T5P8yxn QkjX8uT+ZSUvTiKFSAg0zV8bdWIzhNoDJCD/IVGqaYt8F5gE11bvaPBUXxaAH5gb0dIK TDwX2vsMDtAJVsGYQVsQ2LoMANqaj8LOHw57w87C4jkliZ5VM9ZayssBbOsxxDX4U0+p kwWk7hLhMNbILNrICnxoKb6nu+qc68ujr6m9i9gC1r/wkJWCq6C9TxwsXx0S0tvKycNZ fTYmf9KGFYA4USIfnyEPHQxGmcsGvkn/5p+q0OD+BpfaTra3fdumU20oKZUmL/u+T+eZ K2ZA== X-Gm-Message-State: AOJu0YwmUhJoP2vNgHZgrWI3ThUpzFTErVwICj5/DGF3DZMAIr9UL//4 VtpWyaWoDB8lSRk8GssiARf0jDcpr0R+07j5sPSQcmKPDnpygkZR X-Google-Smtp-Source: AGHT+IFVJLbjrihstm+z1iQykRd1RHjrMq1OggwLcM33etRABky007jtDtqG43IWWvWSUwC4nwqrng== X-Received: by 2002:a05:6a21:6b0a:b0:1d6:de67:91ca with SMTP id adf61e73a8af0-1d8bcefd51bmr2327071637.4.1728631416985; Fri, 11 Oct 2024 00:23:36 -0700 (PDT) Received: from dw-tp.ibmuc.com ([49.205.218.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8bad335dsm18825155ad.50.2024.10.11.00.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 00:23:36 -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 , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [RFC v2 2/4] fadump: Refactor and prepare fadump_cma_init for late init Date: Fri, 11 Oct 2024 12:53:10 +0530 Message-ID: <079e98d7db3b63bc8a568f4e8c03f2976878ae23.1728585512.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 89DC4160017 X-Stat-Signature: 71biq6oaqafnu7njiymkyu6sfeax7a4w X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1728631416-323873 X-HE-Meta: U2FsdGVkX1/cQktO0acGNVIAq6J9ndVz0DFxQN1cOyXNbDaDjxrYhCKdSyoPPL0PmOc+BpkhoyX5ZIvn8uvUm+eryUMAxmmwPUt/ii6esvL9B+fvpIq7ZV176kKQ0X3iqlYAuA3RXOExtiCpSLjtrvdlwwxj4AjujhEX00l9DjXeesD2CAtkYgHTgTvi7+gLs+dYWN9Spfl6aJ+7xd0kHOUXqWMkVXtgh8RlMeJAiyINsJ4K3R8N5M1hTG9fvXXoGhfmHLZPhXUkZ3SAod4IFNF67YHf/I6qMS8KnvBJpqhvob9fBbnm9vUfzly0kyJ8KbbM0B5CcLrZ11wApZae6CUH8FsJGM/pFY1Gv16VHUuSVk/JEVrOqYY4fqVOcFxyunZuEZ8TVenMJo42hBpdiflIKH3M6+1NZvbENlFmKSiB/7GIO87EBl4Xm+DGYdP+VQSfePI9/hWeeZo8Yz0htigDmoUpZBySRUpobB+bePdqDk/2mpBgVwDD/q3uuCPWA4VheLN2u7Mzdqhyn/KJDztM7wLCzhJdTvgfqnPzLVc67VD889zlaE4qd1sDXhAfQM2ws4j71L7d5BMvtm3rQVZE3rXAWd+HWnOx3LckqP8YtpWei6Y0Bpd1ZmX1UlWzPP5YiRaB/O4WdzSFjbthSvzBwnWSJgR8s2cUijf7TTv87LzGFLQxuiQxcs9Qb9Jkgq8J2R4hcDLBPNLPhkiJqc0bIzoTV26sx+Anid8bmTjNF9JwalGerGUaaVh0QNuWfVvajA98Xo4nYRScWQ4vj3ayIVgngsGf7kRTHzKqrt0Y3enb1/O5vgrg59VszTB2Eb5zWmSj1Wh5Vk/PEFIL8fYYwUKIsurZT/6/mWAeGLf0seT3IVRa9cJABNnW+hQH2YtTabqSqwUo4JfpTnD/Q0C4lBa6tF8vZ6Ops2RaIFv+UuAdYza+ucoRejeAcEBILzmr0SQ/bMNjz0JWkjd CisurtyK /B70i7QZ/1JclIn4d61/VpsIu5BUb0PCJk9WAz7jp4RPwrSWi0zn5ax8qUhIVHhK0m5wPZrTndXHnefi0YmvjJ+TSkhdxdj4kvMost5A7U6CwaAD2UBhEhs0n2NHM0Q3qPkli7vE2p7uWGg9CoNtC6C8GCq+BsgavvDAiBnkGi2DzTab0b4oOky+yf2Vc6MpAsWEYuq/Vd4lkJ69FyIMGnJktgMK9jlkYk1mjNHSTlTlVg7Khmwy46yMZQJL1qkr+Gs7iKB4V+xXnlQTCLAPR9Bi/0Yj4HCxbLnMFLBZiVcZcRHupKfaI74fPtizBdUZuwlvfw0QSufuzIWLV7TDStX4SooyPbMCX4KmcyXWXjX3wFrL5fsfbfWEPlNWzE963q1uNWKfMExbFa0yZBjus1C4ZVp+tooSVaYRbe/mM4Xp7jCoongRSSSwZDjIi/jJ85SVx5KoomPEKdyx4qZ6MciV8892V+Symkn2oZokR4FTN3CU3u8jtitcVCaJ2d96SBpVgyPCcy0YRerhllFGK68OAtw== 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: We anyway don't use any return values from fadump_cma_init(). Since fadump_reserve_mem() from where fadump_cma_init() gets called today, already has the required checks. This patch makes this function return type as void. Let's also handle extra cases like return if fadump_supported is false or dump_active, so that in later patches we can call fadump_cma_init() separately from setup_arch(). Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/kernel/fadump.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index a612e7513a4f..162327d66982 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -78,27 +78,23 @@ static struct cma *fadump_cma; * But for some reason even if it fails we still have the memory reservation * with us and we can still continue doing fadump. */ -static int __init fadump_cma_init(void) +static void __init fadump_cma_init(void) { unsigned long long base, size; int rc; - if (!fw_dump.fadump_enabled) - return 0; - + if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled || + fw_dump.dump_active) + return; /* * Do not use CMA if user has provided fadump=nocma kernel parameter. - * Return 1 to continue with fadump old behaviour. */ - if (fw_dump.nocma) - return 1; + if (fw_dump.nocma || !fw_dump.boot_memory_size) + return; base = fw_dump.reserve_dump_area_start; size = fw_dump.boot_memory_size; - if (!size) - return 0; - rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma); if (rc) { pr_err("Failed to init cma area for firmware-assisted dump,%d\n", rc); @@ -108,7 +104,7 @@ static int __init fadump_cma_init(void) * blocked from production system usage. Hence return 1, * so that we can continue with fadump. */ - return 1; + return; } /* @@ -125,10 +121,9 @@ static int __init fadump_cma_init(void) cma_get_size(fadump_cma), (unsigned long)cma_get_base(fadump_cma) >> 20, fw_dump.reserve_dump_area_size); - return 1; } #else -static int __init fadump_cma_init(void) { return 1; } +static void __init fadump_cma_init(void) { } #endif /* CONFIG_CMA */ /* @@ -638,7 +633,7 @@ int __init fadump_reserve_mem(void) pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n", (size >> 20), base, (memblock_phys_mem_size() >> 20)); - ret = fadump_cma_init(); + fadump_cma_init(); } return ret; From patchwork Fri Oct 11 07:23:11 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: 13832170 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 C911BCEDDBD for ; Fri, 11 Oct 2024 07:23:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ABD06B009D; Fri, 11 Oct 2024 03:23:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5349B6B009E; Fri, 11 Oct 2024 03:23:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AE3A6B009F; Fri, 11 Oct 2024 03:23:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 13EF56B009D for ; Fri, 11 Oct 2024 03:23:46 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2B2021C6896 for ; Fri, 11 Oct 2024 07:23:41 +0000 (UTC) X-FDA: 82660481568.30.D693F13 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf28.hostedemail.com (Postfix) with ESMTP id EA509C0015 for ; Fri, 11 Oct 2024 07:23:41 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TAsmqUf9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728631322; a=rsa-sha256; cv=none; b=gaDh2i4z8wJlzy3a9yjT4WIXoiwFGpV6XOwta0NkyIDXBaW/eMb25UeMzTtNAJT5dLxQl3 n8edxA/8QD2nu/DVQZqu8sgvBkTwGaQM4klRI2s+csGfzeDfyPlqDkpFhJfUQwsHQddPjO IpuUzE/uEzez1X5LjtjWLUr/5QdoKeA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TAsmqUf9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf28.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.178 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=1728631322; 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=5ubewzzmHjedesx22pwLGzOS0cZPbgARDYakPnaDJMA=; b=afwft46sx9HPrM9fy2qJuQkbYHuGynefpzhcRLco9KXW4Cbp24HGJYINz+P8saezUs9WlS 4rAoEZK67cUJ4qtZXpeuCpZTS6IlN5JF05A7IltkLGeNUDEsPICJERpzvkWcI/qbbOqdzD 7RzVeEEcXg4YnM8zvYp7IlOblzQw28E= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20caccadbeeso1156045ad.2 for ; Fri, 11 Oct 2024 00:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728631423; x=1729236223; 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=5ubewzzmHjedesx22pwLGzOS0cZPbgARDYakPnaDJMA=; b=TAsmqUf9mP8mvVuH2Bu3B8CSN1BS50+jH2gC7D1IflAC+BBDZfJe/pxvgHh4lx62DQ 0djqK39N3bYIVX2o/dLteoh18q6kefcF/Wud58Hs5IjXbK4hCuArezWmLYG+gxlB4s51 0LxlApYZYqakMECGWiRa/MhaajhsvXM708yLW4oj3h0g2LUxwR/me1kw5m5J5SZWESCi ZdtHpVuniSmHti75GsJmGjSAcK2QxO7dgr66FpXip5vJ/pRUD8SEZOReJOyrk+R9W5P7 Jp1/HQZ7P+RXUoFyplIQSMvVdLPExVN91I4z8MdNfDtcKYa0QlMueifkcQp8PfZ9xHAb u7IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728631423; x=1729236223; 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=5ubewzzmHjedesx22pwLGzOS0cZPbgARDYakPnaDJMA=; b=XRfC2DvvoEo4vJeRnTNdiqvlUfTkS3HQg7y+sobhiKrA7spuIStaLKLR4LoxvX1NXU vvGz8dADGA8/+fzZpa6UUWk75TvaIsfC0tz8h0DrVGwZZYP6xWJ3Om6kU0Ig+fUJJyPN cj8JSSaQNkxFgl1i96p3vaNHPv9tX+/Sj6zzRph5vRcAUMsq183OjzEW7uEeI5ObQRIG bCWlBm4+2tPrLB5opD4oj/x88uUeMxCjzJp5uZzG67lidHbHHUyzwFczPM3EOj3gB1r+ WPbEmnBMxlbJcuU9qEc+dG5mjJVxtVuLFF/66/MfJa+PWtTt7M8gsXpU4p3jhQ1JIez7 1Bwg== X-Gm-Message-State: AOJu0YyhBnxZ1DXDwKOcXzTnR5kpjO+SawYnpf22SwMaXI0E/VLDY1CE i4Y7ZbU/xcaoe5zJMMJwg1k4m00TfZ+WfHyW9obrnGYAqABIWGXcijuALw== X-Google-Smtp-Source: AGHT+IGf9QK0QpSNxbm45T2FEivaCIusibESERuvwR9YsSh8uK+WhxBRvYeFa70z9Xc08Q9BwN2JgQ== X-Received: by 2002:a17:902:fc8f:b0:20b:5231:cd61 with SMTP id d9443c01a7336-20ca14732d9mr21408005ad.24.1728631422585; Fri, 11 Oct 2024 00:23:42 -0700 (PDT) Received: from dw-tp.ibmuc.com ([49.205.218.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8bad335dsm18825155ad.50.2024.10.11.00.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 00:23:41 -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 , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [RFC v2 3/4] fadump: Reserve page-aligned boot_memory_size during fadump_reserve_mem Date: Fri, 11 Oct 2024 12:53:11 +0530 Message-ID: <4cea3a03fb0a9f52dbd6b62ec21209abf14fb7bf.1728585512.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: EA509C0015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9trjsthgfa3zc9tfzx1b8tfx53g9nit1 X-HE-Tag: 1728631421-555881 X-HE-Meta: U2FsdGVkX19W9W/iJlB9kpFRWJWWSVjTjZKNlScLAipKw1HCSKa+gvsymGKqi6q+fYHcFsIC7CWASgRqbE6YpYwOMxEbqp41oG020d+ECUXbEd5Tf7Q0jKaVGYZm1uZfM23nnWlbnmnARKhaPilMImbbcp4w5cnjAnhbn7Zd9Ewz4u4UroJySvPWVaz/rT59jwBl6DuHSiVuiyvF4DOFm8O/hRu0Rw9aQ4DiQqYzRs3z7Qp1wVDLAIE/0eBgaxCOSKwaMy5qReVOnEU0XqbPmbOoKzXVpkZdmUXVxvpq8lJwfvUleFY/06UjnmDDoMKHK2PLKQy2MEzV9VEwvxwBY0cztNXUJ5Y9EJzNvwl/IEi0akY8K6ykW1W5KEYxtiaCSG/KFeKXU9e+F2Byx6pFuWMJBdpry5z7uHFQA4eV5YHjrA5uRzXvS4B6WytReUskW0oRk/WdgZFGcit6eE6AsacLOQv8jFAn4aujSLZzSQYpl0O3G6bxkOZgDBSFZUErnW+SGeitxQfWPRX3QA98ZfBHxo6tsbbOhP/Z86BnNn6/96vcmZRe6JTlx3fskHZZ8DnaDtGMxAXMk+FGixtZrpAPj/12CKRpSR7vGCEEA8A0ktuy2snMXXavKjvRxnJC38uWfDr73CLGcb+9ks2IrEZUMUz/201nz6QshJcA2IFOoFzZD2tjlYwSHVjLsy0H6YHMZLsn405sK7IX/rkRDHnOxbfKwBrjpY/c4nufMujFKmWSvoVN7GXRvh1+WDy68LbVJ1Vk2q11rpQpmB2na0iyHk8XOpZZeUQecnJCLRctKDwddn/YSsoVuJfTt7gCYXHCZCWZ+GeKTkhkS7bdNER2lKBM7Fnx99qE8XVFzHZEZ/g53lotz0sI20qSmfkInJIfG5Xc/YQEoB27k92Yfrx0HALqI+yvtlfIUg/89r/y1KoAa+expokCdHH46qWDYyCIDmz7jK+RwrPbZie YkanhcOc 4yuMKTyOUqROPrs/vq0ZS8l0bDelG1UJzCDHsTslao93HyLhUbekZZRwTmrw82ls72szZu4ZWZrmeFxYAofLRx2431mVmAuzq74M7p7nqjasKT9wIaqD7LWe02kp266Dr08ybxH0CwvbuP8GBihBnhhoB9hZc40sW88u9Jbb+v714DuOh4ldh3391msw5u+BlseJLtDHN2auarKRhCP6Hg7eDopG8KiBWLKT6CQXiDH0bSS8AmS1YPo5iB6RjTW4ZTQ22ywStM4tIiQvJ0ek9Ro1VibcOgHfB0n5Lpq0m5zt78sU5xBjJVj0v/PolenvQ+87RPIVX7K1M5caGW6lMwDBOU+CZQkjITPYB1NTTxvEzaW+Q0WknQkPi1IVpn59lLGbYgj6lHH0dKqxZkN9qSCADxBzeqm96X+xWpbohUbIGkWNafB+vZq/Xc1iCAv3FrE3g3D7FDk2Q2HzpSp7auZZ3XcUt5ynON71MKdzG8g6/Pp9X4TzhQTsaRaoWlxiHW2RC5Mq+hgXE0cKZtI5VmJ9OnhNTb4A6EM2AFFjSYfb1pQQ= 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: This patch refactors all CMA related initialization and alignment code to within fadump_cma_init() which gets called in the end. This also means that we keep [reserve_dump_area_start, boot_memory_size] page aligned during fadump_reserve_mem(). Then later in fadump_cma_init() we extract the aligned chunk and provide it to CMA. This inherently also fixes an issue in the current code where the reserve_dump_area_start is not aligned when the physical memory can have holes and the suitable chunk starts at an unaligned boundary. After this we should be able to call fadump_cma_init() independently later in setup_arch() where pageblock_order is non-zero. Suggested-by: Sourabh Jain Signed-off-by: Ritesh Harjani (IBM) Acked-by: Hari Bathini --- arch/powerpc/kernel/fadump.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 162327d66982..ffaec625b7a8 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -80,7 +80,7 @@ static struct cma *fadump_cma; */ static void __init fadump_cma_init(void) { - unsigned long long base, size; + unsigned long long base, size, end; int rc; if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled || @@ -92,8 +92,24 @@ static void __init fadump_cma_init(void) if (fw_dump.nocma || !fw_dump.boot_memory_size) return; + /* + * [base, end) should be reserved during early init in + * fadump_reserve_mem(). No need to check this here as + * cma_init_reserved_mem() already checks for overlap. + * Here we give the aligned chunk of this reserved memory to CMA. + */ base = fw_dump.reserve_dump_area_start; size = fw_dump.boot_memory_size; + end = base + size; + + base = ALIGN(base, CMA_MIN_ALIGNMENT_BYTES); + end = ALIGN_DOWN(end, CMA_MIN_ALIGNMENT_BYTES); + size = end - base; + + if (end <= base) { + pr_warn("%s: Too less memory to give to CMA\n", __func__); + return; + } rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma); if (rc) { @@ -116,11 +132,12 @@ static void __init fadump_cma_init(void) /* * So we now have successfully initialized cma area for fadump. */ - pr_info("Initialized 0x%lx bytes cma area at %ldMB from 0x%lx " + pr_info("Initialized [0x%llx, %luMB] cma area from [0x%lx, %luMB] " "bytes of memory reserved for firmware-assisted dump\n", - cma_get_size(fadump_cma), - (unsigned long)cma_get_base(fadump_cma) >> 20, - fw_dump.reserve_dump_area_size); + cma_get_base(fadump_cma), cma_get_size(fadump_cma) >> 20, + fw_dump.reserve_dump_area_start, + fw_dump.boot_memory_size >> 20); + return; } #else static void __init fadump_cma_init(void) { } @@ -553,13 +570,6 @@ int __init fadump_reserve_mem(void) if (!fw_dump.dump_active) { fw_dump.boot_memory_size = PAGE_ALIGN(fadump_calculate_reserve_size()); -#ifdef CONFIG_CMA - if (!fw_dump.nocma) { - fw_dump.boot_memory_size = - ALIGN(fw_dump.boot_memory_size, - CMA_MIN_ALIGNMENT_BYTES); - } -#endif bootmem_min = fw_dump.ops->fadump_get_bootmem_min(); if (fw_dump.boot_memory_size < bootmem_min) { From patchwork Fri Oct 11 07:23:12 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: 13832171 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 BD588CFC5FB for ; Fri, 11 Oct 2024 07:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4259C6B009F; Fri, 11 Oct 2024 03:23:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AE4B6B00A0; Fri, 11 Oct 2024 03:23:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 228196B00A1; Fri, 11 Oct 2024 03:23:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F36456B009F for ; Fri, 11 Oct 2024 03:23:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2A91180E60 for ; Fri, 11 Oct 2024 07:23:48 +0000 (UTC) X-FDA: 82660481862.28.A59EF28 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf30.hostedemail.com (Postfix) with ESMTP id 2535C80007 for ; Fri, 11 Oct 2024 07:23:45 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IU0Lhsrr; spf=pass (imf30.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.177 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=1728631385; 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=43KeZkjM4JRDWlxAgOLwxp7bBo4Ct6yjaya1Z8Z5TnE=; b=4YYeFGmXibjUGvkP41q01/mhRSDf1mXK94Lx0pbI7bcpgDOe5E6//s6tddloueurDqOndV 0xt81AV7AmzJB3Ck7uNh8g/7PRdqDi9BdjqybWBu9fNA6Tr2BNjFypNxhJ8lFO2ab9LMyH jjnQIGdGq7F1d/mHW3zDNzkF/7y8aao= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IU0Lhsrr; spf=pass (imf30.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.214.177 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=1728631385; a=rsa-sha256; cv=none; b=x1zSqo5JLObb/FtZAg+ro7+sCNs2UZW36/aF4S/Q+XVEzJIIf0dKj7W0+gLfvuXdfaJkjn kjw0hWUqPeDeimU/ayIZH8Tm8APrH8CkEpGakIegzrrqRUg3SjYPIaqVve94l2bS2uYHco UZJ62rmoNuFNMhwpfMRhfRKE5rPUGpo= Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20b9b35c7c7so11569705ad.1 for ; Fri, 11 Oct 2024 00:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728631429; x=1729236229; 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=43KeZkjM4JRDWlxAgOLwxp7bBo4Ct6yjaya1Z8Z5TnE=; b=IU0LhsrrbncJlRyIDcAITWYg0A6gknnHfg3REkEIKZIXX4vkjEXeYCr/WV4nJ7vEFl 60knVd3NIet0vjvCXABFVzfgRDXt7wyjYuVEpxBmPKW76KBSJD6V2sfF3ZyyIO7A7b+Z V7bRtVi0NnSGq/Jffa5bpHA/S2Mg0BJQ7kHCl2JMNUw+S3ZzOb6GK0WgJey0lHJNYeOO GyqRBUeS7qmfztwL/ZjiDkMkffw3E+nvN5C6WLwSwUj4G0PoHI/cbThIMXG3szNsu6F1 Buf688kv5Hk/4CSaYw5ADvWoMXMTjs16bCjnJb9b5DKjV7dPNqzLJiOiHU90MdSAQIMa 7gxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728631429; x=1729236229; 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=43KeZkjM4JRDWlxAgOLwxp7bBo4Ct6yjaya1Z8Z5TnE=; b=Gv295gLmr1GLnVrAKKNYOZ1qzwdlP4tpz7GhG1KaPRl58rIAGtx2d4d7frotEnDxx+ VRQseCvjokEtpZl/Q4HstE6pFiCnaOIVibeBYl3is1z1Yq8dcwdxdrEt1p3BrJm7dHCY DCU3ziJvnYqjKeKxMSja9sdmp0rm7KqcbhQ2j5JbAK7pAmVrbkC5E18CEOqcxIe8f1Rr SrBP68UvyVbuN1myHvuUs06vlV6z4x7Uzkz6JYoeaA6FBLbnibnMgKTCZR96Qt02QPoB za/fjNaF+aWD/9ZCwVkmNuM6Mi7XCSKb0ABgBbIieZXe+ca/sDiHACfWU+UTEUlklWOu L7Fw== X-Gm-Message-State: AOJu0YzUNjLJAsR+ShcvZjQOovCIYr4vnOcN81MdXwWTWjfZxFDQD5LE OlBG5b3B7N9hHGhWoqsihCwJt6CEehCU5qv7e1wnjMK7zc7RoQJ8 X-Google-Smtp-Source: AGHT+IHvKjtMrFH1g3CLZPdSwjhTqkQHVaREuW1zEqrR1VLtKD+N3w5sn140uSYgK0zgLCGlE26s+w== X-Received: by 2002:a17:903:228b:b0:20b:fa34:7325 with SMTP id d9443c01a7336-20ca16c5acfmr22757985ad.43.1728631428668; Fri, 11 Oct 2024 00:23:48 -0700 (PDT) Received: from dw-tp.ibmuc.com ([49.205.218.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8bad335dsm18825155ad.50.2024.10.11.00.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 00:23:48 -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 , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [RFC v2 4/4] fadump: Move fadump_cma_init to setup_arch() after initmem_init() Date: Fri, 11 Oct 2024 12:53:12 +0530 Message-ID: <819b34cc6dd63e21f142c1adbc1a88bc57f3db54.1728585512.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hxkac47fdjw3bicdnwm3oeniwxg4i356 X-Rspamd-Queue-Id: 2535C80007 X-Rspamd-Server: rspam11 X-HE-Tag: 1728631425-997189 X-HE-Meta: U2FsdGVkX1/FLfraOJzIAP+/DjCnleFatI8fZ7R+UWMScMEnXYTnidl9BtNfqnzQ0HhgEEjnQbQAA/tlhtP6oOYm5OBkwpNiVIdtQoDnXArgUJ4wRyPUvtjfkBVIwystGmo0mSw8a3ZRjz1Qe1A/QIN3vxYMAFNE+tZKaD20bv3U76o/dnwPAS1eVSGqY2bA3Sn/xV2vt/+pTzO2+wYLaXRfnKX6PU0FeGGR6l0SeSzZ8wpD0NsS3yDK3QodAzdEkwsaiSADku7Nd8e/HN/ByNYLC5EnG1rw4SqagOugmN0QoUJJdhWiBFa+Xf0/6rElzYwC9Q2FvhrRpoZU3wGwjdwWXXbiKLlS0LMf32kHj3B8JUB1rR0Lj3cKJZFnxlQW1J49iqclXo5lvK11zDlK5x1o1wJSAJqewI2hgpE2dQQmouzkRbV211a+htsHFoaz0P8jZEJtb6Mu/qLmsEOkSbX2UF1GvUk3TOa9WkQfpE8dQ/AxJp64/2JY+PgYqtW8kXJ7UUCAtn2dBWN4AT6hlB6ids+iArFHLm93Ftp0dpIPo4RF4ffwBTIVSGfZVTIHEGwdwNLmdFh5M2tW+0oZcL8DsUzJ/Cnmrtw7pTXmMwlu7smIqjZflXpBssIJa9AFmZjFi3a4jF8AgOdecibTLkqgBdA/qyIZiYaCd4qPfkYXW75nALC1ycTcI6nnM8X1Ug5mF8yxUkhan1IC4uH2oIL3oSTNMuQV3GWL2smEzi2BrrngWrG5jcE0AMez1jFeBsiSsoOhIh/dn2IkZEpZ5ChfTTjO7Xy5Zc/lMcwNV1VUxwtUGuw166DlpuIV1dxMoCQjVFWBvoxAzdYbIA7XjrtvsrS0tokUeLDkrtlQl45jvWwltm2d3V67FGJYoMeIPxbb++Hil/6BAX4vLkoK/jLQFXonczYSBlAEfLiBBy9I+tDBj2b28EfO207WTS7Eby8X/cY7OGtHl8iAUCt OsNfr2yf g2S0j8VcHKSRPOFrdXHlwf9llvkjZJlHuSrNoVQt9pfQxiPR9Zmvwnupm4z7Jn/D2RY3B3vC06rIjUYRoXTr6uJrhnZe4j4cfFDVlHX3DzhxPLIOh6+5m/4hE+vtoJUoMIsLh0OsAoIIMFjKMAhPqNi6ReYb3PDlw2lNN9INML/Gqqyb2yYWzW8Awt7psSZqQPkj1aH8rhZPWAPklCVoCYeFlGulxU88ZTPySbIX61g2pjU46MO+RhBTn46StfOTYCID5ssl5uL0YbyBvArcWF262tZTGvyhv/utALDAMljFK5tUwYQ0Vhgh9eZOBwuwD2lIA0dIRjB1PjKbKDg1Mc5+7q6Dfy+BWGHW1gTNiWzbSkgwp5E5wLtnpH7V9v5sAZhfw6xcntM9N7MMLQZ97M42NXx5+ksjIPUB/s909MOL+biCVEgYHfkeNObSsIYBnUGSUw7VUdqrqN9kXeNzFjOGjkfrFBFm52bmgEp9NyEkaVfRJeIjt02EK86fzCd9iST3qNCZUYZy7uBBIu8gviScmm432ja65HCHbDndloYt1cwJzO3cJUCgcorknLgqtUK+E 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: During early init CMA_MIN_ALIGNMENT_BYTES can be PAGE_SIZE, since pageblock_order is still zero and it gets initialized later during initmem_init() e.g. setup_arch() -> initmem_init() -> sparse_init() -> set_pageblock_order() One such use case where this causes issues is - early_setup() -> early_init_devtree() -> fadump_reserve_mem() -> fadump_cma_init() 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. Fix it by moving the fadump_cma_init() after initmem_init(), where other such cma reservations also gets called. ============== 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 Fixes: 11ac3e87ce09 ("mm: cma: use pageblock_order as the single alignment") Suggested-by: David Hildenbrand Reported-by: Sachin P Bappalige Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/include/asm/fadump.h | 7 +++++++ arch/powerpc/kernel/fadump.c | 6 +----- arch/powerpc/kernel/setup-common.c | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h index ef40c9b6972a..3638f04447f5 100644 --- a/arch/powerpc/include/asm/fadump.h +++ b/arch/powerpc/include/asm/fadump.h @@ -34,4 +34,11 @@ extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data); extern int fadump_reserve_mem(void); #endif + +#if defined(CONFIG_FA_DUMP) && defined(CONFIG_CMA) +void fadump_cma_init(void); +#else +static inline void fadump_cma_init(void) { } +#endif + #endif /* _ASM_POWERPC_FADUMP_H */ diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index ffaec625b7a8..c42f89862893 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -78,7 +78,7 @@ static struct cma *fadump_cma; * But for some reason even if it fails we still have the memory reservation * with us and we can still continue doing fadump. */ -static void __init fadump_cma_init(void) +void __init fadump_cma_init(void) { unsigned long long base, size, end; int rc; @@ -139,8 +139,6 @@ static void __init fadump_cma_init(void) fw_dump.boot_memory_size >> 20); return; } -#else -static void __init fadump_cma_init(void) { } #endif /* CONFIG_CMA */ /* @@ -642,8 +640,6 @@ int __init fadump_reserve_mem(void) pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n", (size >> 20), base, (memblock_phys_mem_size() >> 20)); - - fadump_cma_init(); } return ret; diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 943430077375..b6b01502e504 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -997,9 +997,11 @@ void __init setup_arch(char **cmdline_p) initmem_init(); /* - * Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must - * be called after initmem_init(), so that pageblock_order is initialised. + * Reserve large chunks of memory for use by CMA for fadump, KVM and + * hugetlb. These must be called after initmem_init(), so that + * pageblock_order is initialised. */ + fadump_cma_init(); kvm_cma_reserve(); gigantic_hugetlb_cma_reserve();