From mboxrd@z Thu Jan 1 00:00:00 1970 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 8B7EAD3C536 for ; Thu, 17 Oct 2024 22:21:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4976B007B; Thu, 17 Oct 2024 18:21:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7E726B0082; Thu, 17 Oct 2024 18:21:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 914FB6B0083; Thu, 17 Oct 2024 18:21:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 769506B007B for ; Thu, 17 Oct 2024 18:21:32 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 585CF16039F for ; Thu, 17 Oct 2024 22:21:19 +0000 (UTC) X-FDA: 82684516530.10.D420885 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf26.hostedemail.com (Postfix) with ESMTP id 91B7314000F for ; Thu, 17 Oct 2024 22:21:22 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="L/kv/ImK"; spf=pass (imf26.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.50 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=1729203544; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C7i7VS/+s8UjP0b/KLzSL/fIwM2E6g5D6tNIeRBMldA=; b=ch5GQAGqlcp0+oeG55bLLDHCbjQj1AMXOaTsv3ld9Qdugf9Oj8bs/4LoK6CgEIdJpe1bLy krMaoFwlwhASah/CWho6bE3g1gFow8cByh90h+Pr+n0dAQd78t0pOtNDlxTCNk1JetoIEt MyVrPV7gi6M6gC7yyyVYZUERBl+1lWc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729203544; a=rsa-sha256; cv=none; b=Rk8oyzD1cYn/SfHeIUaLEy5Qfehx/y8Z0+6Q2V+hnfx6l63hQatcZoRB0f8gUWezeqknoc FT3NcqwGoDVcEd8eRKojhBF9AOdp4OQhNJ5E45P1nHAP8fvMealzb8nnEtD85DcmKFGaGM uGbJGs2gJRNPHb/XDeFVnRwCWNQzgqI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="L/kv/ImK"; spf=pass (imf26.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.50 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5c937b5169cso2295089a12.1 for ; Thu, 17 Oct 2024 15:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729203689; x=1729808489; darn=kvack.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=C7i7VS/+s8UjP0b/KLzSL/fIwM2E6g5D6tNIeRBMldA=; b=L/kv/ImKNhv8b0o82XCgXOUbWGF6c3rrsEkt1FfstH7aqBfnE2M5jPf3f4fo2tS4Ru rFXC8On5N/pSWs61mcmx7SJZOoHH4t09tgoHCjfT/TxUDoq5stxpUx/uA33Sy+q44Rm+ fgXij3OV4vXfEzbQAyJ7qQrS6NHRhIsLt+g5qWAc1hoCLUcuyMYvs7tVGRfWHr8IlfQ5 UxQzIpCEJBftYDJsLlNEvbWt2zMgkW2UZ7SIFnnnZLGlI8Mm/P+/tpkBT1xwL/l9H5g8 O4HIEK0LG37y33qfQ/Meb/djBxusYQ5h1d9awrNIXQEeCzQM1kQmbtEFlnFEtqiNyTTj Zk5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729203689; x=1729808489; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=C7i7VS/+s8UjP0b/KLzSL/fIwM2E6g5D6tNIeRBMldA=; b=b4LXrbB1KWtDM6qIlfJ25J3SIgRsJhjFwb+7JARu/h/SMREk9Kb6OpfK4zI93S9fkC QkprHsmkwAVDiEkQ+dOLAfVHLh5equc7DLnsNxTavalgDhiIhsYeltrKkURov6C5Wozp 1K7k8ZOgneby3QKdXCYeUiYp9ajVqpzW59+eSczaG1ymVTna2Epx3YsYz8ZLzzuFSvAb zI8+/pXxi/PQ7jhM2i28a/aNOuUyUMY3GKJgaQAFHCrSLolKG+GNsw2DEQvh0T/7skS6 peZXAWkxYisRJ1UIMTkeeqE66yCOeh49UjE7UhskSinhFv7+aSn5xLRX5iwoqrqRgKQG FvWw== X-Forwarded-Encrypted: i=1; AJvYcCUa2AlwBcEeL3UYZMr03vkCdsI2oWXH+55Vlr4kQrdm21LJFNVnvJisnVSY4dXqXPiPsWnPiSMgig==@kvack.org X-Gm-Message-State: AOJu0Yyj/N3vpzF2J7XGs2/92wT/HlLlFl1jeaDBX/3lf7zbZ6ejULFB zG7GSS7+MJvK3Tml3vWmv4sRcP1IVVe2ke2OW5xdD9N86CyTFy5J X-Google-Smtp-Source: AGHT+IFboYuJlQdyC0iVCfdKNLuOjrRcNRT4N4UR6RqaT+4QGunGOOgXaCzESzBv6fqqezoUo0HMVg== X-Received: by 2002:a05:6402:3553:b0:5c8:bbc3:9dff with SMTP id 4fb4d7f45d1cf-5ca0b08ca9amr207662a12.5.1729203688362; Thu, 17 Oct 2024 15:21:28 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ca0b0f96b4sm53035a12.87.2024.10.17.15.21.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2024 15:21:26 -0700 (PDT) Date: Thu, 17 Oct 2024 22:21:24 +0000 From: Wei Yang To: "Liam R. Howlett" , Wei Yang , akpm@linux-foundation.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, Sidhartha Kumar , Lorenzo Stoakes Subject: Re: [PATCH v2 4/5] maple_tree: refine mas_root_expand() on storing NULL Message-ID: <20241017222124.wpcv6kf6b4636jvf@master> Reply-To: Wei Yang References: <20241017134607.30206-1-richard.weiyang@gmail.com> <20241017134607.30206-5-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Stat-Signature: ooebfja69douft8ih44hqbgjyuf3xh4e X-Rspamd-Queue-Id: 91B7314000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729203682-885191 X-HE-Meta: U2FsdGVkX1+YZDyIcp5k0w6VExPUiCfFjk4DCIVsGEdEh8/F2CFojacLhz4USrneppV416Q0ipVs/kcdRMqZuCfafOpzyX+NtEvaki8dQHN+r8+xtNbopDzV7fc7weCcBhLy1QCpOnBSREFObdYmqb6d6m+2WIHZ6e5FP3V8LNVsydZBiTuKFUv3+cXV3lkuh7ixKHANqUi9VU3nA2XVKBZ6E1GUmcW3cEExz0NpcUgSRlj57WSj+bP5WM5Xu4/StKICfPzn4oKiJNOqMTWs9kKOrfFgakmZxBtK7bIdyXoM4lLqK7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Oeigi4zZ/ngDAJb4Cu2e71XaHAQKygE33y+7TdAEhPLsCp2H/nxTKJJxvUE5Z8aR0j6+ddy/5DqBJSi/EN3aam6LNg/dVq+TfsZWsZ0mhR+NNG/sFLAeo9D6vUz/RD8dwtknoVODD19K7g1n2NYf71GzUO5usS4yW29GFA/gMnAaWJHMXfkcGQb82odfHPjI742SzXd8SnNwAS9xVESpk/7iPZF+MoRMO844XkAgz5oPUvHwHnz6GXUlJANScDrjJStszy4DNGaby5DJVwj+RR/3pJ5q/pZS+iOyRTcnYaWmbt0PS9qS7LHIjSnvF2y+RYqACWdNBFvAYLOJsBxM3joQ== 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: On Thu, Oct 17, 2024 at 10:10:20AM -0400, Liam R. Howlett wrote: >* Wei Yang [241017 09:46]: >> Currently, when storing NULL on mas_root_expand(), the behavior could be >> improved. >> >> For example possible cases are: >> >> * store NULL at any range result a new node >> * store NULL at range [m, n] where m > 0 to a single entry tree result >> a new node with range [m, n] set to NULL >> * store NULL at range [m, n] where m > 0 to an empty tree result >> consecutive NULL slot >> >> This patch tries to improve in: >> >> * memory efficient by setting to empty tree instead of using a node >> * remove the possibility of consecutive NULL slot which will prohibit >> extended null in later operation >> >> Signed-off-by: Wei Yang >> CC: Liam R. Howlett >> CC: Sidhartha Kumar >> CC: Lorenzo Stoakes >> --- >> lib/maple_tree.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> index a90c29156fe2..15d2124acc36 100644 >> --- a/lib/maple_tree.c >> +++ b/lib/maple_tree.c >> @@ -3335,6 +3335,24 @@ static inline void mas_root_expand(struct ma_state *mas, void *entry) >> unsigned long *pivots; >> int slot = 0; >> >> + if (!entry) { >> + /* >> + * We come here in two cases: >> + * 1. This is an empty tree >> + * 2. This is a single entry tree with range [0, 0] >> + * >> + * If this is an empty tree, the result should still be an >> + * empty tree no matter what the range is. >> + * >> + * If this is a single entry tree, we should set it to an >> + * empty tree if the range cover [0, 0]. Otherwise, we don't >> + * need to change it. >> + */ >> + if (!mas->index && contents) >> + rcu_assign_pointer(mas->tree->ma_root, NULL); >> + return; >> + } >> + > >This fix should be done in mas_store_root(), which will probably reduce >or remove your lengthy comment. > >mas_root_expand() should... expand the root, and this isn't what is >happening now. > Right, will move it. Thanks >> node = mas_pop_node(mas); >> pivots = ma_pivots(node, type); >> slots = ma_slots(node, type); >> -- >> 2.34.1 >> -- Wei Yang Help you, Help me