From patchwork Fri Oct 18 17:29:46 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: 13842087 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 AA611D3DEA0 for ; Fri, 18 Oct 2024 17:30:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 356116B009D; Fri, 18 Oct 2024 13:30:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B5DB6B009E; Fri, 18 Oct 2024 13:30:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12DC26B009F; Fri, 18 Oct 2024 13:30:50 -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 E333A6B009D for ; Fri, 18 Oct 2024 13:30:49 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 74614ACE5F for ; Fri, 18 Oct 2024 17:30:25 +0000 (UTC) X-FDA: 82687412934.14.3C97C2D Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf01.hostedemail.com (Postfix) with ESMTP id 8AE7040024 for ; Fri, 18 Oct 2024 17:30:38 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ma12FNHk; spf=pass (imf01.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.175 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=1729272453; 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=DfUSdtWOnTBS3aUaneALBJjz6yO/1MpkxmVLk8hKBQI=; b=aO6h9s9M9N40+5CtEJFsw1l128qDxmKbdyiRnda+15x2pNqkvDuorbHnfl6Aws83nRvWeA LSJchlTPANncA4qmValHkJBrvlFDx6g8t2W7hCKj18He6nSd8xf6O2LWA20GTFwKT3065j bw+mturdSk9FAQYMNsVWRGU6oS37+qE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ma12FNHk; spf=pass (imf01.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.175 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=1729272453; a=rsa-sha256; cv=none; b=x93P7gcBjYVxgGml7ouZC+aMpkoCsj4MvHiWu8XFQbkoieapkMONrTkTYh5hbz1SE2GyhB 7q7jREcNvyk5YJ+2YTEFUxMMhhF+PlNwc02qoJEPZBdywOW3heg9NUvxZciuOImXJk4zog BQP6mpdQHCx6DLZE/7DFb6R6IAIhB88= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-71e7086c231so1828284b3a.0 for ; Fri, 18 Oct 2024 10:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729272646; x=1729877446; 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=DfUSdtWOnTBS3aUaneALBJjz6yO/1MpkxmVLk8hKBQI=; b=Ma12FNHkHIrZBsWeV6VnYn9JBiEOwgDeAJ61Jrj30Pr0Rbejj8eYUfrxkKxeKKNaOF y7PbTNSh8QEauIWRs3+CYOXI15eT6nao2giTUXQLXXURD+Avxg8uf696VSUMIThAznUm 4+0J/ZVsdrE/q7R2vDNHBwmz0esj4wfzExCkLaHO7RFgjLT8fFJq+95KehfesrXwKqNW KM5oAF5Gbw42e4miQ1McD+I8OXRfboZSIG9hOuNMBN+c6x+Ag6T31AKwBUN04REpMhm2 GewGSho1u0BNS+vtvcsUyQdKidP+kOGwUcoo+qy4aBpcbd5VCD5Dm/47MTl36q7qPy+d aUHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729272646; x=1729877446; 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=DfUSdtWOnTBS3aUaneALBJjz6yO/1MpkxmVLk8hKBQI=; b=DOvcjmY2bHeYAuBxnkpmix9CCOXQQhYR6jf2h8R1UNbHQzXCJS90HyN1oJURoRUg32 eSUTR83b3YZSSl1SOPQW4BidoO5cPP4p+sPvfOzpDcWH/cqQ8ts7JC4X+q0aIU9vHrw+ 5o4splHWq137GqDdPFLf3s7xATMgeZA/0KO96tTdXDozpUzpCEUWoz/9ZqppLCRPCF3J vVz/D8i8ruNuPYGKZiWF6yEsWGnMmpFIq0H72RmUde2bgRHuMI1Pvbk1Hv2DE9C9d5L1 D3k6y0mt8kWB3tMDavmNQIHA5SC0q+TJE4BJOZfPJ1Olf+ugIGQtT57vAMyQZVsfI0AS KtNA== X-Forwarded-Encrypted: i=1; AJvYcCWoCo2ef9UbS3ZrZyuHRg24PpyPCUg51wxaqVoqwk+1UNVEsZ69jWCJL6VyPmWQsg6B7JRzlB1qyA==@kvack.org X-Gm-Message-State: AOJu0YxDhRQuWbsDL3AazGKPu4pk73ydZf8O+jNw+NrM/szegdM6QUrz sJLUGgLgIlYKrpABhOa28pGeoR4tzXmWWJyT33Pbn+gtOQcXyz+K X-Google-Smtp-Source: AGHT+IEH/PHoy0SvfRofUPBZ0xaaeQuP6mqbjcomFuXt7qmLHoVJL01TXC7JEI5XORTcA+JdNts71g== X-Received: by 2002:a05:6a00:6618:b0:71e:4e2a:38c4 with SMTP id d2e1a72fcca58-71ea31e53d5mr3448284b3a.14.1729272646416; Fri, 18 Oct 2024 10:30:46 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea3311f51sm1725242b3a.36.2024.10.18.10.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 10:30:45 -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: [PATCH v3 05/12] book3s64/hash: Add hash_debug_pagealloc_alloc_slots() function Date: Fri, 18 Oct 2024 22:59:46 +0530 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8AE7040024 X-Stat-Signature: 5xocwub5hctrxuoo8aeq1r9hb9njutxy X-Rspam-User: X-HE-Tag: 1729272638-923560 X-HE-Meta: U2FsdGVkX18OyPlFPjm0oVFM1p0sjdtKoin4gyQwnQZO0Yn/8uf3izygpZw4xggQ4eom74c0EiPyq0x10PMqCu8jMEjqO8kYCNvzOmS8XABzMKpviknXcYKwcY6NQSa/JPfxEHttqL7+UuYDHhZvXl8SgZjMoIAQVjuoFqzf8ppuhWU47jh+JZESfGrwvI2JaA4OsuisK9lfNDjdxO9UbEu8KlphUXanMamP3GrYxD9yRmHtWQ36RCevnu+9r3AzOM4CseL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=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 de3cabd66812..0b63acf62d1d 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;