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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87257C4338F for ; Wed, 25 Aug 2021 11:39:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA4561183 for ; Wed, 25 Aug 2021 11:39:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239414AbhHYLkZ (ORCPT ); Wed, 25 Aug 2021 07:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbhHYLkX (ORCPT ); Wed, 25 Aug 2021 07:40:23 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54B4FC061757 for ; Wed, 25 Aug 2021 04:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bc1KbfnaTqDrF8y48kYjRemdc6677tvooRZyXgt+vD0=; b=re2VTTA9IZibuCbSCWgnTiZmYp PfzcoldWjFgZGHHZ+DK9xpOpb3zk79sBN8ewrSVj7qD7dHyXfAn2lkcYr3tmA24oEy7fdCspH53Nq zk/OJhFyeUgsQNX8XwxxPw5FTIZ/9b3ZqlUKivYa7+1CUb5jF10CM0nfOJU+tf1Zcq4p63DVTBDvS sy+WSEuVDJqbFvopnxJeubL37UlgqqJJ9+azXOpQP9KzkmIBYqTXNXljF2mo2stu+dCLuJfJDryKE UbDxl5MB/RjvEeukKeRsAqH/ivYRic6ZYKlX+WItLRfyy/vNjzxyce67+Qa7qnf3DDnzypXjxRuLc ifKSC+oQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIrFg-00CtXY-Lh; Wed, 25 Aug 2021 11:39:28 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D72A63005AD; Wed, 25 Aug 2021 13:39:26 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C40562D862728; Wed, 25 Aug 2021 13:39:26 +0200 (CEST) Date: Wed, 25 Aug 2021 13:39:26 +0200 From: Peter Zijlstra To: Li RongQing Cc: dbueso@suse.de, mingo@kernel.org, michel@lespinasse.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rbtree: stop iteration early in rb_find_first Message-ID: References: <1629885588-10590-1-git-send-email-lirongqing@baidu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1629885588-10590-1-git-send-email-lirongqing@baidu.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 25, 2021 at 05:59:48PM +0800, Li RongQing wrote: > stop iteration if match is not NULL and result of cmp is > not zero, this means the matched node has been found, and > the node with same key has been passed > > Signed-off-by: Li RongQing > --- > include/linux/rbtree.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h > index d31ecaf4fdd3..2689771df9bb 100644 > --- a/include/linux/rbtree.h > +++ b/include/linux/rbtree.h > @@ -324,6 +324,9 @@ rb_find_first(const void *key, const struct rb_root *tree, > } else if (c > 0) { > node = node->rb_right; > } > + > + if (match && c) > + break; > } > > return match; Acked-by: Peter Zijlstra (Intel)