From patchwork Thu Oct 17 13:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13840070 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 AD5D5D37492 for ; Thu, 17 Oct 2024 13:46:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B5EC6B0093; Thu, 17 Oct 2024 09:46:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 96A9D6B0095; Thu, 17 Oct 2024 09:46:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7935D6B0096; Thu, 17 Oct 2024 09:46:35 -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 506A06B0093 for ; Thu, 17 Oct 2024 09:46:35 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 65D7E41429 for ; Thu, 17 Oct 2024 13:46:28 +0000 (UTC) X-FDA: 82683218898.16.74D2A50 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf22.hostedemail.com (Postfix) with ESMTP id 3777EC0013 for ; Thu, 17 Oct 2024 13:46:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ftouWhaf; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729172647; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=vQUsLpJVYTnYrFCC75ffC0wcR/GYWw0KCo4i+B13an0=; b=fjxsxdoD/RV1InQmsI+rdZR5oJPiA5e28ES6u2xS2zy3Tw/hmfFMhXjWisSeKL7JM29Y4q 3jLVW93XzbuLiFEHEFH5aszRtWIp+cQwoFm1ChCj67p4jfVRTw2hjvzxMbeL709/ezzJkH AlnJrgOZnfz6joyvKmmfq8cn/0cfKQI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729172647; a=rsa-sha256; cv=none; b=PriP5K0G28M116bDuk74EtmKZYLtKxMpbWXTodavHwP17pbqEJYdFpcrQu1RKffqq/VbES kfJ1SLF/eglPWeD/au+Db6wS3ja3UZ//b3myNFDDLRg9CXPExxnAbSAMiAxH327VrfuMZU eF/kkZjbc9/rO+l6N5bw8qTxY2UeL4k= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ftouWhaf; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a9a0084f703so131488866b.3 for ; Thu, 17 Oct 2024 06:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729172792; x=1729777592; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=vQUsLpJVYTnYrFCC75ffC0wcR/GYWw0KCo4i+B13an0=; b=ftouWhafNIYapXEKYILA+zqgmZuT+5O4d6pnOc+HYDJE0WWM4vvtJBqlzlB/gpRdPa RrQlYe4I7oa9VBl7w8XKuVxYVenmiFaG1fZH+s59N8soDqHJuqTMZQ5p+xmNcSkw8qWa iPKdXphbwR7XXS4H5h5NAvuHKtQe39XgjxLKuDH3hPnx6rt3uEPlIIzRukKnhhvC/K/s +6Qa+JyJtJB3VEP9O/NsFVs34RLCZwu22a6skXLJ1NDnQQj6ghPje/l9isEus5ycSKHF nWiJNG/nRmjLOBwRIcgszZd+gsFc8w+RTT3oifog7zI1o0RixFGDP77DdDBzTl88wxpJ S34w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729172792; x=1729777592; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vQUsLpJVYTnYrFCC75ffC0wcR/GYWw0KCo4i+B13an0=; b=weyp74wblqAumh5RkDxevIOVkVKfPjbiRQqBCRyNv8DzW0SlQ01FfjugVfDBrqtd9O +8nF6ce8Aq0xc2Gpz/2uY5/bKxEM2acr9Lnpx3MtS2d4tOnIKi6TJQn3Okm+mDAyAKWW IjPyADUcrzNpZouXAJGQi0rF197uSz2SiGim4cj5A+frKrAJmUeShxVQ9DWwCSSsVmeh u9yIEPsHfqU0n07qBRrCL+Dl3qu3tNlLoMyDTg7nVqOJe5EaYtGkI0mH++JpTZvViKnG uQ8iqvQxRzg+TlNnTyTUM99eastSVcchXEfU2SggYvbSlUEZtFClz+YfmtYFoeRFSrMF MhOg== X-Forwarded-Encrypted: i=1; AJvYcCVadvcxUDocUR6igiRJvcg2A4WIwwG/hLQ8yEGMrr7Pc+FymxFkyVrZ45RxOCZaha4iBc31YT4TFg==@kvack.org X-Gm-Message-State: AOJu0Ywc5ix5/PPZTlvl4F58tyTf9aXQ1ULOYQVihEBUGQ0/VTZuF50Z 7xZuobDMI52871zamhEFLpXhgIQKH8BddiBgaXAChMkz1l7wQq6a X-Google-Smtp-Source: AGHT+IFLHHKovlEcSp5LeVVlvgM58L1AB9wvK9Zmq617AL37nHverGskkXGKCJSittusdeStlcZ4Qg== X-Received: by 2002:a17:907:f789:b0:a9a:4a:284a with SMTP id a640c23a62f3a-a9a34d714d7mr670402366b.26.1729172791473; Thu, 17 Oct 2024 06:46:31 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a2984dc13sm304730466b.149.2024.10.17.06.46.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2024 06:46:30 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v2 5/5] maple_tree: add a test checking storing null Date: Thu, 17 Oct 2024 13:46:07 +0000 Message-Id: <20241017134607.30206-6-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241017134607.30206-1-richard.weiyang@gmail.com> References: <20241017134607.30206-1-richard.weiyang@gmail.com> X-Stat-Signature: 1wxro9jj5bft5ffqu348p57ooef5846y X-Rspamd-Queue-Id: 3777EC0013 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729172780-300969 X-HE-Meta: U2FsdGVkX1/MA/SUoCQDsJsyOSSfJfLGWv6LsHZG0Pj8dFxOTxvnkwSWie+Gtae4EzP2b90WhGIl4PfFrE/z98P08v1aD3B10oyjPopsuu6i2qNI0xCP8sZhc5EQx4xP6wCoBF6HSVI3G9kXWIy65vtZPuf1qchun9JKfWMFPK7wR/KzheHD1pNf04PA9BA+8JAtyRKcMzRyNeHUmGsys91HFRev8b6qm+AU2q49iohlWTfvUevLoqdIg8B0ljWZT7cE87GYuxy1dkmrIlqiJP74nrxq0Q6sIgKGBAfBvAXb7dx7PcrvLcPRvaOLBoC/0S2FyDCISi8/OR+dJqG95D9MT15MvvOrl17ninzYmEyEtNQqSVmvk4S4s44soFil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eOgIkqo8g9n0xTQkoCpZabs1JlygC1KK9Xgr8CA44TNzF 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: Add a test to assert that, when storing null to am empty tree or a single entry tree it will not result into: * a root node with range [0, ULONG_MAX] set to NULL * a root node with consecutive slot set to NULL Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes --- tools/testing/radix-tree/maple.c | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c index 5fde09999be4..fbb08f151b01 100644 --- a/tools/testing/radix-tree/maple.c +++ b/tools/testing/radix-tree/maple.c @@ -35867,6 +35867,75 @@ static noinline void __init check_locky(struct maple_tree *mt) mt_clear_in_rcu(mt); } +static noinline void __init check_store_null(struct maple_tree *mt) +{ + MA_STATE(ms, mt, 0, ULONG_MAX); + + mt_set_non_kernel(10); + + /* + * Store NULL at range [0, ULONG_MAX] to an empty tree should result + * in an empty tree + */ + mas_store(&ms, NULL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mtree_destroy(mt); + + /* + * Store NULL at any range to an empty tree should result in an empty + * tree + */ + mas_set_range(&ms, 3, 10); + mas_store(&ms, NULL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mtree_destroy(mt); + + /* + * Store NULL at range [0, ULONG_MAX] to a single entry tree should + * result in an empty tree + */ + mas_set(&ms, 0); + mas_store(&ms, &ms); + mas_set_range(&ms, 0, ULONG_MAX); + mas_store(&ms, NULL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mtree_destroy(mt); + + /* + * Store NULL at range [0, n] to a single entry tree should + * result in an empty tree + */ + mas_set(&ms, 0); + mas_store(&ms, &ms); + mas_set_range(&ms, 0, 5); + mas_store(&ms, NULL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mtree_destroy(mt); + + /* + * Store NULL at range [m, n] where m > 0 to a single entry tree + * should still be a single entry tree + */ + mas_set(&ms, 0); + mas_store(&ms, &ms); + mas_set_range(&ms, 2, 5); + mas_store(&ms, NULL); + MT_BUG_ON(mt, mtree_empty(mt)); + MT_BUG_ON(mt, xa_is_node(mt->ma_root)); + mtree_destroy(mt); + + /* + * Store NULL at range [0, ULONG_MAX] to a tree with node should + * result in an empty tree + */ + mas_set_range(&ms, 1, 3); + mas_store(&ms, &ms); + mas_set_range(&ms, 0, ULONG_MAX); + mas_store(&ms, NULL); + MT_BUG_ON(mt, !mtree_empty(mt)); + mtree_destroy(mt); +} + /* * Compares two nodes except for the addresses stored in the nodes. * Returns zero if they are the same, otherwise returns non-zero. @@ -36344,6 +36413,10 @@ void farmer_tests(void) node->parent = ma_parent_ptr(node); ma_free_rcu(node); + mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); + check_store_null(&tree); + mtree_destroy(&tree); + /* Check things that will make lockdep angry */ mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); check_locky(&tree);