From patchwork Tue Jul 18 05:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Tang X-Patchwork-Id: 13316737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C74EB64DD for ; Tue, 18 Jul 2023 05:36:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 730DF6B0071; Tue, 18 Jul 2023 01:36:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0CB6B0074; Tue, 18 Jul 2023 01:36:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CF538D0001; Tue, 18 Jul 2023 01:36:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 501956B0071 for ; Tue, 18 Jul 2023 01:36:03 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1063D4011E for ; Tue, 18 Jul 2023 05:36:03 +0000 (UTC) X-FDA: 81023621406.24.4F982DB Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf25.hostedemail.com (Postfix) with ESMTP id 6D018A0011 for ; Tue, 18 Jul 2023 05:36:00 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=V+F9nSTR; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf25.hostedemail.com: domain of feng.tang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=feng.tang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689658561; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=xAqSC7nmn/SKKEwK1DW5qLpRLX4cB+epvgv3KPAOhzg=; b=aWG5YQVcfwchqFNDoTdP2/Vcsc7/BBsYfMGyK7KtoMjcIp+On04uqe6Lmv3tcyqDPBEKHA hcuWrCdfxwqBD4DK5Qy7nI+dWBRDthuvubDrtv38h9sVsAkGL38Gzvc58ZZXKBdT+GWAva 1jF5oNdmq4FrtWyF5d1ExKFvj2FFcK8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=V+F9nSTR; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf25.hostedemail.com: domain of feng.tang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=feng.tang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689658561; a=rsa-sha256; cv=none; b=L/vUU993k1DFo6n093ZZ+JjeL2ICbPoeuBd0zUJmzGrRHiPYY6l7aAZ29OE5TGGOG+Ndxr 0uXtciO8PepfuDtSgi3Z8uFXBnUPbOJ0+Eg95Wj9oDCm0mjmo7AL5NeIQGhjBF0ns9oRBZ YWmI9NIrI6NtN961EpSBJZOnhAYXXbg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689658560; x=1721194560; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=pwZocxuhvbEdDjmw/S2Egp+TSxBuSC1aQBEepbrfUJ8=; b=V+F9nSTR02M/lTpp6WJV0cUAwIeL54b0qY3p8PqZRiTEBXIhcRWHPjp+ KcW7EbUSe7QEOprlpOWeohoj7aqSSBrEp8mZ9VhxDYKZyicUuSzerbZ5U hWjjmhGodfZC5RlKjOADOYWZWCdpzVHrqFTCx3qfrNiuADdVZc1sXAJpW 9vGQHPf6ScHB5Pjdu9dlcd9V3RcZngKeaRBiD7XOjAjzsZuVnXafhefp9 uCOLKJOLMBmjOaDwCgA/GVCq1684S4IzULpJ23ONwUa/ON+XFiT7fnmS8 fg4JoawL0jx4nzOEQoxR+4niwF/NogfhgUL2e+Icw0Z4/8+3I+4Lqq8+3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="432293563" X-IronPort-AV: E=Sophos;i="6.01,213,1684825200"; d="scan'208";a="432293563" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 22:35:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="970104267" X-IronPort-AV: E=Sophos;i="6.01,213,1684825200"; d="scan'208";a="970104267" Received: from feng-clx.sh.intel.com ([10.238.200.228]) by fmsmga006.fm.intel.com with ESMTP; 17 Jul 2023 22:35:56 -0700 From: Feng Tang To: SeongJae Park , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Feng Tang Subject: [PATCH] mm/damon/core-test: Initialise context before test in damon_test_set_attrs() Date: Tue, 18 Jul 2023 13:28:11 +0800 Message-Id: <20230718052811.1065173-1-feng.tang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 6D018A0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: irenb9u4q6cmjppqpxnnhgg9wffem9ps X-HE-Tag: 1689658560-6106 X-HE-Meta: U2FsdGVkX1/hQe1TP8c12sbriODha1GzAENNaqwrHD3IRMjjMZiMf+RM6xz2u9emmoSX2sWyMFgw+m+hBoEZZlWuKu+K2d/s4J3gcuMqYpSG3y+xj4TTm2UD1KOS5WQzTud5u1PAjQrh0k+X+MQeQJl/QtBu9tCSnuD+eqYSaeg1fo0AG+d4rbKgZbvfH+htG8nZsm+gnmj+j3Mm5dIs1ykq9WFB4AOSOxhJodkxBK2nYysbHTe6yItiqErOF3HWnybpmox3gf2e+bYGkAs5luRB29gzfGDlSkXy+dJGM6W/ErBtIKXX0nHDcokOWGo2QwxpfkApj6rB6/fX6caN18BIx3SIpi8FhoTrM5bK8faAHMBBHgQ4G3b+8fR5VVFbarvXkOuf+AWloNpimoBUyCizLpL/1CfkRtMzYpJbS+dC8PKOOtZVlpopMoyuQ5ZafljHb2/s/zBb07DOCxTf6Yr3nTjdjVnAoJ9HcC3NXuY5q5DuwSiDithmVPfe5lTruiX5rxVgHTV35iQz36RdRR3v3Pir9jo5n4E0bfWovR112JPK7q0APsJNsncG9otKhgLu3onUrLBD+1Z2EJmLAuLJWgHNgb30U6K5TvqRBszNFSkKklqJYrjbcppQhgdjJ4XgQcvinyYXzLWeKaRdxsBndstSXH7cBX5J51r5QY0NuuizfEWs93MNIhXYHhH8xtUjoKDOd5uYMkP7ec7mwLDznS6/hGHok5sjKaTQwhazfthrKleWlQ/WsTCA63l54YW/6d6nRHOG9wQCNevrFV2Lwh+zxrAxJdnXrb9cfvIwJ8600rQ9NBrU0vQIMWNGJ6B3JEG+bw8xTOQUtBVPxSTQB2V9mETRkjfJc0hh/nI6iWCOdju9cKcmPR/+p8MNj0E/5GkJdhXv0zjEz9w5kQgyndwtuvi2jylj7LXM2t+xLlZgxh15N66ZVbWEI8aloDhJPm1uTx3LbTSqvgV XUc9QlJ3 MFMXkTvgYMGBVfleDE+3txYIpEM3Sr/9lbH/6+5FLkDF2kRorUvk3FEbuve1SSfmILc6diNJcIrRqOZ3akIYvCEoYUKYHTxLktFpOLRF8hv7d2NE/sGP78Av5p4YCwAPZuxMHcht/PSwx/iS2GxYdz/FZ4LsMjAzNYZsB6e3Ej+sJWkgS1utEslux7JnhSQ6o8Eh6k9usdeJ8MQM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 #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: 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. Fixes: aa13779be6b7 ("mm/damon/core-test: add a test for damon_set_attrs()") Signed-off-by: Feng Tang Reviewed-by: SeongJae Park --- mm/damon/core-test.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index c11210124344..bb07721909e1 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -320,25 +320,25 @@ static void damon_test_update_monitoring_result(struct kunit *test) static void damon_test_set_attrs(struct kunit *test) { - struct damon_ctx ctx; + struct damon_ctx *c = damon_new_ctx(); struct damon_attrs valid_attrs = { .min_nr_regions = 10, .max_nr_regions = 1000, .sample_interval = 5000, .aggr_interval = 100000,}; struct damon_attrs invalid_attrs; - KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &valid_attrs), 0); + KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &valid_attrs), 0); invalid_attrs = valid_attrs; invalid_attrs.min_nr_regions = 1; - KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL); + KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); invalid_attrs = valid_attrs; invalid_attrs.max_nr_regions = 9; - KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL); + KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); invalid_attrs = valid_attrs; invalid_attrs.aggr_interval = 4999; - KUNIT_EXPECT_EQ(test, damon_set_attrs(&ctx, &invalid_attrs), -EINVAL); + KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); } static struct kunit_case damon_test_cases[] = {