From patchwork Sat Oct 19 02:37:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13842542 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 4270AD3E1A8 for ; Sat, 19 Oct 2024 02:37:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE4896B00A2; Fri, 18 Oct 2024 22:37:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6BBE6B00A3; Fri, 18 Oct 2024 22:37:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BEBC6B00A5; Fri, 18 Oct 2024 22:37:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 716326B00A2 for ; Fri, 18 Oct 2024 22:37:37 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DD5751C33DA for ; Sat, 19 Oct 2024 02:37:22 +0000 (UTC) X-FDA: 82688790702.18.EA9BEEA Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by imf30.hostedemail.com (Postfix) with ESMTP id 1B01880006 for ; Sat, 19 Oct 2024 02:37:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=T1eE5srb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.53 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729305406; a=rsa-sha256; cv=none; b=1Q8l9+2nHVmlZKgtwKru9Y12OIbJGOPGHt5vtatvI4rofGMgJXxCBAB4MFFjGu/Y9XigAz BWWnNvFIDT6EcNj4b/82EUjUa4QxaAadpjX2o4PD/nO62P9Ulhdpb8TcJdHajewkBnlu+U +Ce4STdPZuikPjOk8vhpBdACWmJBkj4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=T1eE5srb; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.53 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=1729305406; 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=F5Pzm20CYLcjkNnwSf7ys9x85AzpiNweIdnMFQp1ato=; b=pdHuueHgJD4JZ0vu0JHhOw5iUscE69c1ZKyxYQTXb5HbJmQpq5RsO8hzFd6nWuvT15016t 6l3LeNFYuHtxxpDObIZLu/lganY+y986aF+7gvXRIS5iCSFhmOutryFjCZrJRt7ZbUDKoY AIHi7nOJeGYG2hJwTrg2waC0xNr3N2c= Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5c99be0a4bbso3574348a12.2 for ; Fri, 18 Oct 2024 19:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729305454; x=1729910254; 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=F5Pzm20CYLcjkNnwSf7ys9x85AzpiNweIdnMFQp1ato=; b=T1eE5srbEXaI1sTronms+4XtEb9GxHfOp104rmJWdEYo9UJ9uf2bVoFW9MJGTdfMDT SvmR4XNe0pOCObP5ehqa8nH5TE7zr7d86+atGzJkdGyg4sI3oOZvDMsVhz31tP6J1aWN QUQ2SXu4JBPesgMtNwe2tkwfQ5PqjPu9QdD1uy3VTnhFW1O6nbnND1AZ7ixpWVAxDwAm npeuA3jZ686n2d4ue7ZpTdXVvX2KrqOCcynO25+ENHOGy/AaDDrjQOL0f89aWQNk1oX6 BrSXjWdxoBDoSMsnMo6eXAECrqm1qAgaNZzvWwztKhswd5refAck8dpn1zEuPZbk9IrH eLLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729305454; x=1729910254; 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=F5Pzm20CYLcjkNnwSf7ys9x85AzpiNweIdnMFQp1ato=; b=LMbf+ammDgRPdeB/BlIASi4jsoW53/GPSNiYpp8xHXgZUlMa6vooc8YO3fjP0vHz8U W5qRwKjEFGvzUJPy81w/fuz8x/YjWMMUUo9j32GExX2V5mksDPyqn85mqcA/3Sjk/Xrg LumIgjBeOVrRNO3c/E6fUg6067qPRsMsoOaO+GxhWNeJy8LkWMUF5biUPbxteMWq4pPm wBPmicmRjlN3RA/MrpiMVuJIkjJLkTa0mXJLMihdizjvcUtVvalYql2aW3917YN98OfZ ySY7FwGZPHxYeCuwWAlcFoCZclOgP2n9hWYlDP71Bwqc68qXTcLhA+oqrwSTuoFLAgF3 M+Iw== X-Forwarded-Encrypted: i=1; AJvYcCUjdmI7vFKF5GnhqV/Sa7BY9V5j44VDKTuKisfro3gEE/1b/FLYg6gSbj4KIjSy1G8h+jnKC66DCg==@kvack.org X-Gm-Message-State: AOJu0YxqvdXl8B4Tlvd7epwPQ9qNeyZohmOp0hpoU4C7mWvSdFnIaUL5 5vb8iNFQ2oDOQyUS9Mm3Nx/cHmoQSjfvQgyXRPfgGXexO/Zy5r0p X-Google-Smtp-Source: AGHT+IHu9X0Z+YUkSJVe22qVSw4mTGqj1epsJT0iS5Cf31pA+3aA+1hwE1XKT7zCE9TUXGggxuFdIA== X-Received: by 2002:a05:6402:524c:b0:5c9:5bb0:72fe with SMTP id 4fb4d7f45d1cf-5ca0ac62789mr3511556a12.15.1729305453583; Fri, 18 Oct 2024 19:37:33 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ca0b0e6f82sm1337882a12.62.2024.10.18.19.37.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Oct 2024 19:37:31 -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 v4 3/5] maple_tree: not necessary to check index/last again Date: Sat, 19 Oct 2024 02:37:14 +0000 Message-Id: <20241019023716.4516-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241019023716.4516-1-richard.weiyang@gmail.com> References: <20241019023716.4516-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: 1B01880006 X-Rspamd-Server: rspam01 X-Stat-Signature: twgtbaxaub7fcrtdt8ex43yhz6tczw7y X-HE-Tag: 1729305432-787878 X-HE-Meta: U2FsdGVkX1++Ylk1+oZREFjaxQpYuFBDlY318oKHSef7zhusOLcAb5F3JNI6kK+OsLPF3MXOefr7AFH8W/0jpk90hjtHB/p14hLu3uBPniEc/me0/p4TmKdU4iy88fbdrXIrSruVcC+TY+oIrvYR0fNa3A6nzdwElYrblsEzoavGZkVTshC5/PRKxA3hOgWd6lMBAp1N+OGgE4+z0G39InlD0GHH4N/VW67lFlK4vD+Ly1H6gQAtEuKV3/CcOogZ+zQEP9LG858QVxyUCcnh/1rAs5im0iIvfxK+wEiYmKONbj/8FYUnV8ru57NTeosYbNXJVYJSr52n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vzh4Kl31cunrHVn7zSeFOGGk6lQL2odO+MOTnicYBcyJHeUbZghnnL2hpBQjeS+bho1JEbvszeRpD/+eFO5GnZ9+6U94miuAeZ3 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 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 517ddf2950e6..2226e77c00cb 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3662,7 +3662,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);