From patchwork Tue Oct 15 01:33:29 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: 13835652 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 4DC5DCFC505 for ; Tue, 15 Oct 2024 01:34:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6FFE6B009B; Mon, 14 Oct 2024 21:34:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1F166B009C; Mon, 14 Oct 2024 21:34:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9A226B009D; Mon, 14 Oct 2024 21:34:19 -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 985736B009B for ; Mon, 14 Oct 2024 21:34:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DE94DAAFC0 for ; Tue, 15 Oct 2024 01:34:02 +0000 (UTC) X-FDA: 82674116070.15.20F7DAF Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf01.hostedemail.com (Postfix) with ESMTP id 9496E4000E for ; Tue, 15 Oct 2024 01:34:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jc4bgPDR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728955941; a=rsa-sha256; cv=none; b=zxLqFkginHZ4qhwBmcH7rBHBvOqpHl2Go1r+/U4FfDp7aarlxLzjtCG0R9VtI3Jxcyuh9P dqiALv75cRkCDqfa2j+dmgtoUHqtczNcIAKbhA3gW92XPLTm92z/tNsDZVZeFMJuG0VksQ KW5Py10i9z5WjG55btzSkB/o1cr8iog= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jc4bgPDR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.170 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=1728955941; 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=/MHsxmP9bN1bxx4msR28qZ2la9zK0wSY8EDrce3K+zQ=; b=H8982ULZZfAWdx/QqyCiq5jywK5zFRA7JdgVkXAw29YSQ4ToFeKxdxFoJeOkrBDQl6RNaJ STq3dfMeApaGDs7wwR55mql/p/8RXTO5H24RBgpAEUuf8hx020uggUk8EHT2lv3DpY6XXp GuI7uP9VWtETJvylHDc+lYxrG1Z8mkI= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-71e52582cf8so1557378b3a.2 for ; Mon, 14 Oct 2024 18:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728956056; x=1729560856; 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=/MHsxmP9bN1bxx4msR28qZ2la9zK0wSY8EDrce3K+zQ=; b=jc4bgPDRiV5P8bsOmrjq7YkSJIVkztB2/wj7Vxij0BuB4ua/bYvFzosY5n52yWPDvn BGQSBdmrllz8Kq73WnxwDyQyuTdWVMiGnhVokLacqXHMbrloY6kk1iHXu6urNE1uDaVw ZMm48jwolOl48XCj/tw/5AvTf8indtp1KjurDekB5gRJE3WtvtGu6x6+mDo6eWt4AHFI 7cM9iS9PiYNNHPh+ieqwgAy+Pn1G+NuLwkpshxMNGQsy0z07TTZl0sxsIIlgF3HPRD9Q 1NP7zdbJOUGmmOwf9R9YwuBH4bpp7AeN6Q0GeQxOJAPHQElBccIaKjJEod/2UxB1lrjU uHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728956056; x=1729560856; 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=/MHsxmP9bN1bxx4msR28qZ2la9zK0wSY8EDrce3K+zQ=; b=JfGKDP5JOW+FJYHwoH1WRaYwxNB0e65jrt8aF/ZBlFWMH6ZbDRnm80rk4/SdW+Sm2s NXH6iJjWBfE7bCx03R/Ckzp2jbP00rANXQ17vAF3w2cjG1lN/Vk/uDK8xmgR1bht6B2W smVS5c5Ajw+Pr/rYsHBVfmDvT09m24wHJngT7GkPRvtEAikGSB8CHoDDXnEE/SQeYMTr KhM6z2amIlhCKBh+oYAjwMAXz2vfVF0t4Ab9iG/4Vt+xpe/eFjMTCe9zMQTEkm2ZRJ1N lRMgbIENWAFjofWFK0t1+CtBXwP0goPmCy3aO179Y0By7h3yfz/tsbnldWPTpUQtA5fP BaQQ== X-Forwarded-Encrypted: i=1; AJvYcCXj93Z9ky5UrICIz4ZGcvf9Lgndda3LjGILjqJjenHXXTExmDm1XObTD2whwy8i70NbUEPiRs8eXQ==@kvack.org X-Gm-Message-State: AOJu0YwOUswhDhEfWm6Ux6TIe1JrCIlj+ZPv6ad6wjhu7NiMUZc73xOd 297YpFErEuO6UrXoFrxgIXBq9duUfXBUMSSBTRyCTfmnEKD5x2WC X-Google-Smtp-Source: AGHT+IEaRbtvLZbSifnrZqi1CARugZbYpE5zHqXON9KkesVGZbR8E08Sd3QxolQeAT6rqf3d5xyTkQ== X-Received: by 2002:a05:6a20:9f47:b0:1d0:7df2:cf39 with SMTP id adf61e73a8af0-1d8c9577ca1mr13971673637.7.1728956056191; Mon, 14 Oct 2024 18:34:16 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 18:34:15 -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 06/13] book3s64/hash: Add hash_debug_pagealloc_alloc_slots() function Date: Tue, 15 Oct 2024 07:03:29 +0530 Message-ID: <4245e8392bdcb0ea168b9700d356f75575511536.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: rspam12 X-Rspamd-Queue-Id: 9496E4000E X-Stat-Signature: m7zmqyjy4ug7zi1s8t6z4m7dqi71k6xh X-Rspam-User: X-HE-Tag: 1728956051-489131 X-HE-Meta: U2FsdGVkX18m1QaHglHPXezquK+YD6mj0cIbQ+kNsKaHsZsW3N8Ys4eCtSe92MxfOD+htRHInFpTAnl021g/WsOtpzFZM5UUDq9uKr0BukAUmKv59Jd61x7whRra+VZSekz6vKFGBj6ub3hpI96t5PThOqlqZ96dY8jLwUnXid8/JleMRMZjCbv0skaHML9WtF+HXmiED+hatH0d4W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cYbiAZ6N4VZWT9myq/BUtZ2hAJiuuE+0CFAjvnYc130aTiiePmjRyOs7kxOggaQ== 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 adds hash_debug_pagealloc_alloc_slots() function instead of open coding that in htab_initialize(). This is required since we will be separating the kfence functionality to not depend upon debug_pagealloc. Now that everything required for debug_pagealloc is under a #ifdef config. Bring in linear_map_hash_slots and linear_map_hash_count variables under the same config too. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/mm/book3s64/hash_utils.c | 29 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 6e3860224351..030c120d1399 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(mmu_slb_size); #ifdef CONFIG_PPC_64K_PAGES int mmu_ci_restrictions; #endif -static u8 *linear_map_hash_slots; -static unsigned long linear_map_hash_count; struct mmu_hash_ops mmu_hash_ops __ro_after_init; EXPORT_SYMBOL(mmu_hash_ops); @@ -274,6 +272,8 @@ void hash__tlbiel_all(unsigned int action) } #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 kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) @@ -328,6 +328,19 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) mmu_kernel_ssize, 0); } +static inline void hash_debug_pagealloc_alloc_slots(void) +{ + if (!debug_pagealloc_enabled()) + 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); + if (!linear_map_hash_slots) + panic("%s: Failed to allocate %lu bytes max_addr=%pa\n", + __func__, linear_map_hash_count, &ppc64_rma_size); +} + static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot) { if (!debug_pagealloc_enabled()) @@ -361,6 +374,7 @@ int hash__kernel_map_pages(struct page *page, int numpages, { return 0; } +static inline void hash_debug_pagealloc_alloc_slots(void) {} static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot) {} #endif /* CONFIG_DEBUG_PAGEALLOC */ @@ -1223,16 +1237,7 @@ static void __init htab_initialize(void) prot = pgprot_val(PAGE_KERNEL); - if (debug_pagealloc_enabled()) { - 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); - if (!linear_map_hash_slots) - panic("%s: Failed to allocate %lu bytes max_addr=%pa\n", - __func__, linear_map_hash_count, &ppc64_rma_size); - } - + hash_debug_pagealloc_alloc_slots(); /* create bolted the linear mapping in the hash table */ for_each_mem_range(i, &base, &end) { size = end - base;