From patchwork Tue Oct 15 01:33:26 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: 13835649 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 BDAC8CFC536 for ; Tue, 15 Oct 2024 01:34:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 558EE6B0093; Mon, 14 Oct 2024 21:34:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E14B6B0095; Mon, 14 Oct 2024 21:34:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3822E6B0096; Mon, 14 Oct 2024 21:34:05 -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 183DA6B0093 for ; Mon, 14 Oct 2024 21:34:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 96B8740402 for ; Tue, 15 Oct 2024 01:33:59 +0000 (UTC) X-FDA: 82674115314.09.A7E59F0 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf22.hostedemail.com (Postfix) with ESMTP id CB9BAC0010 for ; Tue, 15 Oct 2024 01:33:54 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=No0nldO4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728955996; a=rsa-sha256; cv=none; b=XjAr/+pkgoBj1306gN4BjKarmjJA0Wcw8c8YNdYm48pkeaz3ZOFZpLKZJOa2gD6ZdPOeU0 gynX6FHVGCw5dj4NTROfNIABDOZjxpIpZCJohdRHWZyh8dWVa3zHFxJeAWQvzeopOv5Jsk vk44fd5Vp02vrn1AzYLVwXm+RTyrxRk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=No0nldO4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.180 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=1728955996; 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=9gdBU6NTSnQ45ASWgUOhpCdQmMAIjthCFPvKHCG5k1I=; b=xmmF+mS5MiahSgRYIZQt5gysUPs4QDCGiEsWbcG6LNpP/SYKRlkhOPrGUUn7FNUSUr1zxY nC9sii76r+Ygqo76ADIet1+Pq/tpnLyMVfbUQNl7GuTpRCcY3R+tqtm61qY9HVVBXngolb LJSybJwOgCH+cqW8upfqp/WbCw1neyY= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-71e681bc315so921842b3a.0 for ; Mon, 14 Oct 2024 18:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728956042; x=1729560842; 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=9gdBU6NTSnQ45ASWgUOhpCdQmMAIjthCFPvKHCG5k1I=; b=No0nldO4DRgym0Xrisgq3VxkgcA+FODCUZuigVMItEJiRN7cXFsM7fTWWdCRyCoM4R VSM5P6qk23q5fbHgPFjrsoihnrbvjZ+gqBhsTxk0BCxjs+aTkvLJe6/y2M1vG//rsgGV ZeczDvO6vKDOW/dB4T25RGU096EIxqnsuOu914hzRO4rLURaGQohQ0+KjkhpXbXmboPl Sbu9B7a4MNYRggsiphYJ9GTDs2TVju+gRZR0SUmJ1QXhp1pgPpQwhsLpWPuFMJO++GCP VjXtlqylVQS7uqnNKecOcgLSYxXHsL3JHaVXmcKogRRr0Ro5DgVKuMmi5ur7xqdML6Za EMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728956042; x=1729560842; 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=9gdBU6NTSnQ45ASWgUOhpCdQmMAIjthCFPvKHCG5k1I=; b=KDhGvJ1JQGciuihLJcnBNgRgOpTDOCUEF+owJWrPWNPFRDV4D/A4sHyO1dkUDVLY/8 acEK43LJvLJ4mTlR4bW3g5vb0J9EkkX/tVXY+JiMLxv/eF5nxE7SCKK7f6pceS6UK+kj 5iMsJ7o69AbxSr4rXWrSyqN6SYkXyVRRQIdRTSUdI1zfkB9VlX/sFPZi8zVPD/KFygxY 7fkqZXCWddKUAQ1zkjiN3/8/Qcidmh/68cyNB4l9vpLAxFcKWArIJ8YWGOVlDsuzjqfl m1URe3ttDp/+1uRzZmrMuAW14PnTssz5Qv2d2FnlsnKbNoOkVYRtKASkE9lmcaPISaWk 2/Qw== X-Forwarded-Encrypted: i=1; AJvYcCUMruxHPYPyPoPo0kZTcCEbOLDdxitxpW2TCdp0cV8lrasunVIyFNGgor8CM/49GjHbNRgDG84anQ==@kvack.org X-Gm-Message-State: AOJu0YzoN9G1FwmXBBkvGry22OyxEYLwVAIhGwJZ2/2vnJdsHUlcklbV 9O/g7RaoLPTSRL5l3/Y5DZ4QqMFN3hnZ2Aqucnu3IVMyaYw6exwv X-Google-Smtp-Source: AGHT+IEiFeaAHOWvlSRTf6MSOaFyHyrBNKW3yk4oAKnnkBoJktpp0QXSxa/Okqxxx4ycP0dnhBWBFw== X-Received: by 2002:a62:f252:0:b0:71e:5709:2330 with SMTP id d2e1a72fcca58-71e570923afmr12036633b3a.7.1728956041587; Mon, 14 Oct 2024 18:34:01 -0700 (PDT) Received: from dw-tp.. ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e77508562sm189349b3a.186.2024.10.14.18.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 18:34:01 -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 03/13] book3s64/hash: Remove kfence support temporarily Date: Tue, 15 Oct 2024 07:03:26 +0530 Message-ID: <00ba1fdbf7e135fab9d3d1c8872674079452446a.1728954719.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: CB9BAC0010 X-Rspamd-Server: rspam01 X-Stat-Signature: onn8y968jndo1grdm1cjgpmucdi63bsm X-HE-Tag: 1728956034-49564 X-HE-Meta: U2FsdGVkX19WChbEvjQmZ/KJGbNTtxbLX1srLY1ops7/9p384Pjj+E2D8gVFyq34bUTjNek0MufrUomkGiOtVPsrdiN0rhm23tr8pWtQllxctFdw3VrKQAhQ1NGszRyhyjxA3d3vrezsGpv0HLHYPhC7Z2aXcld7xDpP9tbJAkB9d1UlV7nbbLnz6898Bi8FucW2B0QzegpW/fwICUN1n5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R4SvG8lXoVJDIMm 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: Kfence on book3s Hash on pseries is anyways broken. It fails to boot due to RMA size limitation. That is because, kfence with Hash uses debug_pagealloc infrastructure. debug_pagealloc allocates linear map for entire dram size instead of just kfence relevant objects. This means for 16TB of DRAM it will require (16TB >> PAGE_SHIFT) which is 256MB which is half of RMA region on P8. crash kernel reserves 256MB and we also need 2048 * 16KB * 3 for emergency stack and some more for paca allocations. That means there is not enough memory for reserving the full linear map in the RMA region, if the DRAM size is too big (>=16TB) (The issue is seen above 8TB with crash kernel 256 MB reservation). Now Kfence does not require linear memory map for entire DRAM. It only needs for kfence objects. So this patch temporarily removes the kfence functionality since debug_pagealloc code needs some refactoring. We will bring in kfence on Hash support in later patches. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/include/asm/kfence.h | 5 +++++ arch/powerpc/mm/book3s64/hash_utils.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/include/asm/kfence.h b/arch/powerpc/include/asm/kfence.h index fab124ada1c7..f3a9476a71b3 100644 --- a/arch/powerpc/include/asm/kfence.h +++ b/arch/powerpc/include/asm/kfence.h @@ -10,6 +10,7 @@ #include #include +#include #ifdef CONFIG_PPC64_ELF_ABI_V1 #define ARCH_FUNC_PREFIX "." @@ -25,6 +26,10 @@ static inline void disable_kfence(void) static inline bool arch_kfence_init_pool(void) { +#ifdef CONFIG_PPC64 + if (!radix_enabled()) + return false; +#endif return !kfence_disabled; } #endif diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index e1eadd03f133..296bb74dbf40 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -431,7 +431,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend, break; cond_resched(); - if (debug_pagealloc_enabled_or_kfence() && + if (debug_pagealloc_enabled() && (paddr >> PAGE_SHIFT) < linear_map_hash_count) linear_map_hash_slots[paddr >> PAGE_SHIFT] = ret | 0x80; } @@ -814,7 +814,7 @@ static void __init htab_init_page_sizes(void) bool aligned = true; init_hpte_page_sizes(); - if (!debug_pagealloc_enabled_or_kfence()) { + if (!debug_pagealloc_enabled()) { /* * Pick a size for the linear mapping. Currently, we only * support 16M, 1M and 4K which is the default @@ -1134,7 +1134,7 @@ static void __init htab_initialize(void) prot = pgprot_val(PAGE_KERNEL); - if (debug_pagealloc_enabled_or_kfence()) { + 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, @@ -2120,7 +2120,7 @@ void hpt_do_stress(unsigned long ea, unsigned long hpte_group) } } -#if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE) +#ifdef CONFIG_DEBUG_PAGEALLOC static DEFINE_RAW_SPINLOCK(linear_map_hash_lock); static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) @@ -2194,7 +2194,13 @@ int hash__kernel_map_pages(struct page *page, int numpages, int enable) local_irq_restore(flags); return 0; } -#endif /* CONFIG_DEBUG_PAGEALLOC || CONFIG_KFENCE */ +#else /* CONFIG_DEBUG_PAGEALLOC */ +int hash__kernel_map_pages(struct page *page, int numpages, + int enable) +{ + return 0; +} +#endif /* CONFIG_DEBUG_PAGEALLOC */ void hash__setup_initial_memory_limit(phys_addr_t first_memblock_base, phys_addr_t first_memblock_size)