From patchwork Tue Feb 13 21:37:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13555685 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 875FDC48260 for ; Tue, 13 Feb 2024 21:37:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E7538D0015; Tue, 13 Feb 2024 16:37:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 170F46B009D; Tue, 13 Feb 2024 16:37:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB6C28D0015; Tue, 13 Feb 2024 16:37:58 -0500 (EST) 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 D6B796B009C for ; Tue, 13 Feb 2024 16:37:58 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B79CC1A0CF7 for ; Tue, 13 Feb 2024 21:37:58 +0000 (UTC) X-FDA: 81788093436.22.7C45F35 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 1DF872000E for ; Tue, 13 Feb 2024 21:37:56 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Th8U8xQD; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707860277; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dH9/7pSMHgIoq16nk50EO6AL6CLhc0Zg3gckgnzjmrE=; b=tpRxu6LiDoHlmwTL5C7ihYu40nz5u4yiYOn8YEOtF9R0cMhzS986SYir/cA9ROjJ/oJ/6A grSyXkDOmlwuAPQ41oCe5yxc3qbv63SYjUsH4/mrUNL+/fLjSNNcfpjWRWZuYNhRJK0jW0 YYuzwPYEdpJoivhjoR4sCxZeJ1enRDQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Th8U8xQD; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707860277; a=rsa-sha256; cv=none; b=5tTBwE9nKUylTZkhdTY29dEl/APOBk3HeLKNhCkLFYjsFUoXBgPORwZzw5rrMyNO7/yUd4 foRZRr6PBC/l27RxUVD3mS3YunZi6RP39yFBAwnx667VLcC91+sPC3yieZCjB3SQRBjSuI FW0cQ0TNnYIPU8CxZA8ZG0ZZiPTJ7do= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 61BAA61702; Tue, 13 Feb 2024 21:37:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DFACC433F1; Tue, 13 Feb 2024 21:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707860276; bh=r6dLn2R32hxUVKrwHaR6P90sYMJO3HfuXaP1srQuHsY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Th8U8xQDYjqE1oQO4SMhsymZnm2aTPh8ZM7SpIcq4/V3kMtNsQxxEPtEb+A/tXJZf G7CeU83YmDWCAhd/8bx6jK94iSNmgavwSA4WP4N4dJI0dRaDB/zSKquDqTQXzeFO7m nC38c/PXELlpiHWShA/rc3NbKs6cX7/7sxgiSLwa58znNQ1vr0pOGxb0cnwQgQdJbs a8EcruWbXzSxvwZRj8o8Y+0+5a327ukO27y3BcROelsesxB4/7N/jTda8uI3qtQj8A oJsu3SksCpvwru3/pix1RG4ASCwWk4HWxBO5o5oD9ZaLDJTRzKXMbRscRM2tuNVH9G qMSYb7+IbpL7g== Subject: [PATCH RFC 5/7] test_maple_tree: testing the cyclic allocation From: Chuck Lever To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, hughd@google.com, akpm@linux-foundation.org, Liam.Howlett@oracle.com, oliver.sang@intel.com, feng.tang@intel.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, lkp@intel.com Date: Tue, 13 Feb 2024 16:37:54 -0500 Message-ID: <170786027413.11135.7987491534374292548.stgit@91.116.238.104.host.secureserver.net> In-Reply-To: <170785993027.11135.8830043889278631735.stgit@91.116.238.104.host.secureserver.net> References: <170785993027.11135.8830043889278631735.stgit@91.116.238.104.host.secureserver.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 1DF872000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: w3ah34s85asdw4hgsa7di4b9zfjffcsy X-HE-Tag: 1707860276-268094 X-HE-Meta: U2FsdGVkX1/2pqlwpysWd2nuZcP4jMxq5/tgIRdXKWFZNgBUz9WMFvYtE1/ji3F5PVxRmpnGDbaMjEBQfv9YRqysbRs+0SIgBgxUxk+hXB6sgv3iFfxYVyFHrkg1+IQkjqDae47S0o0+1EqFsiTYC500lDs+4q5T7a+jvgjok/IxtHeqk+kUFR0eGmqDY5RJ1pei/TE/p4ZFhpze7CiRxDX8F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ender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Liam R. Howlett This tests the interactions of the cyclic allocations, the maple state index and last, and overflow. Signed-off-by: Liam R. Howlett Signed-off-by: Chuck Lever --- lib/test_maple_tree.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 29185ac5c727..399380db449c 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -3599,6 +3599,45 @@ static noinline void __init check_state_handling(struct maple_tree *mt) mas_unlock(&mas); } +static noinline void __init alloc_cyclic_testing(struct maple_tree *mt) +{ + unsigned long location; + unsigned long next; + int ret = 0; + MA_STATE(mas, mt, 0, 0); + + next = 0; + mtree_lock(mt); + for (int i = 0; i < 100; i++) { + mas_alloc_cyclic(&mas, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL); + MAS_BUG_ON(&mas, i != location - 2); + MAS_BUG_ON(&mas, mas.index != location); + MAS_BUG_ON(&mas, mas.last != location); + MAS_BUG_ON(&mas, i != next - 3); + } + + mtree_unlock(mt); + mtree_destroy(mt); + next = 0; + mt_init_flags(mt, MT_FLAGS_ALLOC_RANGE); + for (int i = 0; i < 100; i++) { + mtree_alloc_cyclic(mt, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL); + MT_BUG_ON(mt, i != location - 2); + MT_BUG_ON(mt, i != next - 3); + MT_BUG_ON(mt, mtree_load(mt, location) != mt); + } + + mtree_destroy(mt); + /* Overflow test */ + next = ULONG_MAX - 1; + ret = mtree_alloc_cyclic(mt, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL); + MT_BUG_ON(mt, ret != 0); + ret = mtree_alloc_cyclic(mt, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL); + MT_BUG_ON(mt, ret != 0); + ret = mtree_alloc_cyclic(mt, &location, mt, 2, ULONG_MAX, &next, GFP_KERNEL); + MT_BUG_ON(mt, ret != 1); +} + static DEFINE_MTREE(tree); static int __init maple_tree_seed(void) { @@ -3880,6 +3919,11 @@ static int __init maple_tree_seed(void) check_state_handling(&tree); mtree_destroy(&tree); + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); + alloc_cyclic_testing(&tree); + mtree_destroy(&tree); + + #if defined(BENCH) skip: #endif