From nobody Wed Nov 27 02:43:29 2024 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 E16CA15B96E for ; Tue, 15 Oct 2024 01:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728956058; cv=none; b=U8veeoXy6BCOu/7P3/K2OEpgcA96FAJuxWYpalrZjtRUW74OHmIN5SUAlNOUbTVB/9E7IrCymp1MQ0IIHGCJaN2D0X2uK24uYSeLZqR3S+RDXsP2RjQGo+R+Aq8VHsvIUap7GBlusQ3QzOKLrGFiLHjzTu0TIG905mosYJ4uSP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728956058; c=relaxed/simple; bh=ll46Y5ohND+TUmqRmSlDtnD60Fmr6r5zMc07Tyy0M5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EIbk9rTpQHqkdF8wqKHAENuiv4pw/shY9JJhvTyuhLqJ0HnZaaK+96oUav3dTBDfdQPt//QfAhc2Jf1zdk6KtAcl8fI+tpgau84mrn3NBeZ2xdFlrqt1P1uex8CTyfXjn46VEuEZZn0zbSizZjPhnPqVlaVMFNnEJS4+wzW6AF4= 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=TcSwee0A; arc=none smtp.client-ip=209.85.210.181 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="TcSwee0A" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-71e5a62031aso1363786b3a.1 for ; Mon, 14 Oct 2024 18:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728956056; x=1729560856; 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=/MHsxmP9bN1bxx4msR28qZ2la9zK0wSY8EDrce3K+zQ=; b=TcSwee0AaZMkdxLVwzxlbaCFTTjtbU7AhSy9yINvy4IfMGOE4c82oU0zhHOqVB834O 41qbtFENQW9lrTe4wFZ7h4u6Wq4LqCdwhqmewjF/3Wqq/wElJ9Y2/ngznkmbyg4V9dUg kssewrzOOsoZxeYeuoXi+QHY1eiYEEw0UMViCkil4C4OM36JYhhRXfQCQmggPYe53kkJ lAVVTeOFMvbYmyu/Ay0Op4FYgTPM7eSaEkIJxGeC6TEVHckyZACnnCiNgVOCwPO2gXHR pkEtt6pcGVbqwiXXBDOrizVoTsl8LzgwVEoH99yRdgBve29sDXB0Ah+pyQ7ttgYSTRnt nTIQ== 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=PksjHIEQ5fpoNN45qGVpFZYgivfS0remIBm0UPlftaSFRAnYyf52+0BnSbJkjtJQVb 9iXaoT1l51bOwphv1PIBRvDDtuHswhIklmeHolM24wPM0xG0wG+LSabX5xJtI27dKU4X r58gEP7tU4F6+buObXE+6tFijUeyRRJrW2u3VOf+DZetndaVmsXSE6yIjGSXbV75ydOp yQvacHzImxkGngxQU9MvpkTJhoq3wALCVNvEBXkwhEVhUZO+vyGPkwmZJxN8eQTZp4KV 1aYOjQaeVRBwCYRgcfZodrWWipq8WOR8Yg9yrTKTVodkN9j+cBJaTUPYIzaxg85NFerj 2ATA== X-Forwarded-Encrypted: i=1; AJvYcCVRl1lBk3tVjy0UVz9cFA0FZX5mTTtBsJKJupRz/m8bMRqegR2UMUVbbFL7c3z0zr4Od91DNu7Kz+qXgbs=@vger.kernel.org X-Gm-Message-State: AOJu0Yxysv6NMaFO1nmT8toVKZtp+TIYTg2C2ljnOCePb9Vct2KszNP7 XpeogH29r+k+2TdZOf08Vke6IcHs5/DquMrAnrLIg6t9iLWWGHb/ 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: 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 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); =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