mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
mm/damon/tests/core-kunit: add a test for damon_commit_ctx()
Patch series "mm/damon: test and document power-of-2 min_region_sz requirement". Since commitc80f46ac22("mm/damon/core: disallow non-power of two min_region_sz"), min_region_sz is always restricted to be a power of two. Add a kunit test to confirm the functionality. Also, the change adds a restriction to addr_unit parameter. Clarify it on the document. This patch (of 2): Add a kunit test for confirming the change that is made on commitc80f46ac22("mm/damon/core: disallow non-power of two min_region_sz") functions as expected. Link: https://lkml.kernel.org/r/20260307194222.202075-2-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@google.com> Cc: David Hildenbrand <david@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: SeongJae Park <sj@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
300252ebb1
commit
a260de7d45
|
|
@ -1057,6 +1057,27 @@ static void damon_test_commit_target_regions(struct kunit *test)
|
|||
(unsigned long[][2]) {{3, 8}, {8, 10}}, 2);
|
||||
}
|
||||
|
||||
static void damon_test_commit_ctx(struct kunit *test)
|
||||
{
|
||||
struct damon_ctx *src, *dst;
|
||||
|
||||
src = damon_new_ctx();
|
||||
if (!src)
|
||||
kunit_skip(test, "src alloc fail");
|
||||
dst = damon_new_ctx();
|
||||
if (!dst) {
|
||||
damon_destroy_ctx(src);
|
||||
kunit_skip(test, "dst alloc fail");
|
||||
}
|
||||
/* Only power of two min_region_sz is allowed. */
|
||||
src->min_region_sz = 4096;
|
||||
KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), 0);
|
||||
src->min_region_sz = 4095;
|
||||
KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), -EINVAL);
|
||||
damon_destroy_ctx(src);
|
||||
damon_destroy_ctx(dst);
|
||||
}
|
||||
|
||||
static void damos_test_filter_out(struct kunit *test)
|
||||
{
|
||||
struct damon_target *t;
|
||||
|
|
@ -1313,6 +1334,7 @@ static struct kunit_case damon_test_cases[] = {
|
|||
KUNIT_CASE(damos_test_commit_pageout),
|
||||
KUNIT_CASE(damos_test_commit_migrate_hot),
|
||||
KUNIT_CASE(damon_test_commit_target_regions),
|
||||
KUNIT_CASE(damon_test_commit_ctx),
|
||||
KUNIT_CASE(damos_test_filter_out),
|
||||
KUNIT_CASE(damon_test_feed_loop_next_input),
|
||||
KUNIT_CASE(damon_test_set_filters_default_reject),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user