From patchwork Tue Oct 15 01:33:36 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: 13835659 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 39E1ECFC505 for ; Tue, 15 Oct 2024 01:34:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC1D56B00A8; Mon, 14 Oct 2024 21:34:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B72136B00A9; Mon, 14 Oct 2024 21:34:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3A906B00AA; Mon, 14 Oct 2024 21:34:53 -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 81A626B00A8 for ; Mon, 14 Oct 2024 21:34:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BE6F61208D1 for ; Tue, 15 Oct 2024 01:34:45 +0000 (UTC) X-FDA: 82674117582.29.37D69F4 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf02.hostedemail.com (Postfix) with ESMTP id 7D1DE80006 for ; Tue, 15 Oct 2024 01:34:38 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EgXrsNiR; spf=pass (imf02.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.176 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=1728955902; 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=rG0rlJ7RpNnGy840avhtCY+OIP6FbV4qxEoUkbOoVC0=; b=t3ukVZle3ulP1EoK/w3J7bUfNynwFlk7GZnFnWWlvt75+SLewl97iG8tRJp3nkoPBwN6Y7 +BQBh2YHbQp3sixZHo8RQA+4JOm4rligGFjsCKbmmKlwSU9PLIx1kjFv3dCJsLHRz3k5a1 MKL04q5e1AK259TMC5sy4cXZIKMtnlA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EgXrsNiR; spf=pass (imf02.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.176 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=1728955902; a=rsa-sha256; cv=none; b=lbnwAqoT4eHGdOrPF7TRXVjxCUVMONvbW75XB6XetRiMhKdfa/CkRBt503ydFvdxuzynRy 5i6eMHT1wRljrtjvLmGP9ertYW4UxCjHwOAmHbKdxfN/YVuhmF40wbvL+CJ3DA1o97yml8 JKngorlMa3zp7D0sbJp6UdmvFUzcVK0= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-71e483c83dbso2992965b3a.3 for ; Mon, 14 Oct 2024 18:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728956090; x=1729560890; 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=rG0rlJ7RpNnGy840avhtCY+OIP6FbV4qxEoUkbOoVC0=; b=EgXrsNiRroATCbU7IIzIL0rZ8bSFRjZyAhL4HZEjJMaXd/nyCieNOQ2D0WrV6aoQ1v ur6ovHdWT8UM2QTmJd6Ui5BAXlBX2GbwmoeRyy/Y2g+YSXq57aSUCGz2s8csGcOUCg+3 elRUp26LMiDYP4rtlBO/JrAZc9Wstg3sdOQUsr7nJ3UMyN7cDuh/Oh0G7WnrL0FRUlla xl4U4owG2qSe+3hbuwweU8XmMG1Mgd60jgb53dpkwaQdYc80VDXRVGxcDqURuK7/XAou 90bEGA7VfBUqXaDc1G1r5/J4FWFiE/FJh6NWNmtQSGHQCcFeNOn+kEwLAhcQalAvVX09 KiTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728956090; x=1729560890; 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=rG0rlJ7RpNnGy840avhtCY+OIP6FbV4qxEoUkbOoVC0=; b=w0yvbh9xoFDX2PtK0ue/kHhMTK1x5w1gS7GebxKYvr6oTtuYxyN3dhiQOfEDvEaW3k KNsBLPyORuz8Ww59O7HZJgoWvFmtp4zfG91UftfcVL4R354prQxaQij0yISwDBOIRKpi 9mLoO3tZKxwLupGeQany3IRHdLyqqT8cmOnxFcadkVEZvG76t3FgX/LNY3x5atO5HYj7 ROpdMIGHR4jIlAkiPf4nEGkVI3ftKBrC2bmKEVZ+lGfks4kEhiNk4LMMb8X59qBxa/aa BbFpfqlOd7R55/YSMS4tAVpD+DGDa4qoX8f0A9HSP6ZwZR3KskwntJz+co2/BNC5g8Lr QHNA== X-Forwarded-Encrypted: i=1; AJvYcCWGaCBiM4NvFKU+fgMDD0rprW6Jj8Czy5ubJerFd1j7wPZ9f1lmnTqA4/q8pBFzlh4tcqOjOWuXWA==@kvack.org X-Gm-Message-State: AOJu0YxaTBPCf397hWgW/29lPWR3U9qpvDe8ccAJrZyUESY52qmbHPA7 3p386iFDQ0a5knigp4BTQxEAfhHFxWuAmJ5A/QK/8+pKIzamNBIS X-Google-Smtp-Source: AGHT+IFvESYA3zS1GBFZJxbiWhM237fiGLHeDy47xUMjk/AhsGWJAlSSfmCDieCeQukhtrPpShvuWQ== X-Received: by 2002:a05:6a00:1404:b0:71e:5033:c5 with SMTP id d2e1a72fcca58-71e50330377mr13492824b3a.14.1728956090001; Mon, 14 Oct 2024 18:34:50 -0700 (PDT) Received: from dw-tp.. ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e77508562sm189349b3a.186.2024.10.14.18.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 18:34:49 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: kasan-dev@googlegroups.com, linux-mm@kvack.org, Marco Elver , Alexander Potapenko , Heiko Carstens , Michael Ellerman , Nicholas Piggin , Madhavan Srinivasan , Christophe Leroy , Hari Bathini , "Aneesh Kumar K . V" , Donet Tom , Pavithra Prakash , LKML , "Ritesh Harjani (IBM)" Subject: [RFC RESEND v2 13/13] book3s64/hash: Early detect debug_pagealloc size requirement Date: Tue, 15 Oct 2024 07:03:36 +0530 Message-ID: <6b5deb16494e80703577e20fbb150789c83076a9.1728954719.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: 7D1DE80006 X-Stat-Signature: xicru8d5g6ztzs5zo6mocnurxtswzetf X-Rspam-User: X-HE-Tag: 1728956078-552741 X-HE-Meta: U2FsdGVkX1+/JAB8edAc4JuGX9COeBuAjPLhIi3li86Q1Jk4dhi0NatFK7tqk6438dKG0Te80rLoRKNGBx99ydbMA9Iq39rLolYbg/cq+NFsKuFrs2qQ51q+blVji42wQHBB1+6KtlhsWnapg7/4K/MYm1QQVi6zO8198tjzUoi78lAqMDPXwirkrShN+ENgpC/HFQI4oiYqQZ13dLgb+O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JD5DJ8s9QgXsNr8JA6t62JgvY2zx4vVLPAsWRxoQDZyP+w3jWi3vIFuPT2GqNxfVLKGHivZDmw== 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: Add hash_supports_debug_pagealloc() helper to detect whether debug_pagealloc can be supported on hash or not. This checks for both, whether debug_pagealloc config is enabled and the linear map should fit within rma_size/4 region size. This can then be used early during htab_init_page_sizes() to decide linear map pagesize if hash supports either debug_pagealloc or kfence. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/mm/book3s64/hash_utils.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index b6da25719e37..3ffc98b3deb1 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -329,25 +329,26 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long idx, } #endif +static inline bool hash_supports_debug_pagealloc(void) +{ + unsigned long max_hash_count = ppc64_rma_size / 4; + unsigned long linear_map_count = memblock_end_of_DRAM() >> PAGE_SHIFT; + + if (!debug_pagealloc_enabled() || linear_map_count > max_hash_count) + return false; + return true; +} + #ifdef CONFIG_DEBUG_PAGEALLOC static u8 *linear_map_hash_slots; static unsigned long linear_map_hash_count; static DEFINE_RAW_SPINLOCK(linear_map_hash_lock); static void hash_debug_pagealloc_alloc_slots(void) { - unsigned long max_hash_count = ppc64_rma_size / 4; - - if (!debug_pagealloc_enabled()) - return; - linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT; - if (unlikely(linear_map_hash_count > max_hash_count)) { - pr_info("linear map size (%llu) greater than 4 times RMA region (%llu). Disabling debug_pagealloc\n", - ((u64)linear_map_hash_count << PAGE_SHIFT), - ppc64_rma_size); - linear_map_hash_count = 0; + if (!hash_supports_debug_pagealloc()) return; - } + linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT; linear_map_hash_slots = memblock_alloc_try_nid( linear_map_hash_count, 1, MEMBLOCK_LOW_LIMIT, ppc64_rma_size, NUMA_NO_NODE); @@ -1076,7 +1077,7 @@ static void __init htab_init_page_sizes(void) bool aligned = true; init_hpte_page_sizes(); - if (!debug_pagealloc_enabled() && !kfence_early_init_enabled()) { + if (!hash_supports_debug_pagealloc() && !kfence_early_init_enabled()) { /* * Pick a size for the linear mapping. Currently, we only * support 16M, 1M and 4K which is the default