1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-11 17:10:13 +00:00

mm/damon/tests/core-kunit: remove unused ctx in damon_test_split_regions_of()

damon_test_split_regions_of() dynamically allocates a 'struct damon_ctx'
object, but it is not really being used in the code other than handling
the allocation failure and deallocating it at the end of the function. 
Remove the unnecessary allocation and deallocation of the object.

Link: https://lkml.kernel.org/r/20251101182021.74868-23-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: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park 2025-11-01 11:20:16 -07:00 committed by Andrew Morton
parent 40b11d1eb1
commit 80d725f96c

View File

@ -267,20 +267,14 @@ static void damon_test_merge_regions_of(struct kunit *test)
static void damon_test_split_regions_of(struct kunit *test)
{
struct damon_ctx *c = damon_new_ctx();
struct damon_target *t;
struct damon_region *r;
if (!c)
kunit_skip("ctx alloc fail");
t = damon_new_target();
if (!t) {
damon_destroy_ctx(c);
if (!t)
kunit_skip(test, "target alloc fail");
}
r = damon_new_region(0, 22);
if (!r) {
damon_destroy_ctx(c);
damon_free_target(t);
kunit_skip(test, "region alloc fail");
}
@ -290,13 +284,10 @@ static void damon_test_split_regions_of(struct kunit *test)
damon_free_target(t);
t = damon_new_target();
if (!t) {
damon_destroy_ctx(c);
if (!t)
kunit_skip(test, "second target alloc fail");
}
r = damon_new_region(0, 220);
if (!r) {
damon_destroy_ctx(c);
damon_free_target(t);
kunit_skip(test, "second region alloc fail");
}
@ -304,7 +295,6 @@ static void damon_test_split_regions_of(struct kunit *test)
damon_split_regions_of(t, 4, DAMON_MIN_REGION);
KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u);
damon_free_target(t);
damon_destroy_ctx(c);
}
static void damon_test_ops_registration(struct kunit *test)