mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
The lazy_mmu_mode KUnit tests call lazy_mmu_mode_{enable,disable}. These
tests may be built as a module, and because of inlining this means that
arch_{enter,flush,leave}_lazy_mmu_mode need to be exported.
[akpm@linux-foundation.org: remove mm/tests/lazy_mmu_mode_kunit.c comment, per Kevin]
Link: https://lkml.kernel.org/r/20251218100541.2667405-1-kevin.brodsky@arm.com
Fixes: ee628d9cc8 ("mm: add basic tests for lazy_mmu")
Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
74 lines
1.4 KiB
C
74 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include <kunit/test.h>
|
|
#include <linux/pgtable.h>
|
|
|
|
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
|
|
|
|
static void expect_not_active(struct kunit *test)
|
|
{
|
|
KUNIT_EXPECT_FALSE(test, is_lazy_mmu_mode_active());
|
|
}
|
|
|
|
static void expect_active(struct kunit *test)
|
|
{
|
|
KUNIT_EXPECT_TRUE(test, is_lazy_mmu_mode_active());
|
|
}
|
|
|
|
static void lazy_mmu_mode_active(struct kunit *test)
|
|
{
|
|
expect_not_active(test);
|
|
|
|
lazy_mmu_mode_enable();
|
|
expect_active(test);
|
|
|
|
{
|
|
/* Nested section */
|
|
lazy_mmu_mode_enable();
|
|
expect_active(test);
|
|
|
|
lazy_mmu_mode_disable();
|
|
expect_active(test);
|
|
}
|
|
|
|
{
|
|
/* Paused section */
|
|
lazy_mmu_mode_pause();
|
|
expect_not_active(test);
|
|
|
|
{
|
|
/* No effect (paused) */
|
|
lazy_mmu_mode_enable();
|
|
expect_not_active(test);
|
|
|
|
lazy_mmu_mode_disable();
|
|
expect_not_active(test);
|
|
|
|
lazy_mmu_mode_pause();
|
|
expect_not_active(test);
|
|
|
|
lazy_mmu_mode_resume();
|
|
expect_not_active(test);
|
|
}
|
|
|
|
lazy_mmu_mode_resume();
|
|
expect_active(test);
|
|
}
|
|
|
|
lazy_mmu_mode_disable();
|
|
expect_not_active(test);
|
|
}
|
|
|
|
static struct kunit_case lazy_mmu_mode_test_cases[] = {
|
|
KUNIT_CASE(lazy_mmu_mode_active),
|
|
{}
|
|
};
|
|
|
|
static struct kunit_suite lazy_mmu_mode_test_suite = {
|
|
.name = "lazy_mmu_mode",
|
|
.test_cases = lazy_mmu_mode_test_cases,
|
|
};
|
|
kunit_test_suite(lazy_mmu_mode_test_suite);
|
|
|
|
MODULE_DESCRIPTION("Tests for the lazy MMU mode");
|
|
MODULE_LICENSE("GPL");
|