From nobody Sat Feb 7 22:55:06 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 785743115A6 for ; Fri, 14 Nov 2025 11:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118823; cv=none; b=ZBV3cY74U9+KCt2ZCWQIljvILxz24CN++oahaf/33Ijell11Kbj1GmNxr7KLMp32aDX6Fut2n5cW5jtBvmJlpiWl659IHFBFpTC9p61zJvlKsgKkz/JjB8/BwYYWeHuibSxZlLbw3cumJEw4R00slVzqAk9lJPZVtRanKwOGmwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118823; c=relaxed/simple; bh=hjB6g8zh4VEobLPtkfJPC8LQ+Vpz+37lqxLKnWeq9yY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V1LZFPXQJqV7yBUk9iQzzNs5M1i6gfjx0kcvnUVqpivNG013VfdMQZU/W260JSFCEfNwIWaPs869KQ2WnnrSjFoWQLlW/1A1aGbLVEQ1XOqDDw6ATKL1gOd8ZKQSyT/8Rgbqhef9K8Yr8AwErz4ZxKNt/eMpyNiWOwz7G5qrrYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ahulCYKl; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ahulCYKl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QEefGr34jCXytLhrSj7xX2XGq0Zan5wY+b22XB//Qmo=; b=ahulCYKl1T8/1EigkwF90o/vnGsd/SAoByvuSZpMwweuYRBk2FeVT2gsJ/dzEfCsjfcpLo mpzn6A8+HWUhO2EAEW8sql75SXT+7QKV88bnfAPoO9rKIxep+P5dEjCwnXn6+B9LQj02Kb jUh7PSOGRzsLU0M33QU2JbDlxuvcAFE= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , Richard Henderson , Matt Turner Subject: [PATCH 1/7] alpha: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:15 +0800 Message-ID: <66cd5b21aecc3281318b66a3a4aae078c4b9d37b.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: Richard Henderson Cc: Matt Turner --- arch/alpha/Kconfig | 1 + arch/alpha/include/asm/tlb.h | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 80367f2cf821c..681ed894d9e72 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -40,6 +40,7 @@ config ALPHA select MMU_GATHER_NO_RANGE select SPARSEMEM_EXTREME if SPARSEMEM select ZONE_DMA + select MMU_GATHER_RCU_TABLE_FREE help The Alpha is a 64-bit general-purpose processor designed and marketed by the Digital Equipment Corporation of blessed memory, diff --git a/arch/alpha/include/asm/tlb.h b/arch/alpha/include/asm/tlb.h index 4f79e331af5ea..4fe5a901720f0 100644 --- a/arch/alpha/include/asm/tlb.h +++ b/arch/alpha/include/asm/tlb.h @@ -4,7 +4,9 @@ =20 #include =20 -#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, pte) -#define __pmd_free_tlb(tlb, pmd, address) pmd_free((tlb)->mm, pmd) -=20 +#define __pte_free_tlb(tlb, pte, address) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)) +#define __pmd_free_tlb(tlb, pmd, address) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd)) + #endif --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02F69314A76 for ; Fri, 14 Nov 2025 11:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118829; cv=none; b=PUpfhk02Bu97VdVQBFkcJDgQqvAGUYubH2X3ceUBm3j9rUWgAm7ualg8jkG0zJddskza6AFRIg91hB3Ml7w/KyJXQCpUHKMh5SbawySje2A2cet4bt2WgTIchL++KaZiyTVSgUYePfLuXy+Yy5E6l884icptDfrM27Mhrliy6lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118829; c=relaxed/simple; bh=zKmRBaTVYT/GGP753suJGZyWfmgTXSn//WvB4YLCjlk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FuZ2/x9h7ilFfAtUVpbEUnIT6VkzIR7K+dvB9AiwjdseAIhgMliHd9MayIBRu31c1ZE76oVAI5zv2ZR2CWTYKrjq1ugqgI9obresGitouY0Du86LYE6NtpcZHzcJ07uATJTaTYBocHVvt927UnhhsLjLYedLa/bk8aKxR5xAOeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vExdq/0Q; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vExdq/0Q" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P6T+2Lant3MYurrTyX3sjQxVkxrSJ5NC17wEIBzsAD8=; b=vExdq/0QIbNXwYGHrXQqTUESTgynxZF1NJ0xtYYbpdRrZ58EdRub+KFh9R2nimgCQ5fatR 4xLlVhyB6VQJZcD/sz1r9N+vzLfWl9ZUNEJ579ag0IteNR33li8sNEYMRTdhUYVjBH+SAv KC18Vm38wa/0lScGVl1ZIZrfKVIfEok= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , Vineet Gupta Subject: [PATCH 2/7] arc: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:16 +0800 Message-ID: <6a4192f5cef3049f123f08cb04ef5cd0179c3281.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: Vineet Gupta --- arch/arc/Kconfig | 1 + arch/arc/include/asm/pgalloc.h | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index f27e6b90428e4..47db93952386d 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -54,6 +54,7 @@ config ARC select HAVE_ARCH_JUMP_LABEL if ISA_ARCV2 && !CPU_ENDIAN_BE32 select TRACE_IRQFLAGS_SUPPORT select HAVE_EBPF_JIT if ISA_ARCV2 + select MMU_GATHER_RCU_TABLE_FREE =20 config LOCKDEP_SUPPORT def_bool y diff --git a/arch/arc/include/asm/pgalloc.h b/arch/arc/include/asm/pgalloc.h index dfae070fe8d55..b1c6619435613 100644 --- a/arch/arc/include/asm/pgalloc.h +++ b/arch/arc/include/asm/pgalloc.h @@ -72,7 +72,8 @@ static inline void p4d_populate(struct mm_struct *mm, p4d= _t *p4dp, pud_t *pudp) set_p4d(p4dp, __p4d((unsigned long)pudp)); } =20 -#define __pud_free_tlb(tlb, pmd, addr) pud_free((tlb)->mm, pmd) +#define __pud_free_tlb(tlb, pud, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pud)) =20 #endif =20 @@ -83,10 +84,12 @@ static inline void pud_populate(struct mm_struct *mm, p= ud_t *pudp, pmd_t *pmdp) set_pud(pudp, __pud((unsigned long)pmdp)); } =20 -#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd) +#define __pmd_free_tlb(tlb, pmd, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd)) =20 #endif =20 -#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte) +#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)) =20 #endif /* _ASM_ARC_PGALLOC_H */ --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9A2D314D28 for ; Fri, 14 Nov 2025 11:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118833; cv=none; b=JrGadtVVl4XlHY9b/4qaScTKd0XlAWyreJ/r/3wSO+hV8MulKLH5lTivTvfEnyoWDrv2rtYNx2sTjPjLF9OTP1I8qySpZNLIw+UvsZ2WduONCJf5iCizIuz+limqiO2Up36EkGtLkyExzXT5rMRexKjSxz4MUTc1jPyf7Fy/uVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118833; c=relaxed/simple; bh=K56VPDNxBdzrwtk5TC0vgJ3WcdonJxJasyGE9y6RtmA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ILaRJhCLgaQl7VZ7BkYacoA+JXqOtxC1/ycoSXDCjqIBUuhPw9um23XAYagvePbdgLB6mvH9n8OaGzF45QfgzY8uMUbOQ/tAJyR2Iq5HO6xDNgoz8po/75E+tcOzVXIwKEnT4xcczh/P24mdAndp6cvYQhl3gBLweI9CCbRwdpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Y9ji6TET; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Y9ji6TET" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2CgIQM8Rm+rrIBZ65Gc8uDgVfjAkTSjqf1Ed4GSiWMI=; b=Y9ji6TETXOEdJtN7riEZs1egBNIfxqbBF5em7JWsQrRQR5gaeRiytwZ+sxyYdN3yN2wb0q Cp2WEDEqOTCXmA8Q46TPNk2xSPagvU9B7BFxShiJtemzQIQxjnYV6Z0rYNSFwfadUPgSEc hGyB5DAs7t2eEqKZwitvuD99nlUBcqs= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , Huacai Chen , WANG Xuerui Subject: [PATCH 3/7] loongarch: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:17 +0800 Message-ID: <146b5a0207052b38d04caac6b20756a61c2189b3.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: Huacai Chen Cc: WANG Xuerui --- arch/loongarch/Kconfig | 1 + arch/loongarch/include/asm/pgalloc.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 5b1116733d881..3bf2f2a9cd647 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -210,6 +210,7 @@ config LOONGARCH select USER_STACKTRACE_SUPPORT select VDSO_GETRANDOM select ZONE_DMA32 + select MMU_GATHER_RCU_TABLE_FREE =20 config 32BIT bool diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/= asm/pgalloc.h index 1c63a9d9a6d35..0539d04bf1525 100644 --- a/arch/loongarch/include/asm/pgalloc.h +++ b/arch/loongarch/include/asm/pgalloc.h @@ -79,7 +79,8 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, = unsigned long address) return pmd; } =20 -#define __pmd_free_tlb(tlb, x, addr) pmd_free((tlb)->mm, x) +#define __pmd_free_tlb(tlb, x, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(x)) =20 #endif =20 @@ -99,7 +100,8 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm,= unsigned long address) return pud; } =20 -#define __pud_free_tlb(tlb, x, addr) pud_free((tlb)->mm, x) +#define __pud_free_tlb(tlb, x, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(x)) =20 #endif /* __PAGETABLE_PUD_FOLDED */ =20 --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B87C315D23 for ; Fri, 14 Nov 2025 11:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118838; cv=none; b=GxnJvu2kGcfL4Swos12RjUITowswGDuOupdb3unAjemFfZElyMzv8IxosAvxtY3wTVazFRwZs7EbV6qjFxEsvTPxMbs+Zt5WvhrUS1KK7uRICcC2UwQWa/Pd8lcdoEH79rQgIfjNpRhmtPEjb3JZuZJzPi5ep/UT4xAlOFdvFR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118838; c=relaxed/simple; bh=FuWQWsa8J+DKqigztsuvr4pRMYfKawTfRjDCuQBEOdY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VX/buXvm3hXMksByRBrC1umJbBoZYmAjKfE7/0QsXHGLOnBN1ysWSIunZQM2Z9735kAeO0+RVN5LNjPDPQ8acpGmL25xYrQGwUQjBDLM9GH2hwLdg6Py3l7ZeAp2AeD2XgkpK6r94iS6hbLKpN8cnKs6KMbAnE2AvOQGCZE90wE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iw/rnvl+; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iw/rnvl+" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xE2z7TAxeJ/1HQSzhHJnzUcYxbE0hsI+5X32zwVc0VI=; b=iw/rnvl+mSTQwZ1VtfwsUIUgZEgEWYMoBXUqNckA12rFzs5wwBw1DfEnB9VXrBAiN5lBA2 +WL6SCJD5yzsK1tlWnajFGyhDa2TXm27uAcag6i4H/j/tdwWGVq+UdZZjcaWuNr4dD50wD yUns3WW5Fq1s6Y/AV0bEqLTbFKSi9Ds= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , Thomas Bogendoerfer Subject: [PATCH 4/7] mips: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:18 +0800 Message-ID: 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: Thomas Bogendoerfer --- arch/mips/Kconfig | 1 + arch/mips/include/asm/pgalloc.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index e8683f58fd3e2..0ee8820a354c4 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -108,6 +108,7 @@ config MIPS select TRACE_IRQFLAGS_SUPPORT select ARCH_HAS_ELFCORE_COMPAT select HAVE_ARCH_KCSAN if 64BIT + select MMU_GATHER_RCU_TABLE_FREE =20 config MIPS_FIXUP_BIGPHYS_ADDR bool diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgallo= c.h index 942af87f1cddb..c00f445045f43 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -72,7 +72,8 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, = unsigned long address) return pmd; } =20 -#define __pmd_free_tlb(tlb, x, addr) pmd_free((tlb)->mm, x) +#define __pmd_free_tlb(tlb, x, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(x)) =20 #endif =20 @@ -98,7 +99,8 @@ static inline void p4d_populate(struct mm_struct *mm, p4d= _t *p4d, pud_t *pud) set_p4d(p4d, __p4d((unsigned long)pud)); } =20 -#define __pud_free_tlb(tlb, x, addr) pud_free((tlb)->mm, x) +#define __pud_free_tlb(tlb, x, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(x)) =20 #endif /* __PAGETABLE_PUD_FOLDED */ =20 --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA274315D3E for ; Fri, 14 Nov 2025 11:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118843; cv=none; b=VUK5yzyuYqwz8lyOM5EJ7uGzpOxtAe6+TwzwXjZaV6RHUTCC9lfEVSUbHBq6RdhnZaWwSEtX/3v5CzaDK9fW8oqMsuMyqGlOg7rAP1c7zy/ikZ6k5mSRAsZBswAEaRCNI8dmzOyF8Re/WakKt7nG6ybleKLA0C8inP27VTlkWRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118843; c=relaxed/simple; bh=y3+cAqzSkPk1tWuUrHkYALa2DGC3gvmhFzF8IzkFgAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=in0AZBxLZja0gwQhXi5qLmqHhUnIQRMGtZIvJ36N0uheiNyJ/xQjnK2JW49HllDHVxnaPwThCYyoYv82XEI2LGoGXV9JRtY05nJrbp3luHlvTTA/K0TXytqPospsuA+r6WiIpFRsRCigPbPLZITG8fT9ihsAjqE4ap6wUinww5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MJ9Mpinl; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MJ9Mpinl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Sax8A8PA6ZHc/cVS+xTeKKlG8M0r3mfGW440vNjJZdg=; b=MJ9MpinllxQ4TveK74NmYHIrtnuWysqMuo3kH1WtaJPOEfUFraWTOjeuO+qSEwJDbXunL4 KzCwC7WMF3bErXcULhl6Hmst/RWmFUWC5WUQqMmKuZtOwbb3VyxdEl/g2hEf0Oms7Jx9kQ EAMJFMUorbF1pVdhYWTD7Kr5yAkEd64= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , "James E.J. Bottomley" , Helge Deller Subject: [PATCH 5/7] parisc: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:19 +0800 Message-ID: <3a88790a662c2b84066c77772d20bd1f5f687f8b.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: "James E.J. Bottomley" Cc: Helge Deller --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/tlb.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 47fd9662d8005..946cbe21a4118 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -92,6 +92,7 @@ config PARISC select TRACE_IRQFLAGS_SUPPORT select HAVE_FUNCTION_DESCRIPTORS if 64BIT select PCI_MSI_ARCH_FALLBACKS if PCI_MSI + select MMU_GATHER_RCU_TABLE_FREE =20 help The PA-RISC microprocessor is designed by Hewlett-Packard and used diff --git a/arch/parisc/include/asm/tlb.h b/arch/parisc/include/asm/tlb.h index 44235f367674d..ab7d4113df61a 100644 --- a/arch/parisc/include/asm/tlb.h +++ b/arch/parisc/include/asm/tlb.h @@ -5,8 +5,10 @@ #include =20 #if CONFIG_PGTABLE_LEVELS =3D=3D 3 -#define __pmd_free_tlb(tlb, pmd, addr) pmd_free((tlb)->mm, pmd) +#define __pmd_free_tlb(tlb, pmd, addr) \ + tlb_remove_ptdesc((tlb), virt_to_ptdesc(pmd)) #endif -#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, pte) +#define __pte_free_tlb(tlb, pte, addr) \ + tlb_remove_ptdesc((tlb), page_ptdesc(pte)) =20 #endif --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF9173148C6; Fri, 14 Nov 2025 11:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118850; cv=none; b=GEhGEwiKWqfc/9v9WuhqC5/NfXwyQ21rpwwbmlhOpsA7j3ZbMM9q2hNeTKsjF9FdXjs9zHRCGL+WZbrNo4GJ7EWnAl1biP5Zo9JULCD+vn3BJDZXa9pf8bGE8OisklHXTqOpyQtyFBke0LbqLF1xIMv0v7+j1j8Hmr8VLP33CRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118850; c=relaxed/simple; bh=L77VHJOsxYGfJl12t5E1P3bJEqsaMDW4GIC4V2YxBI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OL1T1d4Vb3dXTI3rJQX1N/NQDV3mhc8X4pnunO1vJAHRJWvPb6NwfjkKbtm97P9+fMSzIra5ZU9RuYo2+Hjgi7OYgv1HMY+cmeDZ70kyCfN36maqxHi4j/cDEY2SX/jK/PQgSahhEWeDVvY6tD/1eILRBkmFfClnK/LFFlmlKrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=L48H43W4; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="L48H43W4" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nUnrWplutHBzvgR2dvaxPt91n3EUIlT8RN+kjzr9YeU=; b=L48H43W4jFZRnZVw9O79JRiRB5m9aw/GV0MPdZjIrgDSOzS1xJajXCccgoMGVVyjHQVMx8 ixGDGcGZ9+fwVuXGogoz7wJwNfE66muSzsaVj6jY+ONOTTSdEs5AZWkbAoLKzZN3TJkNEr SLREeZzO+x0CEbQrd41ME+/n9u8TpH4= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng , Richard Weinberger , Anton Ivanov , Johannes Berg Subject: [PATCH 6/7] um: mm: enable MMU_GATHER_RCU_TABLE_FREE Date: Fri, 14 Nov 2025 19:11:20 +0800 Message-ID: <27f173b0fc6fdf92104721fc3daba8d7d9d31e2f.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng On a 64-bit system, madvise(MADV_DONTNEED) may cause a large number of empty PTE page table pages (such as 100GB+). To resolve this problem, first enable MMU_GATHER_RCU_TABLE_FREE to prepare for enabling the PT_RECLAIM feature, which resolves this problem. Signed-off-by: Qi Zheng Cc: Richard Weinberger Cc: Anton Ivanov Cc: Johannes Berg --- arch/um/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 097c6a6265ef3..47a41bc77bb24 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -41,6 +41,7 @@ config UML select HAVE_SYSCALL_TRACEPOINTS select THREAD_INFO_IN_TASK select SPARSE_IRQ + select MMU_GATHER_RCU_TABLE_FREE =20 config MMU bool --=20 2.20.1 From nobody Sat Feb 7 22:55:06 2026 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 299D73161B8 for ; Fri, 14 Nov 2025 11:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118854; cv=none; b=KGmjwjVc3xsBwGqvWC8P2wcBLVoS1f/Y8lNKlj8BnJDK9rG8T1UcHurnhO50lQ7auehD52YkomQdlYv73JBAUPNq+Vi+PdKfCF+6/Y4+q5vlkDdmmuQhbCC/+dsXC29psle97ATJBkGWc/BUdJdksaBc2hrBMXiwTmftMaTcz/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763118854; c=relaxed/simple; bh=CXsWQVszD/4e4l8zbTDqOiyMxntdOa/q50nLcbN+x40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FT3ffZxFZypk3hpV5DWlTywGZuQAjJP8QN1E8ZQmZlX+O9JdXh53R5nOk9v91rmsECQ/iFu/04LG5vKMyBhvy6/S3vBqUAzPFFWTL0IOvvzvayt3q/1CBMo0FDVoZbnDvl8bO0USJQdC2GfvckhkM/weHrURkwUMkZGpZNnBDvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=B1fHws4v; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="B1fHws4v" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763118849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3MvAZBElD0X3pJk/MX8AXoxW4zTACm8dJmSYdSV26R0=; b=B1fHws4vdV9SHk7Nm4NMEkMGypQnWt5ebGnT0lkQhYxPSrPX9T5usjJtN8D6xLK5/tENRj 6lr6jCeTav9vHkLaX2Cm/MDvr39umGBs008BSWf4p0qasklCP7V5XJNNR/0A712o57bV/X UdgHrzzazzIM8MjWkX4twJlrGaTbo7c= From: Qi Zheng To: will@kernel.org, aneesh.kumar@kernel.org, npiggin@gmail.com, peterz@infradead.org, dev.jain@arm.com, akpm@linux-foundation.org, david@redhat.com, ioworker0@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-um@lists.infradead.org, Qi Zheng Subject: [PATCH 7/7] mm: make PT_RECLAIM depend on MMU_GATHER_RCU_TABLE_FREE && 64BIT Date: Fri, 14 Nov 2025 19:11:21 +0800 Message-ID: <0a4d1e6f0bf299cafd1fc624f965bd1ca542cea8.1763117269.git.zhengqi.arch@bytedance.com> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng Make PT_RECLAIM depend on MMU_GATHER_RCU_TABLE_FREE so that PT_RECLAIM can be enabled by default on all architectures that support MMU_GATHER_RCU_TABLE_FREE. Considering that a large number of PTE page table pages (such as 100GB+) can only be caused on a 64-bit system, let PT_RECLAIM also depend on 64BIT. Signed-off-by: Qi Zheng --- arch/x86/Kconfig | 1 - mm/Kconfig | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index eac2e86056902..96bff81fd4787 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -330,7 +330,6 @@ config X86 select FUNCTION_ALIGNMENT_4B imply IMA_SECURE_AND_OR_TRUSTED_BOOT if EFI select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE - select ARCH_SUPPORTS_PT_RECLAIM if X86_64 select ARCH_SUPPORTS_SCHED_SMT if SMP select SCHED_SMT if SMP select ARCH_SUPPORTS_SCHED_CLUSTER if SMP diff --git a/mm/Kconfig b/mm/Kconfig index a5a90b169435d..e795fbd69e50c 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1440,14 +1440,10 @@ config ARCH_HAS_USER_SHADOW_STACK The architecture has hardware support for userspace shadow call stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss). =20 -config ARCH_SUPPORTS_PT_RECLAIM - def_bool n - config PT_RECLAIM bool "reclaim empty user page table pages" default y - depends on ARCH_SUPPORTS_PT_RECLAIM && MMU && SMP - select MMU_GATHER_RCU_TABLE_FREE + depends on MMU_GATHER_RCU_TABLE_FREE && MMU && SMP && 64BIT help Try to reclaim empty user page table pages in paths other than munmap and exit_mmap path. --=20 2.20.1