From patchwork Tue Oct 15 23:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13837426 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 D3A23D20686 for ; Tue, 15 Oct 2024 23:39:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71A6C6B0089; Tue, 15 Oct 2024 19:39:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C9946B0088; Tue, 15 Oct 2024 19:39:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56A156B0089; Tue, 15 Oct 2024 19:39:33 -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 3211A6B0083 for ; Tue, 15 Oct 2024 19:39:33 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC774C19E8 for ; Tue, 15 Oct 2024 23:39:22 +0000 (UTC) X-FDA: 82677455574.23.43A3E41 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf07.hostedemail.com (Postfix) with ESMTP id DAECC40016 for ; Tue, 15 Oct 2024 23:39:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDtRnBOi; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729035497; a=rsa-sha256; cv=none; b=ShPQ1xy5PhDtWMj/1sLTVaV93cTpkz3tg4ZSHAbKPTagob3HTPzmspuCKWf3OzL2UhA5ob 8rlirPbKcZLj2dvqzDXNabYtgWQxmPsYxPNEXzO+go3z3SJy+VQFHHVN3gD+M84J46V4cK FL9kbEiGUmEdeHXad0y1hMKPKGYMflU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TDtRnBOi; spf=pass (imf07.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.42 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=1729035497; 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=rK9sCH7BMRprmC0SVhuiTVMlbu8841RZhYJRE0a4wvw=; b=uM48RCpIx4TXrnQLkZCafF1/EZVRxeRJgZaeItEfDY0I/Ib7W24yEB9/PUYFWogXabU2X6 5NjEtEN91xY2/IqXsTHHggBYjNL9Ho7FDkDNRJh1kn/3xDANSY+EcVmmkVoWW9IGDWu8lA hD6HT1SD/Q2YbBCV1Zxfzu3Mnc+8KH8= Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5c96b2a11e7so4380104a12.3 for ; Tue, 15 Oct 2024 16:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729035570; x=1729640370; 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=rK9sCH7BMRprmC0SVhuiTVMlbu8841RZhYJRE0a4wvw=; b=TDtRnBOiraIuAH1JsJT/icILH1JaksD384qjrQkriMBkGCWk7FC/eB0RsV/RAW8yBF Jm1O59Cs3nFhsivRlvgP9Yvcec60igbj0Vl+tMqNwpDC07euY3aAMMdFkaiB93WtqH8i X9kH976G1A2Kt0yGTjhmxxQaNR0eROV3ctnmyK6mGc4w2UX/Kjzt9m+806L3y7/Czvmo 7FMrdCo5nNdZexwpEBB+vlKZF8we1KkTFSipmRrjAgAthnT/p6VrsJN7MUu7CMcpT1LY kFBiaG1OZdLxuQ+1Swx3K7KcpKXE55bA99uJ3oIofCj1FetuBKki/bWaBD6soF8GNrq2 /oBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729035570; x=1729640370; 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=rK9sCH7BMRprmC0SVhuiTVMlbu8841RZhYJRE0a4wvw=; b=Gcpk55oLoekGkNz4g99QaKAliKqCb4xqkmMDxafINCvjISl/aWkTRw8Aq1iNsT7TYx 04k0FMRpLjA9BGKPxPp29Nqja3FV9JmVKNqfF9LAlBmDbbwrpxH8SGb0tgwfEb34grNb TLctrqQv7IuCDCU/CElIIb7Hc+Njk4JK0cn/KS/LsouUXI+klB2DsL8nara0H9Sm+v98 HdpWrTi4vuoNAOpLdMCQP0B/J9/fm4p5+HLYK70oQXZxSg4OzQhDcL9KfUxNDaApNEdY FMQ+ZEzFeQ9NN472RKFLxvovC5fjW0PNVt9UYNPU9hCOXU3dFsfyuDIY0abzmx11a/kT tpUQ== X-Forwarded-Encrypted: i=1; AJvYcCXYQz9IthoxWOdtW9gBgTHVtL9Q2v4ORHyy+Muoui2bDyRQ2AMVOw3WoJwrX1KnepsSzjllHxqpLw==@kvack.org X-Gm-Message-State: AOJu0Ywyrot4T24HqU3Hi5xpKmVjgumB8yyxQRW4bEwMC9lEhItxejP7 KgDYo6n17MKIR8shNa+I9K3+hv1/VJNSwBCNGnlWeZq/FypfQ9Jc X-Google-Smtp-Source: AGHT+IGlt4pzcCQ5BPOK2aWaUqY7XOWOEoXqMYZS6Tz//cacV3vQo3ji1MXU6BwC/VyW8OYOLuUVQA== X-Received: by 2002:a17:907:1b1f:b0:a99:e1a1:473f with SMTP id a640c23a62f3a-a99e3ea59ddmr1351429666b.57.1729035569428; Tue, 15 Oct 2024 16:39:29 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a298232f4sm116923466b.117.2024.10.15.16.39.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2024 16:39:28 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH 1/2] maple_tree: not necessary to check index/last again Date: Tue, 15 Oct 2024 23:39:08 +0000 Message-Id: <20241015233909.23592-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241015233909.23592-1-richard.weiyang@gmail.com> References: <20241015233909.23592-1-richard.weiyang@gmail.com> X-Stat-Signature: 1rb5grpojwinqdeikexcuknu6o8i39e9 X-Rspamd-Queue-Id: DAECC40016 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729035559-307899 X-HE-Meta: U2FsdGVkX19vMlNZ9qrNvk2jyE1u+vomGvd57UD4r2NnIE7EgyoNtehza1A7nRN12Eka4Vj2b/pQ5sreyKGuCLOEuGnQ9KJ1NNbdUhlP1rm1mKOrFxRkU1N7lBbyjvSgqZIHAVJGqABduEiTUjhiGo8NSjFuhHMabq2QwFi13Gdz1hh6naAJutloMhP+8ZOY+hHJEx+aToV4rJ0ZxBbhzxctfRxgIFIVicIHtiAiyaKtcXb25T2ZEGlQg/cfDu7ZylgSaHimZPdgPAw6squFJgU0SfbcshQk/KNHYhy5U+slh8KvROPKBAz5BmKzsCBixcFcwke3kRIfojEdh3TQo41FT8Db6Qf6xE7F+2gIVWO6JF4r/1ashQWcNgo1lou0mqu3F4eutc9QFwoTTUraLIswKr8utLQGntukCuHRm2le0uUymS2+HYphb6LCxnMLGvZLuMZu82owsnoOuwIdZo0WZmN0afZYf9LGlumElI68qz95dWDCnHSNFOZnEdfISrb5gXuo99hMAkFENSqyjpPEmrraSgP98kocbLc4O3KRKHvuRWHhgBi4Qy8sUHRTKrppMTfrrCwnwfFn+LySFFCZ/zlEnZ+eoWBO3SFWIRSBFBYQvKBoinVVd+BtNfYq+9FAfsMJqJekncVg8p0t3gSCOTaIfd9nBepWVvQlCZ/9G6u7pruEcjuDk7Pkdl/JCdkMRf9gqVPT2iS7f8yhRkmKaaAevi9hJHPB6jAVI0PGfa+WpdCfpYfzAFxK2QQP2Tto/p7Z6IFE7snjzCBvo5BLQm6Gxmq/mTC4kc8WsESHV58UIM+OsrindXPm/mJ8/HK6LoP4rTqUVxfuKGqAMm9CruURpiaSb1IpItL4VyRDpHmCmEoQ8EfAazeiYtYafKurZBOhNhFlIqi3VYi+jNPjaKcNqMtU8YrDiRMIdOISwfTYC6z7ka+u3vuVkkQrbJbNKOJAHb7j+nqiXeW 9dpa5VVm sjBwaf65sS1Pee8rEY0wjaAFaVR3gp7Qpx/8iR3qUelb5y52QNSNiTw4/gXmcNu1qp8LOtuJEPWkGjnwmE1F7yP6Vv/DOId+cHnyd6ispPuQWA8biSfzubAJ1dn/HuPvcFfzZxFpoae2ubxP8v1WBf+tNriXu+eCdEjv3HjWgDCuagIcZoYCDHJsMoiuftLKjgBBSyqnQgtWlgHih2JZanrckXM15Ik6gubvONxHPSdbQgtB/Ujdtkypq3oOsxk5/LkIel5+OwkAimy+YQci97ZD1xonjN9GBq2RofaIahO96Yuz1PY43QBOHyl5c1BykxSjLtvBRzhniqWauVFJjT0psFU+8dxVvc2VNrkvECWL9wiFVStTpD1uRzTr/OIoAtFmv+Q5bG4oCMVIUCNVqeqa0gqeUX730G9ru9Z5/xd68Dy9JSH/EVnvtvmLrQorQsbgH7FbcAAWQ1y445wQuu44lPfqvLUXd3S/k 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: Before calling mas_new_root(), the range has been checked. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes --- lib/maple_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0aa9fa8fa7de..3a12866a4a89 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3594,7 +3594,7 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) void __rcu **slots; unsigned long *pivots; - if (!entry && !mas->index && mas->last == ULONG_MAX) { + if (!entry) { mas->depth = 0; mas_set_height(mas); rcu_assign_pointer(mas->tree->ma_root, entry); From patchwork Tue Oct 15 23:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13837427 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 86B15D20682 for ; Tue, 15 Oct 2024 23:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 127476B0083; Tue, 15 Oct 2024 19:39:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D7DE6B0088; Tue, 15 Oct 2024 19:39:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF6CB6B008A; Tue, 15 Oct 2024 19:39:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B71A56B0083 for ; Tue, 15 Oct 2024 19:39:34 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3547AA198D for ; Tue, 15 Oct 2024 23:39:17 +0000 (UTC) X-FDA: 82677455700.16.B7BD698 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf21.hostedemail.com (Postfix) with ESMTP id 370761C0017 for ; Tue, 15 Oct 2024 23:39:16 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=msP7sZgO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729035525; a=rsa-sha256; cv=none; b=GJrN2WNsgjuTAK7R4Bd0J46XB4rS79KDrkafuphpODQWuQftojO3y2MxG8y1/VxujD1LUj gm+GuLr9MwaOgRnYXC3VTasij7X5nhuyC6Wyd5AiNDimrS7g+XgQYVtzO214LaN2LVRAIv m6EVY+Wh8K3Ts9CIZwkoIzAPu43jMrk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=msP7sZgO; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729035525; 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=HuSYYhE/JkpFSKLOeglwPqOvNxdz4SQPYnMe0bHyg7E=; b=kKlYo4kK3vhRnbCdMDY5fkYmMUaBqhJeJtb7E62NfY0hd06H+aI0ChnxwvfYggYZVBqZnX IXoljQVqW1vOZmD7eSpX/lE4AyfzZBd4iAuX98ai30goTIZMFkyVB0RNdZKgBGRT9+qGsu hYKdAy2+nK7o39GzbRT0+VIzNLGo5ag= Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a99f3a5a44cso414061666b.3 for ; Tue, 15 Oct 2024 16:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729035571; x=1729640371; 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=HuSYYhE/JkpFSKLOeglwPqOvNxdz4SQPYnMe0bHyg7E=; b=msP7sZgOLXJZ85udeQg/KkF2xiKUk8EGcvcJLvVw3D1wDNdKCocIqJ5kM5NFJ3dxdl llV/dldh4PJCkNOkQzCAbtrQJkGDVVbkHgDlmcvciAoS9Ce586Fq813seq7Mfb3OIJ1d cwSTO0SH61qNU53+gKfEXRbZNO6dXjV9CfJcQKPKlkmGAm/Dfo/EfZ8epQJkt3ZgcCro J/lxKza1Nbbo6oN+YmSVhkl0lIptTMLeOewheKRvoayq8dz/+bToJ75QRreqj+KFn3wy GOxpsefMEItg0WRsBwHH+7a5xuyBUDWJw+/02bwb1V88W6jw/dzbnRZiW7f8fbUekvbJ 1bww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729035571; x=1729640371; 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=HuSYYhE/JkpFSKLOeglwPqOvNxdz4SQPYnMe0bHyg7E=; b=JBs27l+Bclr5Wr7/Tx7uviU9QyzNbE2NmuSNT8Iudb3/5HjpUqZEjmWvSD4U0qktaE Vhb767pXdZdtTKh80wYesI1vbAwNrOwExk7Gl2lVA/fdeVpyH4e42+92TseoFT4qXx08 P92dF+vqqyacQXChJ4WB/dnqUXqRjTuHVYaxGKw8qWfHMXOGMGeOu3aBgDFcO7xju+pS N0YpboGJgpu76ze/ECCCvB/piNL24o9wy3eUmGS9/Un2v3gHkZG8B19zpyBfs2WLw+dn jrDpDRXJ6pi6TfNz0fcIL2b6w+Ru/LY78uAp/vg9+L/529R7zd5gxEOq8+Sos3jHMtxA Z4Dg== X-Forwarded-Encrypted: i=1; AJvYcCV0UuWpkYyNDHVQpM7yS4mPydd4DPM3kgrO8VcmJSoac/dHASbQ9upTiMAp0azujBqr1ecDezxGsQ==@kvack.org X-Gm-Message-State: AOJu0YwbimOTmISNXh9tKO3d0FnBJzyER/g7GyiruGtYXc7MijvPFaEp dkGQuDLLyERiedjzv6SR3IvmkXmtLMVNInDIEFBa56/5IdNWnOCV X-Google-Smtp-Source: AGHT+IEkFxbVt2nizystO1bzmnWwbFtIEPHN4fPC2zeLlxQlLhfnvDqbrl4dATuniR3I8YdXD/xJdA== X-Received: by 2002:a17:907:d2df:b0:a99:f656:2bd8 with SMTP id a640c23a62f3a-a9a34dd96e5mr153545966b.42.1729035570803; Tue, 15 Oct 2024 16:39:30 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a29717cc2sm120025866b.13.2024.10.15.16.39.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2024 16:39:29 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH 2/2] maple_tree: one single entry couldn't represent the whole range Date: Tue, 15 Oct 2024 23:39:09 +0000 Message-Id: <20241015233909.23592-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241015233909.23592-1-richard.weiyang@gmail.com> References: <20241015233909.23592-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: 370761C0017 X-Rspamd-Server: rspam01 X-Stat-Signature: qb3k16546wr34rawex47dnixthy1o17o X-HE-Tag: 1729035556-990000 X-HE-Meta: U2FsdGVkX18urBl+1/YncESZccCJN/Kz8LTvqymWfeXruj+jvtg7k9TqjoKF5aweItpPkv0xO3EQBAbDpMICEeGfJMZDz76WkHxXbWnti/nI0NYos7nz9SB9noPIqd34mpDIamFr/1ZAmNSksDJyfxbNYU5aRP30yH7bYXFQrfd/23jnmnu9U1Vy24qQitXKnyaJvqGFIP4rE47HwHMVHob/JPs8CiFHQF0nWFlm1FQJ2ckyH8bfTFf4FjDWKUnGvqwaPYHGY/trf3GF5VbqMYp0KuxxqlSqbmO1nGU2lpTk61W1pJjfmg6oAudtAPSr2iIz6eWvwFpOpMdF1rqeyuLYJCiVkVjRxrgrA1fCEmPpVorRpsl+1nLbFAxT0/KIjo1GKFJ1ypRSXB7BEGQ2czNZEE1+SUiZm8QfDGReIqRDkGBJ49YwwTK2CxmAaiJy2oCxjcacF9hmUbFla+HlPDhfPTAh0DGjSH/BU0mwsteX9c04m4Hj9ODLXBMpdcsrP6xY48eoZk8f10m4NX+B9XLJi+e5u1kmmrKWr8JEZpc2MFyz2IBPsNCWVR0G8WhKpetGtbOKaX2wUx7jLQs+xJ3kvaVO7X1rqwbn+KtAh0lkcNzkGRQm2ddu83v3FsjVRKs/nJFP3AgrtWHrweIUyoROK+idMY8N1BTvxOva3OjjP0B1ViDicuKSmW55iXItxxa+i/c99F5lYnNkSCW7qgQ8vpt+STFZHRLwLgTAAk98LyimZLkoBbl1B53Auyyk5dUtK5PngK7sjLBGlpqyQBP8I9fiFZDvgQDmAbxMnXJDkq1KiMt68JgueO7yQEuMraijib3uxR6esnkJZxWYaj2TTsoMCAvqJm8p4x6apmnK0j0B8LRbOA+r7ssNHPzdWL/fmz1xXCrgzLCH0v8hcQRQMHYfpZNwex3DHYbvbfxZ7auIa0puJ+ONdBBP6QjsQUTYp4fdTUphCzJtAAz XtZbqX2j 438GjrT0FOjgePSqdZbm6yiHJG3taKNS+I3zydUh7cEd+iHaMlfG1CzRGGi4tL4UjxVwiRUhh1KhjB5yuBue2dW/qM07sY1WZ0iUzr87Mzx3AD3QbioXvaeEYsDYpRbadAfdjjfUzWq+s8JX5r+/IZXZ/0IT9y2krhNgtKK8v3wu76v+hjnuIEREEDLp1BO9T7Co5alCGLKtmRZAvvyHARRyuHuS8VKaCTLXt2ReBKrFehEmBNrju2W5WAekPHh1D6TGbHlU0vDxM6bTWPDMfhqrog+6C0wQyFeL1h1gmjcOLsbQ9OWoCi3S3IQtkSr9HxixZ/KAO8f7iXdalxC8wG4DBRx8gkFByCqqccvFZP8y8pzTdy2GCO9letF7ssfrVgErn4V6VMZlUG+jDdZ7u2/d3dVPXRa9IiL+eBx+jl+LnhVPfaGywvDmbch/lB1EcoJs7D5k4MwGv1MWKgYo+/hSjm1+rWGhVA5YGN/Bq5m2AOUDJNuYVB1vRUhFKVjsRKpBE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The current behavior of overwriting the whole range with NULL is not correct. For example, we store range [0, ULONG_MAX] to a new tree: mas_set_range(&ms, 0, ULONG_MAX); mas_store(&ms, NULL); mt_dump(mt, mt_dump_dec); The dump result shows: maple_tree(0x7ffd9506e350) flags 7, height 1 root 0x61500000010e 0-18446744073709551615: node 0x615000000100 depth 0 type 1 parent 0x7ffd9506e351 contents: (nil) 18446744073709551615 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0 (nil) 0-18446744073709551615: (nil) But if we do the store on a tree with value: mas_set_range(&ms, 5, ULONG_MAX); mas_store(&ms, NULL); mas_set_range(&ms, 0, ULONG_MAX); mas_store(&ms, NULL); mt_dump(mt, mt_dump_dec); The dump result shows: maple_tree(0x7ffd9506e350) flags 3, height 0 root (nil) 0: (nil) We can see even we write the same range, these two trees are different. The second tree only has an entry represent range [0, 0] instead of range [0, ULONG_MAX], which is not correct. The good news is it doesn't affect user, because mtree_load() still return NULL for each index. Let's create a node to represent the entire range even for NULL entry. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes --- lib/maple_tree.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 3a12866a4a89..5dfc589a8cde 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3594,14 +3594,6 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) void __rcu **slots; unsigned long *pivots; - if (!entry) { - mas->depth = 0; - mas_set_height(mas); - rcu_assign_pointer(mas->tree->ma_root, entry); - mas->status = ma_start; - goto done; - } - node = mas_pop_node(mas); pivots = ma_pivots(node, type); slots = ma_slots(node, type); @@ -3614,7 +3606,6 @@ static inline void mas_new_root(struct ma_state *mas, void *entry) mas_set_height(mas); rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node)); -done: if (xa_is_node(root)) mte_destroy_walk(root, mas->tree);