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 7EC4EC77B75 for ; Mon, 15 May 2023 21:16:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BE23900005; Mon, 15 May 2023 17:16:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 06E0E900002; Mon, 15 May 2023 17:16:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9FA2900005; Mon, 15 May 2023 17:16:15 -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 DBA0C900002 for ; Mon, 15 May 2023 17:16:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BA1AAAF2D7 for ; Mon, 15 May 2023 21:16:15 +0000 (UTC) X-FDA: 80793747510.10.B505082 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf28.hostedemail.com (Postfix) with ESMTP id E1083C0008 for ; Mon, 15 May 2023 21:16:13 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=mjIcxdOM; dkim=pass header.d=linutronix.de header.s=2020e header.b=mIWjKwOG; spf=pass (imf28.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684185374; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DZHhrNE+lQbMd0iIV/PZ3+/ZDJKPK1+e6kKnPQuIdO4=; b=8Jl2eiXGBK8uFshoeeQeUNc1qRThzyfiXjI+E2KvxnwkLL2uBWjGPDeTR1bW+DOLN+AGul EvW8YrcEUyKAQdWKNRsABaC9bXbj+DOBEQJChq7m+NiD4V03FV4zXubkQu1yM617A3RkXy +W3AErf6oabMczWr69zHzPa65Ezxl4s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684185374; a=rsa-sha256; cv=none; b=OrfVw/U5UUg+eE6unQRxB/4h0Jk2Zx1MweonxbTYSLiE7XzMnf/94kGZyOw5Y0jNydG1de JC2bu/StQTRfKD25chwLf2ZV7fw6aMCgren+KgGF/pHdQsIdjTWvGwvb0opCoUOoc5P3FM i10b7RCxQaqzkMJ5ilFC+D8K2wyIsh4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=mjIcxdOM; dkim=pass header.d=linutronix.de header.s=2020e header.b=mIWjKwOG; spf=pass (imf28.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684185372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DZHhrNE+lQbMd0iIV/PZ3+/ZDJKPK1+e6kKnPQuIdO4=; b=mjIcxdOMt117Z/QHUdcxvAHXIzHvqhmCiIOD4xmpVwTwKEFP3bAbA4CeE0Rbf7q97sD5xa XT5sPi25X90ACLaZuBUj533X3Gof2ZS+mkXZNl3+nGiDJy5Kxx71nsbfFeOn0UCx2gvHZr bowCkjef4fchr61EnWxh1gz2NK8ot5IByR204y7wZY966ZtDpEx7jKYbsjeBUvhMLBL1B/ 26Tr9LWuCQhQG06+xDS+u6Bn1jfRFhMeGO1F3R/QLLegky7enBvgqwzgRUqPCvLUdyozhT MrX4wCGrt2CwEEh1vKnNwG+ytq9epy97LtAeaEXtw1fs2LPN4GYU/rRfO+cUHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684185372; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DZHhrNE+lQbMd0iIV/PZ3+/ZDJKPK1+e6kKnPQuIdO4=; b=mIWjKwOGTdaUTvRCsI5Y8rW11BO2lZGkbtLM/DOu1MtM/HOODl+KJnMyb5AEdyu4eunqr4 QNdFSjbS7c4xzpCg== To: "Liam R. Howlett" Cc: LKML , Matthew Wilcox , linux-mm@kvack.org, Shanker Donthineni Subject: Re: your mail In-Reply-To: <20230515192708.sypitem5hzycdois@revolver> References: <87mt2cxb7y.ffs@tglx> <20230515192708.sypitem5hzycdois@revolver> Date: Mon, 15 May 2023 23:16:11 +0200 Message-ID: <87wn198fdw.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Stat-Signature: kmm9iqsred79m7ti6roi7yotyubkpfui X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E1083C0008 X-Rspam-User: X-HE-Tag: 1684185373-488176 X-HE-Meta: U2FsdGVkX19CVYglu6/ewZTLDGV6nZDjNkIIYEykjDj+uUyTlMWIoSvLVpURoUQi/0WKK9AzfDxHTDcT6VnN1qrMWJQZlUNuazrmdo1IRNN4pLch5zGsVlKFLEhoz6y4FCq7fxpApwGGNRUVrqkc2SvAWywRZ3nqgALSdqtUKMaGXE/tOdCb7K02MRHT9X7Y6pwzbG4H7MtLL7LUIjjhhTNwxr26GEXqZ0BtZKuIQb895p/SVSSnaHMqARSv2fD1iLofKQJ3eleF0Gqkl85nCS7rpX9eShNpF9jFvDUQOAwUQ6yXTUSs2tO3DQYcoB85gFfrogt1yM4diSdKslAh5Xoe9SO6PAZ1MtwPVcUF/tRMsxELTkA83V7PyEXw/tQ7zxn8zRNlwoclm8F+i1SfUOoitYPABXiJu66p8yM/pX1nslizMmPUAanUUkH48S77VLFEN9Sevwz6LjLr0K86YSs73JjJJPx66g2Gx3VWOloOTOXoIPR1muw7olzQCXVze3rdcbYq8b1J9xEUJQt0ltUslK9NqDVCdvIF2mQzqUu2qi5vWRdnpZXuTiGVTWdTyciitIWQ8iwqXc31ICOrXgU9/vP8MMfKCqs8KDf4gaAldsMBwFctzA+NpkznaA0XsjJ9cIvt+kNKm+NhU3/V6RJboQ50f6wLlqW7YlNEFzuEXYFkVMyXbrOtmj6igUvf6nliFy6Rp82OKJ68Kwqez07r0U71QXL5w7CPS0d/DVwRqp3X6F1cMQkAHkAH0/E7eA9U6kipnogkIFQkCFl11ujiI/xeEQv0ZDcZC2sc5nanzFym6wyDhb58TCCZG9cyivCO6Vw0qjoD2W4u0fE8OWwBItk7Q+gCce+Ji38DsO4lCMWp+KgVjvuqSYPZ08rl53jCJ0vtpaeQr0g2czMJuiykqio9k6I58wMIAnwOpMi1gbOUsg9EBV44zaPpkWJzGGwsnahN4sWMtKEDpP3 b0zoVq6F 43DvjDRBPYxbe80YAHS29hAsZE2LpUzuXhtwYvfmiedL+pyA= 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: Liam! On Mon, May 15 2023 at 15:27, Liam R. Howlett wrote: > * Thomas Gleixner [230510 15:01]: >>Also the >> documentation of index talks about a range, while in reality the index >> is updated on a succesful search to the index of the found entry plus one. > > This is a range based tree, so the index is incremented beyond the last > entry which would return the entry. That is, if you search for 5 and > there is an entry at 4-100, the index would be 101 after the search - > or, one beyond the range. If you have single entries at a specific > index, then index would be equal to last and it would be one beyond the > index you found - but only because index == last in this case. Thanks for the explanation >> >> Fix similar issues for mt_find_after() and mt_prev(). >> >> Remove the completely confusing and pointless "Note: Will not return the >> zero entry." comment from mt_for_each() and document @__index correctly. > > The zero entry concept is an advanced API concept which allows you to > store something that cannot be seen by the mt_* family of users, so it > will not be returned and, instead, it will return NULL. Think of it as > a reservation for an entry that isn't fully initialized. Perhaps it > should read "Will not return the XA_ZERO_ENTRY" ? That makes actually sense. >> --- a/include/linux/maple_tree.h >> +++ b/include/linux/maple_tree.h >> @@ -659,10 +659,8 @@ void *mt_next(struct maple_tree *mt, uns >> * mt_for_each - Iterate over each entry starting at index until max. >> * @__tree: The Maple Tree >> * @__entry: The current entry >> - * @__index: The index to update to track the location in the tree >> + * @__index: The index to start the search from. Subsequently used as iterator. >> * @__max: The maximum limit for @index >> - * >> - * Note: Will not return the zero entry. > > This function "will not return the zero entry", meaning it will return > NULL if xa_is_zero(entry). Ack. >> + * Takes RCU read lock internally to protect the search, which does not >> + * protect the returned pointer after dropping RCU read lock. >> * >> - * Handles locking. @index will be incremented to one beyond the range. >> + * In case that an entry is found @index contains the index of the found >> + * entry plus one, so it can be used as iterator index to find the next >> + * entry. > > What about: > "In case that an entry is found @index contains the last index of the > found entry plus one" Something like that, yes. Let me try again. Thanks, tglx