From mboxrd@z Thu Jan 1 00:00:00 1970 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 ED6AECD4857 for ; Wed, 4 Sep 2024 17:36:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81E076B0422; Wed, 4 Sep 2024 13:36:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7CB5D6B0423; Wed, 4 Sep 2024 13:36:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66BFC6B0424; Wed, 4 Sep 2024 13:36:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 42D026B0422 for ; Wed, 4 Sep 2024 13:36:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E381FA16DF for ; Wed, 4 Sep 2024 17:36:51 +0000 (UTC) X-FDA: 82527761022.23.74C447D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 3BB321C000A for ; Wed, 4 Sep 2024 17:36:50 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="fo/495hH"; spf=pass (imf20.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=1725471334; 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:in-reply-to:references:references:dkim-signature; bh=c9GqwcMkhkYmcFh6ZhMA0LSctpWIRniVrJs3Fqn2Nvg=; b=HJw1nP6RyPA4jf62wGfLNU4Lhex5pE3aJ5HAT/dYZRnp4dRNoP6u+76wq9WxfMn5iplnjg gsE2AskUHFj5raDFZMY7A8648/xMoN7By3RQD+qh4KhFLPQWWOCbNn/aB0TFHWdSvL+kQj A0W4GpEkKtyxEmbTJCgz7uvbZbvb+As= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="fo/495hH"; spf=pass (imf20.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=1725471334; a=rsa-sha256; cv=none; b=PI1yJKXOWcSxuS/70h/D6yfP8jbTwskezsNprIJRFRjNqxbSZAeq4sZOUdmrLTbVx7NCLR WazeKqGjYB+uZq9qAh0vCnyLLZCwwDmjcp2hWbZG5LZH6y/JkNtUL6zu+GXI1c823lf6WB 46Y4e6MiJO2IFR2idhvkbo9D69bO/MQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D7FB85C5619; Wed, 4 Sep 2024 17:36:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C323C4CEC2; Wed, 4 Sep 2024 17:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725471409; bh=kWds04I5pjMm3FhcXtiQkfRW8MvMdUPBrd8CIBFbZac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fo/495hHWvxt/g2JiEXBugpYAgkiyhgMt6vu9YtlthaxN7JCGZzMwkxO/oy1fD3+m n8JH1BVmZaO3YILnBkhvOPrxqOooUrbv2LH2LKVyT9RjbhSlN+wXchrveI4XuruP5G AdKBUjSuFy3t5JNTw9XjU2GU40WuwD90yOaFM9S9jvB+RVWGBWwQ9508kyQA37cDzf I7NBiBnHLMvCwFqLwVwM7RXfdfrfwDLiZcUi3Mmmz6+2EYIcdxKWeCKZaQGQSTxgwg DX6MBqVk0KgTG6qNFT4i6da45xWmsWme7Ia3bmWz9nwxm/2t370m5vlsm9TVSUrLVm 3dnipCkWGHiFw== From: SeongJae Park To: "Liam R. Howlett" Cc: SeongJae Park , Guenter Roeck , Andrew Morton , "Matthew Wilcox (Oracle)" , David Hildenbrand , 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 Subject: Re: [PATCH] mm/damon/tests/vaddr-kunit: don't use mas_lock for MM_MT_FLAGS-initialized maple tree Date: Wed, 4 Sep 2024 10:36:45 -0700 Message-Id: <20240904173645.1679-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: s6qrcesm9rx4zsk4tns8odet74eouwss X-Rspam-User: X-Rspamd-Queue-Id: 3BB321C000A X-Rspamd-Server: rspam02 X-HE-Tag: 1725471410-839701 X-HE-Meta: U2FsdGVkX19nCt1MLo1euxTCocZRTp9rJKSr2g8bLGIhohf7O8fdBNNYZP7hnlQlYfyzFCdmX+FTH+I/23IFsRH+oHg576VALaFp5yRChaeolPqh+XSL9ERS3/jrDBTP1vEu7q12V3gR7vqFF1p9NJwIAS/YTwPOCyegyKIFIB+HWn9Ua2lTJvtYNE5QdSFrXtx2iulcBmuJTTDpFnhx2Mxj/D3w/GttoxQ9e4BLnlPQa3aQYEb5Hd7DsEtL4E8IitMqDI7WJtocWAnDQzG95cn0oh7zqkMvfgNthn2P6OvqyXyqjK80l5y/dWMkIbRJ3qS+DGxtM9P6di86goYFpOXbEimWF80weOJZd4bvmeo1n0LGpU3CZey+Q9mXDCnBoszQCmPZ5nuaYdYavigf8xbBCuVNiFpLOV2taZZa1xH4k96RH8bykXGqB+YWUKpv7uQYf9279MKkR13mkyAJ4uG3buHRVl9fL2gcViJU0mwBrytFtiFrrNwRhmClWoAYsAwdFoXH/b9zZObpQY9t1K+Dz2RGlCxYXAOat/2yBH2oa6y36MkR1+Z1/HB9iFUPCwHidecPitGdzcRu81sm4rj5abbYmud2gEX0sShRwdP9KFzoP7iow0ADBbOudxzMXeAcMEY8d3E7A3QzzxjByRr/SBq7cN4AhryS13c26FAXGTvnZwuWRDjqj6kQpm3WLpxqMr8pLvOJc8iuqDk2zK+GKM4FCW9sKmLGYUkt0eOf1x0hmzjnARfiEZt3MuuHu9rN5QrWDYiXsrUFmpFHIqKXmgfa7fXHIiMsguyq8dPiWk+h0lsU2UXJtAH0SZ44mxKcTYbr52KF7ny7YUfoZZ4C2uJVpPcmoIPoemBM9APJbCg3WHdY05S76UHVWdbpX8PftNUzjlxra9nsH0/r6rZ2LX+QAfyTN+FYBS49ocyRnM7CjsQIWm7du8K9JS9em97MHDB0lozQuWEvEDv xFaCPBCx jKl35agmvsifw27NUQiUoOMf378FVlHVzK6jL9ZNrlBSmWGAzkR/t16po5eN2rrD3DqmBPpZxPJk5PTbhfFskYcVyGy4QHs+OTlvSE5MoSQeScgOVJLfvIp1m0e2wh7e7fg0HcbjpeG8XlvYVZgIBLCGy1Db8Sjd9+CMzCqDL1S7Z/Pmq5C/iqXzgnv5pxcGRf4kes+E0iUMdIMulMh8MJmi1TNpJ2Q0btJdrdv4LnI5Uw9Bab5OYBMh7Z0Jxy6vi+9OojrPp3ZxHf4t+WH1Zjgf1ouadg91o8JU05C6STGN7BokUpTijoIfFALnA2uyWeVcLo4LZ60tTUfKV7IZUO7cKJKEDFHetHky7gC2gFOwu+GA= 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: List-Subscribe: List-Unsubscribe: On Tue, 3 Sep 2024 22:43:40 -0400 "Liam R. Howlett" wrote: > * Guenter Roeck [240903 21:54]: > > On 9/3/24 18:18, SeongJae Park wrote: > > > On Tue, 3 Sep 2024 17:58:15 -0700 SeongJae Park wrote: > > > > > > > On Tue, 3 Sep 2024 20:48:53 -0400 "Liam R. Howlett" wrote: > > > > > > > > > * SeongJae Park [240903 20:45]: > > > > > > 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 celar when spinlock debugging is turned on, since it > > > > > > reports spinlock bad magic bug. Fix the issue by not using the mt_lock > > > > > > as promised. > > > > > > > > > > You can't do this, lockdep will tell you this is wrong. > > > > > > > > Hmm, but lockdep was silence on my setup? > > > > > > > > > We need a lock and to use the lock for writes. > > > > > > > > This code is executed by a single-thread test code. Do we still need the lock? > > > > > > > > > > > > > > I'd suggest using different flags so the spinlock is used. > > > > > > > > The reporter mentioned simply dropping MT_FLAGS_LOCK_EXTERN from the flags > > > > causes suspicious RCU usage message. May I ask if you have a suggestion of > > > > better flags? > > > > > > I was actually thinking replacing the mt_init_flags() with mt_init(), which > > > same to mt_init_flags() with zero flag, like below. > > > > > > ``` > > > --- 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(&mm.mm_mt); > > > if (__link_vmas(&mm.mm_mt, vmas, ARRAY_SIZE(vmas))) > > > kunit_skip(test, "Failed to create VMA tree"); > > > ``` > > > > > > And just confirmed it also convinces the reproducer. But because I'm obviously > > > not familiar with maple tree, would like to hear some comments from Liam or > > > others first. > > Again, I'd use the flags "MT_FLAGS_ALLOC_RANGE | MT_FLAGS_USE_RCU" > because that gets you the gap tracking that may be necessary for tests > in the future - it's closer to the MM_MT_FLAGS, so maybe some mm > function you use depends on that. Thank you for the nice suggestion with the rationales. Just posted the v2 following it: https://lore.kernel.org/20240904172931.1284-1-sj@kernel.org > > > > > > Same here. That is why I gave up after trying MT_FLAGS_ALLOC_RANGE and > > "MT_FLAGS_ALLOC_RANGE | MT_FLAGS_USE_RCU". After all, I really don't know what > > I am doing and was just playing around ... and there isn't really a good > > explanation why initializing the maple tree with MT_FLAGS_ALLOC_RANGE (but not > > MT_FLAGS_USE_RCU) would trigger rcu warnings. > > Thanks, I'll add that to my list of things to do. Thank you. I agree that's somewhat we can visit separately. FYI, I was also unable to reproduce rcu warnings with my v2 patch on my setup. I will also try to use Guenter's more detailed repro (https://lore.kernel.org/78880ac2-f7fe-4dc1-b2cb-25942fb0cacf@roeck-us.net). Thanks, SJ > > Regards, > Liam