Skip to content

Commit 2653f1d

Browse files
ftang1paniakin-aws
authored andcommitted
mm/damon/core-test: initialise context before test in damon_test_set_attrs()
Running kunit test for 6.5-rc1 hits one bug: ok 10 damon_test_update_monitoring_result general protection fault, probably for non-canonical address 0x1bffa5c419cfb81: 0000 [#1] PREEMPT SMP NOPTI CPU: 1 PID: 110 Comm: kunit_try_catch Tainted: G N 6.5.0-rc2 gregkh#15 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 RIP: 0010:damon_set_attrs+0xb9/0x120 Code: f8 00 00 00 4c 8d 58 e0 48 39 c3 74 ba 41 ba 59 17 b7 d1 49 8b 43 10 4d 8d 4b 10 48 8d 70 e0 49 39 c1 74 50 49 8b 40 08 31 d2 <69> 4e 18 10 27 00 00 49 f7 30 31 d2 48 89 c5 89 c8 f7 f5 31 d2 89 RSP: 0000:ffffc900005bfd40 EFLAGS: 00010246 RAX: ffffffff81159fc0 RBX: ffffc900005bfeb8 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 01bffa5c419cfb69 RDI: ffffc900005bfd70 RBP: ffffc90000013c10 R08: ffffc900005bfdc0 R09: ffffffff81ff10ed R10: 00000000d1b71759 R11: ffffffff81ff10dd R12: ffffc90000013a78 R13: ffff88810eb78180 R14: ffffffff818297c0 R15: ffffc90000013c28 FS: 0000000000000000(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 0000000002a1c001 CR4: 0000000000370ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> damon_test_set_attrs+0x63/0x1f0 kunit_generic_run_threadfn_adapter+0x17/0x30 kthread+0xfd/0x130 The problem seems to be related with the damon_ctx was used without being initialized. Fix it by adding the initialization. Link: https://lkml.kernel.org/r/[email protected] Fixes: aa13779 ("mm/damon/core-test: add a test for damon_set_attrs()") Signed-off-by: Feng Tang <[email protected]> Reviewed-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 18f2eb8 commit 2653f1d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mm/damon/core-test.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -320,25 +320,25 @@ static void damon_test_update_monitoring_result(struct kunit *test)
320320

321321
static void damon_test_set_attrs(struct kunit *test)
322322
{
323-
struct damon_ctx ctx;
323+
struct damon_ctx *c = damon_new_ctx();
324324
struct damon_attrs valid_attrs = {
325325
.min_nr_regions = 10, .max_nr_regions = 1000,
326326
.sample_interval = 5000, .aggr_interval = 100000,};
327327
struct damon_attrs invalid_attrs;
328328

329-
KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &valid_attrs), 0);
329+
KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &valid_attrs), 0);
330330

331331
invalid_attrs = valid_attrs;
332332
invalid_attrs.min_nr_regions = 1;
333-
KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL);
333+
KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL);
334334

335335
invalid_attrs = valid_attrs;
336336
invalid_attrs.max_nr_regions = 9;
337-
KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL);
337+
KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL);
338338

339339
invalid_attrs = valid_attrs;
340340
invalid_attrs.aggr_interval = 4999;
341-
KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL);
341+
KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL);
342342
}
343343

344344
static struct kunit_case damon_test_cases[] = {

0 commit comments

Comments
 (0)