Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1346040rwd; Tue, 16 May 2023 16:04:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BKAEg/eoBaYr+kr45SXk0qfOi3opq3J4jzK/aGRhNg7LVR0j6y4Q0GdWRX+W1hOb/8qXe X-Received: by 2002:a17:903:124f:b0:1ac:451d:34a with SMTP id u15-20020a170903124f00b001ac451d034amr51210699plh.33.1684278244569; Tue, 16 May 2023 16:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684278244; cv=none; d=google.com; s=arc-20160816; b=v+l6wG2Pd5nIOTMA2FXMh9a6cQO68Nr2sjAJu2soUbxuyWF2SGLmd87e6wIfUSNoSB zYEX/YyX/MpADb9QhBnmXGp+Tidf85uHctbx/JzQZLGe4ijFdj9NxN21E1/IuTKyJUeZ woKuVDiOxR1OdMOtu3qiXdeHxgQxzVVbchMCORvI5yjIn1c2kwCscbSPIqENi74zPYrV EPsmO343BMrvHf6Kb9YztwRYMh1hqMxQdPl6TEKdzMpmW+LNdS/LwH6SqLHLyKRRfkMo 7P3HBw/vwvgTnXwa2n5TPS0XUQY1n+F26jyWpjT/lquTp6Dj4DxWEkgKztg6WIHnD2sS PGIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=BtkrSYxnuRq6fiYCIde637D8KY4d2NVOuzHNW7z0qFg=; b=IfWVuCqKvdayxlNlxb7Ey6GZxqsOyqvbgFd04RQN0FLl3hj/cSGS22FhVw8432C+uk 4F9UaLhJiLSnXmMoeLqMJD5TYWF4lwyGmWwvbpbgMRmPnOJZL3ZH7TmR2gb/OqZLHXY1 yqSX8zya+QbKs47v4h0CJ1hj4tvsPxRjfN1dZ0EdO8Ypi4hm9fjkePN8p/H044gCqXv9 UsxsvGHRKETGq9SYqhVfPuhe82Fm7vcw/g0bk7SbWAl0L6uOyXIbkoCj5/fcHTd2P4q2 lnA8JI/Hzc1yfFfxdRI+8+bqyHsKPe8jeIbZ0KJ8gTtrny0JFOaEQY/UrFjmf7qMibhh PNZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YFYIkcto; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nsnm3oFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg9-20020a1709028e8900b0019f3064da41si6975420plb.383.2023.05.16.16.03.47; Tue, 16 May 2023 16:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YFYIkcto; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nsnm3oFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbjEPWr7 (ORCPT + 99 others); Tue, 16 May 2023 18:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjEPWr5 (ORCPT ); Tue, 16 May 2023 18:47:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9976619B for ; Tue, 16 May 2023 15:47:56 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684277274; 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=BtkrSYxnuRq6fiYCIde637D8KY4d2NVOuzHNW7z0qFg=; b=YFYIkcto9cPds9qu96Ubj5+T/w+4IEqS9GqLheJM3JbElVLAh7rNwB/NGbGMN0uqwjNMV3 gmJuyQ5pdbswYubgo332tN7gA8Qf6e4WGIIh0OskJ4P+egADvoNKvWfFwIfPI3JrGxyZOV fmUdF5DEBgGHrVV/x/VhpZR65p0eTNElsIe9unk7WFqMC8RyQ09kaV41A/ZJBGaSeS2Z0M KA83fx7LJl7ryiDa6h67QclG2E0YY/sdJZZ9c2kRwTN6XhbCpmMEzlJ82FcThDuGva2jnc U91IH+Qjc2Ia7VIWBqUUjrXVj9TdPf1R1cXCKLTueYnwWy4sEN3+IvzgGxC6Nw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684277274; 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=BtkrSYxnuRq6fiYCIde637D8KY4d2NVOuzHNW7z0qFg=; b=nsnm3oFCOawHhI4D325r12isohSzO7y7xFjeebthE/ujyb8RB6nsbKoGoDRm/ZyDN73O3t Ot00+4+38JbvFVDQ== 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: Wed, 17 May 2023 00:47:53 +0200 Message-ID: <875y8r7v1i.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 15 2023 at 15:27, Liam R. Howlett wrote: > * Thomas Gleixner [230510 15:01]: >> The documentation of mt_next() claims that it starts the search at the >> provided index. That's incorrect as it starts the search after the provided >> index. >> >> The documentation of mt_find() is slightly confusing. "Handles locking" is >> not really helpful as it does not explain how the "locking" works. > > More locking notes can be found in Documentation/core-api/maple_tree.rst > which lists mt_find() under the "Takes RCU read lock" list. I'm okay > with duplicating the comment of taking the RCU read lock in here. Without a reference to the actual locking documentation such comments are not super helpful. >> 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" ? >> >> - * >> - * 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). If I understand correctly, this translates to: This iterator skips entries, which have been reserved for future use but have not yet been fully initialized. Right? >> @@ -6487,9 +6493,14 @@ EXPORT_SYMBOL(mtree_destroy); >> * mt_find() - Search from the start up until an entry is found. >> * @mt: The maple tree >> * @index: Pointer which contains the start location of the search >> - * @max: The maximum value to check >> + * @max: The maximum value of the search range >> + * >> + * 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" Still confusing to the casual reader like me :) "In case that an entry is found @index is updated to point to the next possible entry independent whether the found entry is occupying a single index or a range if indices." Hmm? Thanks, tglx