From nobody Tue Nov 26 10:48:48 2024 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E2E9204F7E for ; Fri, 18 Oct 2024 17:30:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729272649; cv=none; b=OtUWfaqXQEmKa6iFmrRehWsaVpXZZRDbnYPfxLQdsxphnuppBdWoTXZinJn/icgmwlyJM/VPeudSjdT0Chjll1NwHrOv03ZSjGJxO1aYDLx5y0cI5nAvD+TaNNE3/+yFzQ5EjpNxFgP0M7BgXks8ntbv05vqLVIJtHYTVWFVrqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729272649; c=relaxed/simple; bh=E1R3Fouo1t2LcLOJd8YnFBZMjXJ6qjnl450cBxYMuHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OG7ZKhPcLkU9CQZHY30nUMuKYnTWgmeGRdlKcpHI6shJObGdqYGguOJOhS26vfRWXOznK+28fGE8ThcQV6W7c/MkF3nGx/F92bd5JyMj6nBqXUjaYJMqI7nHHRQC+WK3VYUFj0fzXm5DY9ub0ORpnBR+JCZHAA7bjzY2BSKISfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZfFuc2s0; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZfFuc2s0" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71e579abb99so1707090b3a.2 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=vger.kernel.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=ZfFuc2s0+HsxfAphN9wVfwOqxCyFrsja5boTwpQha2SC4RTOFzxvqCB7M/M9qhqTDM MX+xpirtKgHSewC9BtJdmvwvNyM2NUtoS3srHxMtqDJp0YEGC1EH6NMQ+6Ff53ZIc7Jy EfUPRiqTP/Dal9seRt5quBjUMiT6di27oTrLTAHz1JqFFcybwtocFUaBOgbuV8e2aaw9 nt7+ZKcrE7UUIMxrqQU+bbVq0hmCzAJJVq0vqo2SQfj4WAvKPTaoYhYWLtlX7EYz+FeN 8BwhYZsLhX6EiHEuZlDoSeUiojJkBWBzumjzfjKz4jWogyBlwiPqkpIVKZ+0K1b4+nLi n0tQ== 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=Lr1Y/SQZ9ywyB/Ov0yrXxUG55KPQb9exaTg7WFVqRfV5NqySUnCkj4yvDHTewIpH3T XHbHNyQO2osdq6fsH240hFjXM0BjjXwbpthhh6F4J9rXQNCLwqy3FI2N4Peh/7nHFDOo ggxVnZ5KpwLMTg/Xq7djBpECwxteKlluNtalfWPfdUMkFrITsYZVJykZXuM08UdPoWOG WKrnqT/4ZmC8wPmlkBcqMeYDGeiFGZ9oD1elE999jj4/FK1kPo4qeDnG/1zkq7DzvCU4 blin3Velg7j7NZiLTIRva6bnZ3fbIf1Nb4qtUMUm3lfy6Ujyz32A3asW3IlxceZXailg Iw3w== X-Forwarded-Encrypted: i=1; AJvYcCXjUNfwx9JYNcjEKx/+EAknRsfnNDLap62Yq8N4yFWT9kp4HkEmVzqexukZhaOZOqm+C+TJq3qDEdKxESA=@vger.kernel.org X-Gm-Message-State: AOJu0YyCs2D10vVqg89moDQDbifAcewWVyWRb5W7VnRAPi7FZyztVWiz 9A7SFuRPvuzKvTitAhxvtm8hmJtMSx5x+ktvmvXSDMdT94htoKSXIv0prrm6 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/book3s= 64/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); =20 @@ -274,6 +272,8 @@ void hash__tlbiel_all(unsigned int action) } =20 #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); =20 static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) @@ -328,6 +328,19 @@ static void kernel_unmap_linear_page(unsigned long vad= dr, unsigned long lmi) mmu_kernel_ssize, 0); } =20 +static inline void hash_debug_pagealloc_alloc_slots(void) +{ + if (!debug_pagealloc_enabled()) + return; + linear_map_hash_count =3D memblock_end_of_DRAM() >> PAGE_SHIFT; + linear_map_hash_slots =3D 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=3D%pa\n", + __func__, linear_map_hash_count, &ppc64_rma_size); +} + static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int sl= ot) { if (!debug_pagealloc_enabled()) @@ -361,6 +374,7 @@ int hash__kernel_map_pages(struct page *page, int numpa= ges, { return 0; } +static inline void hash_debug_pagealloc_alloc_slots(void) {} static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int sl= ot) {} #endif /* CONFIG_DEBUG_PAGEALLOC */ =20 @@ -1223,16 +1237,7 @@ static void __init htab_initialize(void) =20 prot =3D pgprot_val(PAGE_KERNEL); =20 - if (debug_pagealloc_enabled()) { - linear_map_hash_count =3D memblock_end_of_DRAM() >> PAGE_SHIFT; - linear_map_hash_slots =3D 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=3D%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 =3D end - base; --=20 2.46.0