From patchwork Wed Sep 4 00:45:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13789527 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 5784FCD37B7 for ; Wed, 4 Sep 2024 00:45:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA7B58D0200; Tue, 3 Sep 2024 20:45:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D56588D01E4; Tue, 3 Sep 2024 20:45:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1D858D0200; Tue, 3 Sep 2024 20:45:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9D4CE8D01E4 for ; Tue, 3 Sep 2024 20:45:41 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 59B6AA0654 for ; Wed, 4 Sep 2024 00:45:41 +0000 (UTC) X-FDA: 82525212882.16.32ED0E4 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf22.hostedemail.com (Postfix) with ESMTP id C633CC0012 for ; Wed, 4 Sep 2024 00:45:39 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B13qpL9p; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1725410716; 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=Y+PEeNs7EhenFlZ682FfB0E27HAmZzAfKBcR4NcgxW4=; b=WRc/ely0NQH3HkUxeK23gULX3kwTVjdx2PEMis6O3G3gTWk/c3Cva2EPH1L+yqzoSEdhlA nStfw/XObiBOsWcgZnpkEPaniza5k5um00DSlB7YXVbfrYoCx8w0b5mTwwuYw3Xq3Jbf5H R0RffkPKzIlz2FANE8Pyo3oWwU9DRO0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B13qpL9p; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1725410716; a=rsa-sha256; cv=none; b=YsquDQzfAgVd9K4yFcBrn3w8d2eru4zCx59oYgT/On8O96ex4ZQppLnabEuBPhyQQpOIbJ ZQ4h/PsynwXRSvrzF7TzBEnsj74MTv1iS1ztBtCaeExoFGW5fGAHSDup5TRB1GdiZokbeF UWw2ZZUeuh2F1BFwqN7UH7jT4/tMOJw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B8932A41FD8; Wed, 4 Sep 2024 00:45:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A397EC4CEC4; Wed, 4 Sep 2024 00:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725410738; bh=xSWI9r6Swvs+yoAPpNGT8PdDYc4MPyldkqyhEGpxlnE=; h=From:To:Cc:Subject:Date:From; b=B13qpL9pcFVJFQl6efVY9KY05M5WB6tlAsaEw92tuRZ26yu6yreUSoa2Qy9q+Ke2T PtfIa5Wa4S9hX4agaN2AtsIP1AbwrFeuNclurekYVfsGNEeTvyLGcPFL6yHkri9ScP WGvzQHHUDVhrOYdLrIdn2KY7RZc2j1MxL4YmCI9HNMDQez5NrTgHoFuOhFZ4S5tPlv DU3nQL4NpT1RW5tsEqQwj5DV1C7M3OTcYI/UD8J1cTkxAu9F0iF/5YEu9IgE81PlAE xBxeK0vPaEzBMr0iVblHt2LHCRPe30Rl/ianGluHaRdX1sQUw2x7rKiPOe9mKTnHQG F2mGPXDsCaFaA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Matthew Wilcox (Oracle)" , "Liam R. Howlett" , 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, Guenter Roeck Subject: [PATCH] mm/damon/tests/vaddr-kunit: don't use mas_lock for MM_MT_FLAGS-initialized maple tree Date: Tue, 3 Sep 2024 17:45:34 -0700 Message-Id: <20240904004534.1189-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 41h9yu31do3ko641y5t3wh1haychyhks X-Rspamd-Queue-Id: C633CC0012 X-Rspamd-Server: rspam11 X-HE-Tag: 1725410739-802131 X-HE-Meta: U2FsdGVkX19VbBRCsFCKT+lPTnV1lFaAtgEzWZ4XkwTeDRYlYbsit6Vo+D6CjU0Vbpm9QPwHr+eT5Uie8oTJWKhs9pd39+WA6sx/PZK69SF0aaZJXzRLbM4mEKMl5+JNJPiyacnKaceC4l3WEpWf96Co1+ArLbCgjmxegtNsDf4lL+1feYB0NhGeT2GPZKATVMRyDt3If8sZwW00bOnLDUCSOXzT2GjPVZFduhUs0qIpQWEbbxiaI0K+anYSnzZ4RwKnxDz8+uPzlzCE5HaUuUXjDa8UCbb8TSmCylEpEQXHNJCcfhUO6MDMrFOfRd1S1txxGw5K1exk1dog2VFCenC4hjgEXyUxPSWX/nNDra6v8PwDrluPnSKz/NstQu5Ds+0XcZdjGymemFTH3VDYF7iNJu90InUIqxybPYuMOZb5Rzd4KAxaTlIsQlYeHv4jiB2izdCFgANwIQ2ht4+FQW8EMRz0BPSCmlwwMKfcAAFwfDvp9ffVH4/rIbbH4PX4iUe6rn73jW8f69Y0KcB8KiD2b7ayKqy6wvKPavwRZZdC96fGBmI988d0Y77+ubxdc6zL5V+vg1G/INjWiE8M6Dk/W1ZOjfS3Og2ZHtbRGRZ6f2MG727ZbGqUpWeDzI2L7YbbJtvSGgx+XL/6euud21usuSw/SSFt6Ajcc34XyJEsecltv+hfhZJnJgAwTFPO6rRsFeJC4CTKzMk89FZHj4WhKIyr1Gmtk1C58loP26bdpSZbiN7ZKldp2XZ+rBW7sCnGDX7LHbZeFGEagYc/96ayv6iVFl9MIMBMHUY9ltaVxbKmylPuUszIwgRO4XGNMxQGYcg5w3CLINyavdbNhrl38zDCP79Y6+GOlBJ/6l0GRAFzMJDMNK6MYzBk2CdMUc5C5p0a7tSYFl93I3Kum3vg5OYss4Q3zPjTf0px7OyxDjpkov6CBlb8LBoAzXnN7ket8YKey2PvMuAFtUt BMK3lXxv Ng5+4pwSISlWuj/TvimAJfLvpXdeL+nQbt5mx2y2anRd266NB4WvaAn9jib1Q9zDt/8lckBmgi+TIK/dch2fq8cPf/j+P351fbYIEtpM6AtdH8NZdi9unF9xBIHhmxqC0h9PC2tSixH5v05h4DqOnDfxI1qiLkPf7INnlcnyAFKF7Q8WhkfYRBPa4F2ngEHfaDEhHrE8eVnv8iA0a9PFTjGTtUuDWus6kpzgoWQ9sGEBqa3pbM/M2fFaV/VjQIgOeN5yto6tm9u4lEiONAiI9n8V3n673XFreii/zwBJJIY7DwB1J3gV8hPd92ebYxEhgFhM1PWuI6GAm5WosxYQVZwMApA== 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: 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. 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") Signed-off-by: SeongJae Park Tested-by: Guenter Roeck --- mm/damon/tests/vaddr-kunit.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index 83626483f82b..c6c7e0e0ab07 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -17,23 +17,19 @@ static int __link_vmas(struct maple_tree *mt, struct vm_area_struct *vmas, ssize_t nr_vmas) { - int i, ret = -ENOMEM; + int i; MA_STATE(mas, mt, 0, 0); if (!nr_vmas) return 0; - mas_lock(&mas); for (i = 0; i < nr_vmas; i++) { mas_set_range(&mas, vmas[i].vm_start, vmas[i].vm_end - 1); if (mas_store_gfp(&mas, &vmas[i], GFP_KERNEL)) - goto failed; + return -ENOMEM; } - ret = 0; -failed: - mas_unlock(&mas); - return ret; + return 0; } /*