From patchwork Sat Nov 16 01:48:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13877450 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 5AD27D68BDA for ; Sat, 16 Nov 2024 01:48:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3C0B9C001D; Fri, 15 Nov 2024 20:48:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC27C9C0018; Fri, 15 Nov 2024 20:48:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A161E9C001D; Fri, 15 Nov 2024 20:48:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7AD1C9C0018 for ; Fri, 15 Nov 2024 20:48:25 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3BFD9A0C51 for ; Sat, 16 Nov 2024 01:48:25 +0000 (UTC) X-FDA: 82790271942.23.29E0E2D Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf12.hostedemail.com (Postfix) with ESMTP id AEB1640006 for ; Sat, 16 Nov 2024 01:48:02 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FHTEIdDg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731721523; a=rsa-sha256; cv=none; b=BJk6U0vkMrrXXsxWzIW+NxI8NV3s6VrHmzvV+bMGfrDNu/1PiVG7yAVZ5+7YhjTDLfi5j+ 6AzuRfPXq08Kn261+1B8mF3rMG92XOZ+yAN8qvBrNpTSq8KGbocDvvtKHrWjiL/ZkZwwv8 GSRjQEqhcqQmgTsECCpKqv+70nvm8UQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FHTEIdDg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.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=1731721523; 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=msokFv9RdAKNmPKFZ+3ZhxZgblEp1OUlFHB1o7bJR9A=; b=xJFh2plxUXmj3jcZRoYumNVDBfWK++tz3lrELZ/AXJy8lPqvUgBm1g+NFbTz8/Ph77KMwd 4FfpxItZ7XHjY49Q/9CSm+4r3BghIC5QBwit6iBhLOzelEphnQITZfWo6L8k7X6NYci5/L mmpp9XF5seR81vpmYJwsTl3HQhU1Sts= Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5cb615671acso60816a12.1 for ; Fri, 15 Nov 2024 17:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731721702; x=1732326502; 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=msokFv9RdAKNmPKFZ+3ZhxZgblEp1OUlFHB1o7bJR9A=; b=FHTEIdDgsIlEJs87Z4AMLrw8Ai1RJ+bVl7phomxMmLMwdWBxa5qTl3ohzPtBcC+Mlg 0W16eUXbb3f9ghNBaHJUC5OYozY7hy72f67q0C1bdstU2ZNtJVggOB2SsL2wYspHXyGb LTYVtRabLML9uxTsxjyVAXoInwNMW3vt9mcA4VNuNRoDNg8HehH61FOTmFq539lQoFNf wjTKBsLeOSCsx/zPLisX82QbUHBgEt1fld0KaxKDLgTSWzdwbmm0At8uEjiG7hJp/VvJ a1X8c9MrToVbyK8Q212wVwv+NLVFpZjLO3G0MeUFLWKWE33BWAumHNQqV2oI+nkEosNT UKUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731721702; x=1732326502; 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=msokFv9RdAKNmPKFZ+3ZhxZgblEp1OUlFHB1o7bJR9A=; b=oeAlS0dF8UWhxU6DzgKJvOqTlQRI9mCc2mk6SJYcLYjlcNuhPpDEgG4GSwl4+fOenX xrxproapA/nIVOdnGhzl90/eSu7RcLSKOt5yqop1++dNxGZFd2UcDgi2tO52fBCmhRhn nV6ivjBl+v00YGUHsKCl95kHRevUaK9DTK1uUsepEPwJBpNERtnvmL+o7xC9tP+0Zp3K i8kcy4dX51k+hxZ+RkZfobjtR0qR25SQX94Y1wrCgMMYAUARkZ8Drs6RG2lycexOqRW5 mkBF0PuJyQPf9GCKEq6UnNcVOoT3RA7DTDrOHY4uluXK4HbNjS0i9RGlMSGP6b37RRhc ECKQ== X-Forwarded-Encrypted: i=1; AJvYcCXySq2sCWh40xMQcj8wWJbvo+qd8yAyjjFvwETU6QnNM1di2YA74nOcrPsEwilpRGAnhq0/xg6Ypw==@kvack.org X-Gm-Message-State: AOJu0YwHPtviuWz4QQVOST3jYPnN3vHqULl6TTt4xXLGOyt0IuQxjCZs GLgShgDjE48w/QP1IR67N7jTjyvQ42qGKlITvWE/68OVgsHIalAt X-Google-Smtp-Source: AGHT+IE6N5G874CuhYxh9tPwL2DJtH0Vzen95DMC+jq87OjICu/3BI3XEaBVM/f3cpFef422pHlJOg== X-Received: by 2002:a05:6402:2747:b0:5cb:bebb:38d8 with SMTP id 4fb4d7f45d1cf-5cf8fcc6d6cmr4094295a12.14.1731721701723; Fri, 15 Nov 2024 17:48:21 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cf79b8a931sm2076652a12.7.2024.11.15.17.48.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 17:48:20 -0800 (PST) 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" , Lorenzo Stoakes , Sidhartha Kumar Subject: [PATCH 2/3] maple_tree: not possible to be a root node after loop Date: Sat, 16 Nov 2024 01:48:04 +0000 Message-Id: <20241116014805.11547-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241116014805.11547-1-richard.weiyang@gmail.com> References: <20241116014805.11547-1-richard.weiyang@gmail.com> X-Stat-Signature: komnw694tnrtmpwx4tpooofjj6r9fqji X-Rspamd-Queue-Id: AEB1640006 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731721682-969272 X-HE-Meta: U2FsdGVkX18uMNjjqQbB/6It4pOg16sJrKB5IugB95AgEWBjVW+3zFFQJjqhmGFFht2Ws8fLwpr1RWv0ThP9JUagCnn0ngbckBuK+5pCYlfwge9FfKZAGOPbVoc1IkU36maS7ncUzcBUp4UV1fhTmzenpNHcAo0iUTqbjfVg7qTATqzoKLsqPXirROcpA6Vd09gnxnGFk1iDyIch9+tdrQ/MBko7TVX364rzefK0NiFa53uxWK3hFIY8BHvraGoo8sQFAq5BXT0tFLKyRznEF2qV0Te3+yjG6DDTr9nyY5/mlN3S78j3/xAXXiWm1QA9o2tPVNA+apwKjgX/XCN7LmhSbRgR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nxByylu0ehI9dfH0JoboP3qFK97tpI+IwkW2wby1viiTqvDWREOw9pdMZifXb5FT+hpV X-Bogosity: Ham, tests=bogofilter, spamicity=0.006216, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Empty tree and single entry tree is handled else whether, so the maple tree here must be a tree with nodes. If the height is 1 and we found the gap, it will jump to *done* since it is also a leaf. If the height is more than one, and there may be an available range, we will descend the tree, which is not root anymore. If there is no available range, we will set error and return. This means the check for root node here is not necessary. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Lorenzo Stoakes CC: Sidhartha Kumar --- lib/maple_tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 63dccd7b9474..ab235d0194f7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4891,7 +4891,7 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) if (gap >= size) { if (ma_is_leaf(type)) { found = true; - goto done; + break; } mas->node = mas_slot(mas, slots, offset); @@ -4908,9 +4908,6 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) } } - if (mte_is_root(mas->node)) - found = true; -done: mas->offset = offset; return found; }