From patchwork Sat Nov 16 01:48:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13877451 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 7F4D2D68BDF for ; Sat, 16 Nov 2024 01:48:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49AD39C001E; Fri, 15 Nov 2024 20:48:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 423299C0018; Fri, 15 Nov 2024 20:48:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29C109C001E; Fri, 15 Nov 2024 20:48:27 -0500 (EST) 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 086289C0018 for ; Fri, 15 Nov 2024 20:48:27 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B7A2A140CE1 for ; Sat, 16 Nov 2024 01:48:26 +0000 (UTC) X-FDA: 82790272068.22.E457708 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf09.hostedemail.com (Postfix) with ESMTP id 5195114001B for ; Sat, 16 Nov 2024 01:47:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zr+fu5+3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.44 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=1731721611; 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=YcF47OPMgV4gAHSoaTWEjiZTKjXBo70DUlqXu2ApiN8=; b=GK98ztwtscBWyChNE8cgcBqEaTVZ9vs4vNHOOKjPUKULPUTlLq6ukvdhfyAYR25bHMv5lL qQVo5AbquWXisn8ZK/b6CWRmnkvzYAOU5eNeuGXExV6gHuGzxwqHLFq5rN+z25pamV2l5C 0XvWL4RLk2BLqkjooEqoW7UIFt9QxF0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zr+fu5+3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731721611; a=rsa-sha256; cv=none; b=wugfPdCrpDg4cG9hLuXxd068o0s+YxdkNBjCzBKrmqHz3Kj3dcykG13e5SzCRydpT3qEco cvCP2hbM7vDdMjQRo+FbqpZZfqDlVeH79xarOlXMBk0jaLqh/92952QOS0vUBDHkDH5jrF TrKeRwq1Dg8LTcKn/5RgfZpQh9Sqddk= Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5cefc36c5d4so226977a12.0 for ; Fri, 15 Nov 2024 17:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731721699; x=1732326499; 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=YcF47OPMgV4gAHSoaTWEjiZTKjXBo70DUlqXu2ApiN8=; b=Zr+fu5+3wh3Vt4gRW8VwNCXFVpOT6V4EmayJY1q9rZ4OyH28O56CUHox/NX8qDhsa8 SU8HvKS1NBKHzhijhou/OFHpU5fGK7Is/e13TPDlQx2ty2H8qIUtHugTWNcGIzBERQGp 9ScTMKVbTSpd6WM/A75q01lGCUZDktJVR63j/99Q3aWs4RiI/5q8Cjj8JImOXwjgJkSV w8vO+NXMd6mbCL4LU/M5Sk8er+fLXImpjFVZokQV1JdlkMe//eQSSown0oTVjA4FL3ye T/ILeYsPPnCZgZL/Fd8HHk0BU4+BG+yBh7seK39w0aG9O6+skr6PIlo+incp8bEKPWsp TZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731721699; x=1732326499; 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=YcF47OPMgV4gAHSoaTWEjiZTKjXBo70DUlqXu2ApiN8=; b=ISXlS16bBZrasyRICTO7AUYxg2jMOjiooxJ5nv+fYRIcJAr8x/LbyT5q1BH17DpkWn 30eLRin3d09oRMaPSedrh7RNAK4AZldRxiaPohkNh+B8Fz0UcD83CtInLh3nSSxZTlBV 0yeDUk+deUVUUNDfsp+uBqndc0GAoElRWTUlX7Pbbfwiuu7bcpCi1U72Bpr9d2bVxLUW BqpJe6c6niikvy3Ftlt0dK3gM2ywjDKfn6vhTS9q5u7qNQLNi5/SqqLEBTlAdt2+014y z7UTzUJivqeKbPAT/nbtlxlp4cDCfwZFiR75If1uBT8klTASAHAD8XLcs7/3LO7kmEt1 QeLw== X-Forwarded-Encrypted: i=1; AJvYcCXHw3V7YNSzHm/9/QOj/PhguZi5lOwR9VxhkIhBOYYZDWuo2aVC1oveubAaFPoaqNxpV+3KhulQgQ==@kvack.org X-Gm-Message-State: AOJu0YyKhFpnXmC5lmRYT0UuJ6sT/dg6Za0y45QkC7G+lfPsxjPkiAh/ Hm+qtaOXK0csChPu1F9Q/hqW7Oypwf5PxQf9EB/HISIA12o9b1T4 X-Google-Smtp-Source: AGHT+IE4Zrpc1KBdRyyM6fBOv/K3r/c9TnDCzrAP58hw4DvATPjPIUCoEdgZzlGw7iwdi4loZrfy+Q== X-Received: by 2002:a05:6402:2744:b0:5cf:7473:3317 with SMTP id 4fb4d7f45d1cf-5cf8fd325e5mr3478871a12.24.1731721698456; Fri, 15 Nov 2024 17:48:18 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20df1ca49sm238564466b.3.2024.11.15.17.48.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 17:48:16 -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 1/3] maple_tree: index has been checked to be smaller than pivot Date: Sat, 16 Nov 2024 01:48:03 +0000 Message-Id: <20241116014805.11547-2-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5195114001B X-Stat-Signature: ck3senurff38mktx3m1xtt4jpzminawe X-HE-Tag: 1731721668-931344 X-HE-Meta: U2FsdGVkX18JowEC3qo2z7RGStoG0JzfRdDuJOFXhqYrTOeekSbBT0rijHi/+I/WFlLDSzfR/DvX6PTQRRud1MgMc3j/dA73t+1dF2FbmjahZ+Nw46NHSFVUohlXXZtSk19QnGaAfDxxc6VqTKgwtJhfbRFzpf1Wbbf91pNsVmhrYTskrp+yTjMPIUOGl9ndXesL1oi6L/Uk4RdrfHjDKbUhE4V62ltyFLomkeUOctVGoX50nOcMcw+T1HMtdSxYm+RtiWwRvqxRIFC9vqIdeaOptw394Ubl8KsHJmB/NX+kmAxvfL1OBCAdAA9ZFWw0FucjVbInrZ6x62wFAdObblxTscw6+zxV2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m1I7s/2zBPgCm9DfiBWy7Kj2or9lzfhrXiieh8Hhn7AMxvfvyrlbeo6d2UHNGyjMxRO7/YS X-Bogosity: Ham, tests=bogofilter, spamicity=0.000259, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: At the beginning of loop, it has checked the range is in lower bounds. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Lorenzo Stoakes CC: Sidhartha Kumar --- lib/maple_tree.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 667326717f35..63dccd7b9474 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4893,13 +4893,12 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) found = true; goto done; } - if (mas->index <= pivot) { - mas->node = mas_slot(mas, slots, offset); - mas->min = min; - mas->max = pivot; - offset = 0; - break; - } + + mas->node = mas_slot(mas, slots, offset); + mas->min = min; + mas->max = pivot; + offset = 0; + break; } next_slot: min = pivot + 1; 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/XCN7LmhSbRgRO3T2QPYUZDbZOPqiMspAzBhKfKFkWBbPyRksct12nL22n5AnNa2hwccfsWJZ1LsPzOkEjziHLf/vX8ZI8ZBlQQUeLbLdcFQKSXojHV3XwYInY5N94RlYrrzR6n5rK1jTcAL9UFQmgvlrszOlQgk3cCjGTDYdjv1DCXXPVIqkoIl2OA6szCL1/q54ACAlyf7saaNMrPogm64OfQKCZeA10LSul4JLdyfDv4mRaG4YkrbzQxmKmoRRFSZE4oKGmD3dapsn+a2dXQl7p9ubSv6h4oWHiVoDlbf6z6sQFQgpeA2NQi++b22hX7yDHzwjSZko9W1y9eF4/aUgCy7txy+FqNEHFvJXPgREOxYDUs323dhz3E60gHqE811wIJqAg/DHCSql53vVQkFu8CcXU2o1xlwkknypZqTZ7OHzg8rk0PKdAAEvaK7OswQ7oAD+FkYP5on0t5ksDKGRk7rFQitwdVMPFyOVZMZvvgDCITQR+dQVgqrMBruObBQib6U+aukqoicRj3Yxlv+L0z+HpWYI8iUdJj89Gl84zcnqVgR0tEkqljyQkArCFjbu7rqb6rr5DjuaIJJcftWyiyngb8pDu7SqjjYk8fDyAn2legmgb6GSlNsL9RCbkck ZMovR4Lh 2yeXHFjBCvrggDPQn2tpNRV9EpZNmvG1TN945Wf397iYkapxmDHN2Zc6ASKZ+YrEALUXvnAph1dkoc2GpepFa3jNtBifLlGN22j1oASacIqx64ipGV0mzvJtzO3oiL7LnQ+ymiYXSkQ+zSEVoeH1pg/KFA4klQW5mVU+1ud6xsEb+ewzSmwLWLQcJ/9qKkcVUQ/3npnc02DuvaKkaflCnlqXavVBcls0DKtao70WkRoUjiGpWoGTevgAVsDJ7i9wC4vdhamGBQ/UIz06yLkOGHqOll8yPN+s2HL+Lsu12ESPzDFdLnr2BqXW1mY+3SbF9xKIy4zBYEPL05GIdBJ/zKhW60kzN+kPN9oQnl6XYJ2S4du992V4vIMDdNCdyUPm3qKJaK20QPMJuAv5Ji5HfuTFqFXanivE0X+6LMp4hG7h87nWJ2dv+HjRnOHIhyk9lnxByylu0ehI9dfH0JoboP3qFK97tpI+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; } From patchwork Sat Nov 16 01:48:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13877452 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 0F683D68BDA for ; Sat, 16 Nov 2024 01:48:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18C639C001F; Fri, 15 Nov 2024 20:48:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 13CFD9C0018; Fri, 15 Nov 2024 20:48:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E83039C001F; Fri, 15 Nov 2024 20:48:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C4B4E9C0018 for ; Fri, 15 Nov 2024 20:48:28 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3D94A80BFB for ; Sat, 16 Nov 2024 01:48:28 +0000 (UTC) X-FDA: 82790270304.20.62B2DD8 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf24.hostedemail.com (Postfix) with ESMTP id 73CD9180013 for ; Sat, 16 Nov 2024 01:48:20 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SD8Ae34f; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 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=1731721527; 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=BNDgC68v8sJKVQZrvcjoA6ZrF1/Wfw50bmTVtryDY/U=; b=EEzltPpFpX9WD9GcvwSpVa4mMcvZAsvSPRggUxd5If3f+U6EsMCTZuQkAyzOgjAgOfXc40 SMsMzkZeolwVSe2BsGPRc4h6e8a49ZLTsUYpuA1OjVkl9S6QR9UFc3qw86em8DD1QKgas7 zd9pShSC/AeaOaofsKfTrdxD8jp0kDo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SD8Ae34f; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731721527; a=rsa-sha256; cv=none; b=uMhehVLfoUk///8G2m8N/UkV1e9GrILxpptTze6Y8S0GxkIP9EmDE5F5KBNO366pzicmtP H4tQ9RL0kWE6xO+Wxge0dK46bvmZLsERRNrNZIqk6UGazZ32M8lpcOMlk7QZBrc67mdswI T6E21d47RrXVuVUrre1nh8lgXbHlSQ0= Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a9ed49ec0f1so405712766b.1 for ; Fri, 15 Nov 2024 17:48:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731721705; x=1732326505; 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=BNDgC68v8sJKVQZrvcjoA6ZrF1/Wfw50bmTVtryDY/U=; b=SD8Ae34fLAmKzRCv1bLhwBzbwRvne9dNLtDtuwY604FSF6mJYcWFSOp6sDr8iJkSCS 7N3xKcB8Xcds+x6+va4r9yBUqDVN1d0nS5hIsSsN5v9O+WUEirXAUOXLXNn7cMmWbH5N Gr4PVAVNAyB0mF6nvqcNWRpcUQPn+sPiHVgNBIDl7v18mfEdDVLx/Ewq5p/HF8022xly z4Fq7L9qQqhnwCjbkcXV2b+tiS0mf1JBGfLQDRgnaKITZm5XwCdlwBQX+ZpSIq8o9VYY eYOPBdY1/q8faVYGQ2GdSISv4cXojqYyv52VrXZv9BME4BZhxiOvDyRwZGdtG8sJaxW6 WFoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731721705; x=1732326505; 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=BNDgC68v8sJKVQZrvcjoA6ZrF1/Wfw50bmTVtryDY/U=; b=IL6BEOYyodva23OH5O2Kr812AMPULkQo3zmvuUjf0gTDlX4db/HVx83StGfziNxjhV N4Euj1CGeflEmdDQSh8F870d1OynN0Nfdu0piaXSEX99C9WBU697dO8ygtwMfMutfPsd vHzfx9LuUqLy7EeQWJy9ynoSboTmzOUx6YP8BFsLSTyNUbH849G8/d4rJf++0BVdJWJJ 7WAYxWXQ9DgmNELhfkkO2fT2HMybEIaZI58eySSlyjFUE3uYQrhX52B6PSbFP1Pp2Qad ewfk2Bqkfp8IR2OgvpRxktMFZwY5SePfTaxyh8SRWBAABAHkNc+Il0x5OkMnJXl1cYqY m1bg== X-Forwarded-Encrypted: i=1; AJvYcCUscViD5hIPGtyoi0To4qaJ7LZBoxVF8JSWXR7aZ3gX15hcBmaUNpMuQ8bDbJJZsxsSioszaMfFag==@kvack.org X-Gm-Message-State: AOJu0YzfDQfHAjJdk12zRweiTS75nIQZ1MCsSXK2OAGKSwrJqraOTTSK gsCfb/C1D4t9DzYLxfpSWNgiS+hqEAK+L4t/zIwGgNDF+RdhH32e X-Google-Smtp-Source: AGHT+IEVKWZ/iq3gc3tHNSgdopeDJYKBCaC9RVkFMhUDCZ/KP+MPgkGlIQnQHCyO/L2VU+jeuebyXw== X-Received: by 2002:a17:907:7ea5:b0:a9a:1918:c6c6 with SMTP id a640c23a62f3a-aa4833e8b76mr355096566b.8.1731721704864; Fri, 15 Nov 2024 17:48:24 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20e086ad4sm238501866b.199.2024.11.15.17.48.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 17:48:23 -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 3/3] maple_tree: we don't set offset to MAPLE_NODE_SLOTS on error Date: Sat, 16 Nov 2024 01:48:05 +0000 Message-Id: <20241116014805.11547-4-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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 73CD9180013 X-Stat-Signature: b67hpj78z3jxttfqw7r5nt96j8fy1w36 X-Rspam-User: X-HE-Tag: 1731721700-169751 X-HE-Meta: U2FsdGVkX1/Lml2hxlvt+qlHC4UrN/HN5prDvHIIMVrcGRoLZVp07UDOLn/t2M25/Tr6kHRiAOPVnhy0orCpZGwChgOR7G7fnXK1JOZDQVXXWyjYMofV+Ksl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ZFj5GCuAkTwu15uhTrOr4RSpN5srQQQN67oWhTYbExihUfx8kxxIgFO1xMS4q3T16izakj7kBqirbqUOWGrY62aXHCBPgbreGcxK3dKC5mmOzTeMwN+OCeBIZ9iYumjNuZIuvJc0Dp+VCrhPDbUac6QV9y2AORsSNDim9YGt1zZa0CKo5WgHTOo0XB/G++DxWjYPwtFV8MhBJagBM1Ac46hIB4RlHAOd7JIv+rI4W8RqddBtN80TS70oMrXVLIEdsXGWdzbscTNVLyYnRjApKBkkXpEVVV5Q15ks9/w7N2S3kA 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: When mas_anode_descend() not find gap, it sets -EBUSY instead of setting offset to MAPLE_NODE_SLOTS. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Lorenzo Stoakes CC: Sidhartha Kumar --- lib/maple_tree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index ab235d0194f7..b67dae356182 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5011,8 +5011,8 @@ static inline void mas_awalk(struct ma_state *mas, unsigned long size) * There are 4 options: * go to child (descend) * go back to parent (ascend) - * no gap found. (return, slot == MAPLE_NODE_SLOTS) - * found the gap. (return, slot != MAPLE_NODE_SLOTS) + * no gap found. (return, error == -EBUSY) + * found the gap. (return) */ while (!mas_is_err(mas) && !mas_anode_descend(mas, size)) { if (last == mas->node) @@ -5097,9 +5097,6 @@ int mas_empty_area(struct ma_state *mas, unsigned long min, return xa_err(mas->node); offset = mas->offset; - if (unlikely(offset == MAPLE_NODE_SLOTS)) - return -EBUSY; - node = mas_mn(mas); mt = mte_node_type(mas->node); pivots = ma_pivots(node, mt);