Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp376263rdb; Sat, 17 Feb 2024 12:29:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmNdebwpBOc0NrFk751aVRRm/EEPdMSuX2UYKhB72NBJ+nRxvOAzx6CYb02LqH/BT2f78Q0Gpr1kqj/W7wY63KX4rfhr7mLcIUxA/uEA== X-Google-Smtp-Source: AGHT+IHhmzC5DhmNonDkD+oxsowdWTHZ6pxS2oesVu7dQE/n6YM/pmH+Bt+Da4/IvO9lWRIGiVsR X-Received: by 2002:a17:903:264e:b0:1db:94a9:f9f7 with SMTP id je14-20020a170903264e00b001db94a9f9f7mr6179095plb.20.1708201755043; Sat, 17 Feb 2024 12:29:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708201755; cv=pass; d=google.com; s=arc-20160816; b=d529JtDfS3peTZVCdNvDCbkXrYDwT+qCfQuQEbwn+ZRXHqy0G8wZIpn2ZEjfr8xhjN k6if+iI4tZNLMayyx/TLl2ZxXXe2t8cx+kW7z1iOLu8mNynGAwg0WkHolp9eD0mqeHWe oFf3CxmVx5dvoUQ+0SjF1WiwAubE10AH1nuvUq65S3m3M4pjfFHM19BNeWT2k6vGP3Ip sELZLRxNdt1VwW1uEjfBphhdqYca76sED5vDmS24naud4czwV0NpvE471MZMt3vduZXy 5jXv184piTt63q9tll8M2kg1DGkPsAaPYK2Apv9clZPDwglhh5CKSUEZ/jjPcinV2rRK p9nQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:cc:to:from:subject:dkim-signature; bh=dH9/7pSMHgIoq16nk50EO6AL6CLhc0Zg3gckgnzjmrE=; fh=0JMhqiWEaK+qw2xgbbey7OsRaoj7Z6cFR6nhiwhAbe0=; b=GxiyEj1/63CqIOJp06X1YAEHmoDsYuk+Z3SaXOKfoKdT6wQgnYVVEQyUonXYGQEixx DKWFBDZCwJqd668dqcG0/CjSS02gGAsCyImihv82UGJikvwVbcOHIZtRUuFs49QKKh5D lF12UW889QGGb51Z18JxjfsT7e8KGNFyh1ckdAAJhGzgBzcK/UsUDtCse/P8VI/+mrAb j7h/uQcXEtLLcpZdOVkHgtOe9a/9gFnAiSZ803mTKR2RbgoQxAHMkzRN7Y7qGPni59BZ OJMp+zVj/QmKlwVC1ubnzejOfbeIzx9YHXqRAA53oXpNlTg9NWCMwF+UW9cxiB/LStjO w3oA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O/VgTJ4c"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c8-20020a170903234800b001d904d7c449si1927767plh.271.2024.02.17.12.29.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 12:29:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O/VgTJ4c"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5705AB237E7 for ; Sat, 17 Feb 2024 20:25:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 367C17FBC7; Sat, 17 Feb 2024 20:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O/VgTJ4c" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DC567FBAC; Sat, 17 Feb 2024 20:24:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708201451; cv=none; b=m9OenjuRKdhYD1E0hCKuD9WzFBYc6CfKQ3mGftdizUFIAJo7VJoS3CIhp3haM9CZhk7ldLE4F9RBk3n72+phF7uilnh6dvngnLbHgkmwN60bJR33LMJUM2YkeyRB0QCD8R+5VyRAeaFWtI/eRUUanUbaNchNobzheoqPfnsI8Do= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708201451; c=relaxed/simple; bh=r6dLn2R32hxUVKrwHaR6P90sYMJO3HfuXaP1srQuHsY=; h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lGeq762d7q8FXyZEDTlesMwDnrPM9wgHfW9GsjYa69R/XDIHhI3VQn7JDk5eF+GEsmRjqDsQb5Jtz+jc2aLGfWWOvKRyCm/2RIya7HpmW2ZFq5Z5lJ3D4QvJxpNVFBng0ooKBQkkV8LLSek/OgHIfHy0VnVv/VSS8QrE4sjdW8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O/VgTJ4c; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7B52C433C7; Sat, 17 Feb 2024 20:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708201451; bh=r6dLn2R32hxUVKrwHaR6P90sYMJO3HfuXaP1srQuHsY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=O/VgTJ4chu/g5D0kuQ6IwQrqk6Yged1gYNOnPpILQjot3IwuwxhS0tjBHhH+sQ2Kz Zxyb7DTRLGPN4oi1a1lmsh4iMS7n4x8eU7JR4n/7kJCgHm31IjaEMLd1aj3WKlJZTI cWR5pWetfkjmwe/CpCU4IWr+5zr/kolzJq/4IHeq53kuEhX7f+Lj34sgVaaCR9TUTA WqRRhpu5EBPzA0IeI1/a8ljmj1zl5QVpNFm6gr31iF/Lh2h1sWihqI5TErBNv7U0Gl nkriuby+Se6wuvehqDAuLb9N0LS2Jbw55eloingd6OQJgzmXnWAbWh+8Yghq/aV+hZ 9cHhYH/qLF81Q== Subject: [PATCH v2 5/6] 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: Sat, 17 Feb 2024 15:24:08 -0500 Message-ID: <170820144894.6328.13052830860966450674.stgit@91.116.238.104.host.secureserver.net> In-Reply-To: <170820083431.6328.16233178852085891453.stgit@91.116.238.104.host.secureserver.net> References: <170820083431.6328.16233178852085891453.stgit@91.116.238.104.host.secureserver.net> User-Agent: StGit/1.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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