Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: add basic tests for lazy_mmu

Add basic KUnit tests for the generic aspects of the lazy MMU mode: ensure
that it appears active when it should, depending on how enable/disable and
pause/resume pairs are nested.

[akpm@linux-foundation.org: export ppc64_tlb_batch and __flush_tlb_pending to modules]
[ritesh.list@gmail.com: use EXPORT_SYMBOL_IF_KUNIT()]
Link: https://lkml.kernel.org/r/87a4zhkt6h.ritesh.list@gmail.com
[kevin.brodsky@arm.com: move MODULE_IMPORT_NS(), add comment]
Link: https://lkml.kernel.org/r/20251217163812.2633648-2-kevin.brodsky@arm.com
Link: https://lkml.kernel.org/r/20251215150323.2218608-15-kevin.brodsky@arm.com
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: David S. Miller <davem@davemloft.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Juegren Gross <jgross@suse.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kevin Brodsky and committed by
Andrew Morton
ee628d9c 291b3abe

+90 -1
+3 -1
arch/powerpc/mm/book3s64/hash_tlb.c
··· 25 25 #include <asm/tlb.h> 26 26 #include <asm/bug.h> 27 27 #include <asm/pte-walk.h> 28 - 28 + #include <kunit/visibility.h> 29 29 30 30 #include <trace/events/thp.h> 31 31 32 32 DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); 33 + EXPORT_SYMBOL_IF_KUNIT(ppc64_tlb_batch); 33 34 34 35 /* 35 36 * A linux PTE was changed and the corresponding hash table entry ··· 155 154 flush_hash_range(i, local); 156 155 batch->index = 0; 157 156 } 157 + EXPORT_SYMBOL_IF_KUNIT(__flush_tlb_pending); 158 158 159 159 void hash__tlb_flush(struct mmu_gather *tlb) 160 160 {
+12
mm/Kconfig
··· 1475 1475 MMU-related architectural state to be deferred until the mode is 1476 1476 exited. See <linux/pgtable.h> for details. 1477 1477 1478 + config LAZY_MMU_MODE_KUNIT_TEST 1479 + tristate "KUnit tests for the lazy MMU mode" if !KUNIT_ALL_TESTS 1480 + depends on ARCH_HAS_LAZY_MMU_MODE 1481 + depends on KUNIT 1482 + default KUNIT_ALL_TESTS 1483 + help 1484 + Enable this option to check that the lazy MMU mode interface behaves 1485 + as expected. Only tests for the generic interface are included (not 1486 + architecture-specific behaviours). 1487 + 1488 + If unsure, say N. 1489 + 1478 1490 source "mm/damon/Kconfig" 1479 1491 1480 1492 endmenu
+1
mm/Makefile
··· 147 147 obj-$(CONFIG_EXECMEM) += execmem.o 148 148 obj-$(CONFIG_TMPFS_QUOTA) += shmem_quota.o 149 149 obj-$(CONFIG_PT_RECLAIM) += pt_reclaim.o 150 + obj-$(CONFIG_LAZY_MMU_MODE_KUNIT_TEST) += tests/lazy_mmu_mode_kunit.o
+74
mm/tests/lazy_mmu_mode_kunit.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + #include <kunit/test.h> 3 + #include <linux/pgtable.h> 4 + 5 + /* For some symbols referenced by arch_{enter,leave}_lazy_mmu_mode on powerpc */ 6 + MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); 7 + 8 + static void expect_not_active(struct kunit *test) 9 + { 10 + KUNIT_EXPECT_FALSE(test, is_lazy_mmu_mode_active()); 11 + } 12 + 13 + static void expect_active(struct kunit *test) 14 + { 15 + KUNIT_EXPECT_TRUE(test, is_lazy_mmu_mode_active()); 16 + } 17 + 18 + static void lazy_mmu_mode_active(struct kunit *test) 19 + { 20 + expect_not_active(test); 21 + 22 + lazy_mmu_mode_enable(); 23 + expect_active(test); 24 + 25 + { 26 + /* Nested section */ 27 + lazy_mmu_mode_enable(); 28 + expect_active(test); 29 + 30 + lazy_mmu_mode_disable(); 31 + expect_active(test); 32 + } 33 + 34 + { 35 + /* Paused section */ 36 + lazy_mmu_mode_pause(); 37 + expect_not_active(test); 38 + 39 + { 40 + /* No effect (paused) */ 41 + lazy_mmu_mode_enable(); 42 + expect_not_active(test); 43 + 44 + lazy_mmu_mode_disable(); 45 + expect_not_active(test); 46 + 47 + lazy_mmu_mode_pause(); 48 + expect_not_active(test); 49 + 50 + lazy_mmu_mode_resume(); 51 + expect_not_active(test); 52 + } 53 + 54 + lazy_mmu_mode_resume(); 55 + expect_active(test); 56 + } 57 + 58 + lazy_mmu_mode_disable(); 59 + expect_not_active(test); 60 + } 61 + 62 + static struct kunit_case lazy_mmu_mode_test_cases[] = { 63 + KUNIT_CASE(lazy_mmu_mode_active), 64 + {} 65 + }; 66 + 67 + static struct kunit_suite lazy_mmu_mode_test_suite = { 68 + .name = "lazy_mmu_mode", 69 + .test_cases = lazy_mmu_mode_test_cases, 70 + }; 71 + kunit_test_suite(lazy_mmu_mode_test_suite); 72 + 73 + MODULE_DESCRIPTION("Tests for the lazy MMU mode"); 74 + MODULE_LICENSE("GPL");