Re: [RFC PATCH 1/6] mm/damon/tests/core-kunit: test damon_commit_filter()
SJ Park <[email protected]> Wed, 29 Jul 2026 17:01:54 -0700
| Newsgroups | dev.linux.lists.damon |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 29 Jul 2026 14:52:57 +0000 [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] The kunit test uses the wrong enum type `DAMOS_FILTER_TYPE_MEMCG` instead of `DAMON_FILTER_TYPE_MEMCG` when checking `src->type`, causing the `memcg_id` assertion to be silently skipped. > -- > > --- Patch [1]: [RFC PATCH 1/6] mm/damon/tests/core-kunit: test damon_commit_filter() --- > commit e16ea26a19f85858bdb608d81842e976d30c3270 > Author: SJ Park <[email protected]> > > mm/damon/tests/core-kunit: test damon_commit_filter() > > Add kunit test to ensure damon_commit_filter() updates destination > filter as expected for valid inputs. > > > diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h > > index 4a536d41cdb2d..6cbe22accabfb 100644 > > --- a/mm/damon/tests/core-kunit.h > > +++ b/mm/damon/tests/core-kunit.h > > @@ -1306,6 +1306,45 @@ static void damon_test_commit_target_regions(struct kunit *test) > > [ ... ] > > > +static void damon_test_commit_filter_for(struct kunit *test, > > + struct damon_filter *dst, struct damon_filter *src) > > +{ > > + damon_commit_filter(dst, src); > > + KUNIT_EXPECT_EQ(test, dst->type, src->type); > > + KUNIT_EXPECT_EQ(test, dst->matching, src->matching); > > + KUNIT_EXPECT_EQ(test, dst->allow, src->allow); > > + switch (src->type) { > > + case DAMOS_FILTER_TYPE_MEMCG: > > + KUNIT_EXPECT_EQ(test, dst->memcg_id, src->memcg_id); > > + break; > > [Severity: Medium] > Will this case label ever be matched? > > This code checks against DAMOS_FILTER_TYPE_MEMCG, but damon_test_commit_filter() > below initializes the source filter with type DAMON_FILTER_TYPE_MEMCG. > > Because of this mismatch, the switch statement falls through to the default > case, and the test silently skips the assertion for memcg_id. Good catch, I will fix. > > > + default: > > + break; > > + } > > +} > > + > > +static void damon_test_commit_filter(struct kunit *test) > > +{ > > [ ... ] > > > + damon_test_commit_filter_for(test, &dst, > > + &(struct damon_filter){ > > + .type = DAMON_FILTER_TYPE_MEMCG, > > + .matching = false, > > + .allow = false, > > + .memcg_id = 123, > > + }); > > +} > > -- > Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1 > Thanks, SJ