From patchwork Wed Sep 4 17:29:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13791244 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 C260ACD4857 for ; Wed, 4 Sep 2024 17:29:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 558928D025D; Wed, 4 Sep 2024 13:29:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DFE98D0250; Wed, 4 Sep 2024 13:29:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 380378D025D; Wed, 4 Sep 2024 13:29:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 17D798D0250 for ; Wed, 4 Sep 2024 13:29:46 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9503FC02D1 for ; Wed, 4 Sep 2024 17:29:45 +0000 (UTC) X-FDA: 82527743130.03.C615C9E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 1708E4000A for ; Wed, 4 Sep 2024 17:29:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zf8qnOV4; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725470935; 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=cZ45slU4Zl84NtS1zCPAYDaO9fy1OeXTZ+hEtCARGD0=; b=AFNS6dL/CXyK68zGrTuMivECiurqPWzOM/7FZx10XcmDctcUPPdDNV5OsnYv8Gr/VOg0vG bq3mIAPeFcXFXHNSOmLnfuAi09oyOLixVdRNTTrW1XRo2LmR26WtfhZP8/64RM70Z4deID pfjEnAQ6bd6Beo6yEHclXf+rKr/KGLE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zf8qnOV4; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725470935; a=rsa-sha256; cv=none; b=DaW26lWgg5AjEoly3W66LUhw7379HHxzqN5iawkRgag8Q+S9jf8MG27mUn+AiOYV94iFRw d4e9pIgSbIVB2Zs2AXCChvkwBnAzAlDhWauNZg80Fk6KIdoAJpLM1yfQSeK5crU8ZoLwrV ay8PQzs7GWWGNHGUUcRPEffStwCKKJk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 97D675C5826; Wed, 4 Sep 2024 17:29:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2D39C4CEC2; Wed, 4 Sep 2024 17:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725470981; bh=g2SvYEsNRUISamOgyu6CD7Iy+rnUtlzFhcKFNMBbW+o=; h=From:To:Cc:Subject:Date:From; b=Zf8qnOV4xVEXtXImMjjoQ/DlyyKTurmsFg3Sn05aCnHyFRrQOWLthCj5ZcGmKdLAh wFcoCGDddKU40xe0pqdzgyVXOCwQMKv1DQuHhVi2mi406cM53G8vic1HXtCqKnm+Hs gYcCqMhy+hvi+i0op9ujV83L+n+JktjTMubSLiezAKKoN0BxaN+KbkIJG/4Yn2uPc5 DBVVAwKKkqI0ZrVLN1T/v5xdQ5UtfELgG5BOkjkkUz+/zB7n4ECdc2I1LReLUcfi2r 4U1/sG3ax9xfvJZwYS9Kl4/0e8Y7fLJdkOa+LiGM1kBjwYm9XsDLlba4exX9XFuJ4e usaZEqvlOLUpw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , "Matthew Wilcox (Oracle)" , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , "Liam R . Howlett" Subject: [PATCH v2] mm/damon/tests/vaddr-kunit: init maple tree without MT_FLAGS_LOCK_EXTERN Date: Wed, 4 Sep 2024 10:29:31 -0700 Message-Id: <20240904172931.1284-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1708E4000A X-Stat-Signature: 3amfrtqr43qrp1wjuscob3krg3zbpban X-HE-Tag: 1725470982-479147 X-HE-Meta: U2FsdGVkX198ST9UnbxJ2aDLvqWJjE5w/KATQ7o5BmowFLd6pKqxEM9ztK1gpwjoyk5wn6us88DOSUIS9qpzlOVdl+jgtUTRbII2bS0+1MyzuIMTnBYCEsLkVTtiwvbs0KBip3FDDnYJN3MsbhivmN+rrvzPh503EUpLUFzYVvJaN8VGKJ5xEdgrf1qu9hATFvasVIICTAmXhYbJSfM0m7f4i9GbMQih2j08zmOsbALDy7vsS8gT090nJjtpCm/P/PWiA63mSqtXN685pibqgHFe5ekehewD2k/NangGDiINTlaqZ3SmbwrL3TtChFZikqhwHxEF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m@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: damon_test_three_regions_in_vmas() initializes a maple tree with MM_MT_FLAGS. The flags contains MT_FLAGS_LOCK_EXTERN, which means mt_lock of the maple tree will not be used. And therefore the maple tree initialization code skips initialization of the mt_lock. However, __link_vmas(), which adds vmas for test to the maple tree, uses the mt_lock. In other words, the uninitialized spinlock is used. The problem becomes clear when spinlock debugging is turned on, since it reports spinlock bad magic bug. Fix the issue by excluding MT_FLAGS_LOCK_EXTERN from the maple tree initialization flags. Note that we don't use empty flags to make it further similar to the usage of mm maple tree, and to be prepared for possible future changes, as suggested by Liam. Reported-by: Guenter Roeck Closes: https://lore.kernel.org/1453b2b2-6119-4082-ad9e-f3c5239bf87e@roeck-us.net Fixes: d0cf3dd47f0d ("damon: convert __damon_va_three_regions to use the VMA iterator") Suggested-by: Liam R. Howlett Signed-off-by: SeongJae Park Tested-by: Guenter Roeck --- Changes from v1 (https://lore.kernel.org/20240904004534.1189-1-sj@kernel.org) - Keep lock usage and update the initialization flags (Liam) - Fix a typo: s/celar/clear/ (Guenter) mm/damon/tests/vaddr-kunit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index 83626483f82b..a339d117150f 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -77,7 +77,7 @@ static void damon_test_three_regions_in_vmas(struct kunit *test) (struct vm_area_struct) {.vm_start = 307, .vm_end = 330}, }; - mt_init_flags(&mm.mm_mt, MM_MT_FLAGS); + mt_init_flags(&mm.mm_mt, MT_FLAGS_ALLOC_RANGE | MT_FLAGS_USE_RCU); if (__link_vmas(&mm.mm_mt, vmas, ARRAY_SIZE(vmas))) kunit_skip(test, "Failed to create VMA tree");