From patchwork Thu Oct 31 23:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13858438 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 659D9E6748C for ; Thu, 31 Oct 2024 23:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C68D36B009A; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF20B6B009C; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959736B009E; Thu, 31 Oct 2024 19:17:00 -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 622AD6B009A for ; Thu, 31 Oct 2024 19:17:00 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1C321ACE6E for ; Thu, 31 Oct 2024 23:17:00 +0000 (UTC) X-FDA: 82735458288.09.CB34A93 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by imf22.hostedemail.com (Postfix) with ESMTP id 455ADC0021 for ; Thu, 31 Oct 2024 23:16:24 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dkPpjfeb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730416456; a=rsa-sha256; cv=none; b=njI2Hm/biI9xE/td42SCWgH8YWD5ijx11APGog2HSB4M7aZqNxAOZoG/7IgZpUVHp4yY2Z l6l5i2oL+OZbue/g9c7gQmsjPPA1VhjNydQlF651KWUzAAZGzgw9xXjTKL4RyKJTaCPteT X7O8FIBqx984AxZLRGEcr6K0HXou3vM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dkPpjfeb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.47 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=1730416455; 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=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=oUCfhPMJu36T3egRNBDNs+6ybPloVUo9qCst1GnnTDkPvfy3d++Cd//BP/uWZEoZja4E3W Gz6W9Q+zjXvu8spF6Ec4HQXpdQea9i0k8/QkpgE1gyPfv700KDoI/l3N4bGt6ZicFOLcuL Exw7+9O14m8lTJXbKrkIqeM1nZObej8= Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a9e71401844so3220166b.3 for ; Thu, 31 Oct 2024 16:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730416617; x=1731021417; 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=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=dkPpjfebfiFP1TliK8ezEwNPeClb0Q1S1QajnVoPLm0LPwJDBWkcgdGKMnvjO/7rjU quJnwdcXqpWwbDRFiZDRM2iyoTwge0Yk/iKE6qVkmrjbZY/Eb/t+wGwVSRuF2iRisWeS QQuL+87dkaPTQ05DY21o+wBTnQP7QS0/yX8Gmhi2M1srhsMuU0xoNdwGl1pnJCgBpIlk WfQQwSCweyCVBsto3TYtXzskcnyji4QZ9NSQTffuOYVoLNN4Ot0fOQ+ikrmfC0B+vIw+ NtE7SrMdgglTmrwS+aQcZJ3yASQIUvcoaJE2HF3G/t0CVVpqfi+vvQnkPYu5Tcis6hVh 2RWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730416617; x=1731021417; 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=gcFqE4Oz6KR49+L44Z8kkADWOf7Ogr19DZkDm6Ror8Q=; b=fIXQfHnudDoRnnisJZpDaH6FEzkK18/rxFZT2yTJ6lChbPJQnrXXSGhCVl8JAPl1hW mmmtSXRFnaqTnRFnGw4sbXTCesxOh/tSaESj+rcKSItX1oqe+kEhjwbqPHsSikda64oZ tFtTj78JcZhcW/LWrhDW8RKznyCXizngPJ72JIBU0m4QyXmTNFkm8FF2ZphnMfmUhjLY sDJ2fok6yAnElYiXs+6kaJ4ImXvEj3UMJRllUldVeDyYCdd5qmaTvb7AzFzmf6dre9pH jLTvHFVuUe9QO3mFl2hmF56qDSVlxHRnSD1U6W0oHfEH/SVeh7VeWhfj5RTGggO3/hk9 jtUQ== X-Forwarded-Encrypted: i=1; AJvYcCUD9NPRWNFRUTh2u739nqjgksInitAOB6U6P29aCvkjfk0J5zS+9C4PSbCaRjAqCkmUeAPxPaXtvA==@kvack.org X-Gm-Message-State: AOJu0Yy9egBaH/DTavzldN0D/mvYOx87GtJHI1ZLJNqYFsCfI1xMtFIk CG47Lawc7HcSWELn0rwe97+fJ31lMfKNij29gB3BsU2WR9z3WU7t X-Google-Smtp-Source: AGHT+IG/zNXGzQh7mt+iQBuSF34CRxeFuf8RWx9qdbSGI/o9kzmtSVGeo/HU2aoVMhKKGpLZdJsjxA== X-Received: by 2002:a17:907:2d0d:b0:a9a:59f:dfb9 with SMTP id a640c23a62f3a-a9e508ace9bmr476289366b.5.1730416616737; Thu, 31 Oct 2024 16:16:56 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e564c5327sm115126866b.56.2024.10.31.16.16.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Oct 2024 16:16:54 -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 v5 3/5] maple_tree: not necessary to check index/last again Date: Thu, 31 Oct 2024 23:16:25 +0000 Message-Id: <20241031231627.14316-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241031231627.14316-1-richard.weiyang@gmail.com> References: <20241031231627.14316-1-richard.weiyang@gmail.com> X-Stat-Signature: 67pt6riu64seufrz8yz9toqxees7kaoc X-Rspamd-Queue-Id: 455ADC0021 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1730416584-494270 X-HE-Meta: U2FsdGVkX19eFwMPnoi/J4axO1rjm+/RTun7LVmtdMv0y06ICfhI7Tb9IPRbsVP0z9gApgZsFf1IzVrdMFw6yAnZ2lSNoKlbk6olSo8AoAMohQao7TzmNLoEdeHQKvPRDCNl3Xe+0uIyLMKBiCcK29ZN83px8mwRgRE4Ya2GEQW3Ok29MM8ArcVkt9K9eqWLutLJf10LAo1ZHqVbBKvAZ89DXFzYzVt0XL8o2QsE4K6EZi+inRYC0R0aVtlGbTn6HNyeKttYsTou9Rb8G95tg3mGlvASMSN/SW7eVKOZZVkW3Wp8uHyVgo0gKc0bkJog0F5WcrMldm54lN0rvtXygIWBe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2iXPXJ+51VjnvfWINPSJiyxzkTsUdt3eL5AxwOYAK8Pi462r8PXLyfZJCqgum1pV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000256, 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 Reviewed-by: Liam R. Howlett --- v4: add WARN_ON_ONCE() to check mis-usage. --- lib/maple_tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 071d3055f1fa..4900f182e99d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3670,7 +3670,9 @@ 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) { + WARN_ON_ONCE(mas->index || mas->last != ULONG_MAX); + + if (!entry) { mas->depth = 0; mas_set_height(mas); rcu_assign_pointer(mas->tree->ma_root, entry);