From nobody Mon Feb 9 04:31:32 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E79C001B0 for ; Thu, 10 Aug 2023 07:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233792AbjHJHLM (ORCPT ); Thu, 10 Aug 2023 03:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233721AbjHJHK7 (ORCPT ); Thu, 10 Aug 2023 03:10:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A5CF3; Thu, 10 Aug 2023 00:10:59 -0700 (PDT) Date: Thu, 10 Aug 2023 07:10:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691651458; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D4ibZomJJGs831EnKckgDLHRDE5xgjYSDrjS2GgTZOc=; b=ChK2bCCyrflE1GGL07pj+xPHQwKAdeoMQ0NCY87FuucsZ5ckuU6BaO4fiuVCPq/beL9KB7 PdgfWpKbcInD+Fikqd5tGXT754E9bAz88lFMt1c0oWXPaH/NA4mB3Rn4YJJAM5cDXDzRPm a4xajPmGkgXDKTDyzv+pxe1MRDAlJGosN45B4eh61o0eKPr/HC/IjtVeEAuvDlnGFSnLx8 gFoD5FH/zkCWoEzeh4HvpSTbUt39BR08dSYduzLRCtaSCbPI2XDvZylanKcDoIyfR0Dlsg D2OrzS/00aIQ0s1wu8qcgE3D+e6sM9zuk6HScBP08RGJMJfzbbtyqe3aEcBRqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691651458; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D4ibZomJJGs831EnKckgDLHRDE5xgjYSDrjS2GgTZOc=; b=nNATIig822xMthvlsQoWHtly4LNjI7jrDb5ueX9P7Vru4vXxfcoY0XVipph4Hi0r2cYP3A D0dlwNJ9hIRpWbAw== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] rbtree: Add rb_add_augmented_cached() helper Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230531124603.862983648@infradead.org> References: <20230531124603.862983648@infradead.org> MIME-Version: 1.0 Message-ID: <169165145631.27769.14339276495833528763.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 99d4d26551b56f4e523dd04e4970b94aa796a64e Gitweb: https://git.kernel.org/tip/99d4d26551b56f4e523dd04e4970b94aa= 796a64e Author: Peter Zijlstra AuthorDate: Wed, 31 May 2023 13:58:43 +02:00 Committer: Ingo Molnar CommitterDate: Wed, 19 Jul 2023 09:43:58 +02:00 rbtree: Add rb_add_augmented_cached() helper While slightly sub-optimal, updating the augmented data while going down the tree during lookup would be faster -- alas the augment interface does not currently allow for that, provide a generic helper to add a node to an augmented cached tree. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20230531124603.862983648@infradead.org --- include/linux/rbtree_augmented.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmen= ted.h index 7ee7ed5..6dbc5a1 100644 --- a/include/linux/rbtree_augmented.h +++ b/include/linux/rbtree_augmented.h @@ -60,6 +60,32 @@ rb_insert_augmented_cached(struct rb_node *node, rb_insert_augmented(node, &root->rb_root, augment); } =20 +static __always_inline struct rb_node * +rb_add_augmented_cached(struct rb_node *node, struct rb_root_cached *tree, + bool (*less)(struct rb_node *, const struct rb_node *), + const struct rb_augment_callbacks *augment) +{ + struct rb_node **link =3D &tree->rb_root.rb_node; + struct rb_node *parent =3D NULL; + bool leftmost =3D true; + + while (*link) { + parent =3D *link; + if (less(node, parent)) { + link =3D &parent->rb_left; + } else { + link =3D &parent->rb_right; + leftmost =3D false; + } + } + + rb_link_node(node, parent, link); + augment->propagate(parent, NULL); /* suboptimal */ + rb_insert_augmented_cached(node, tree, leftmost, augment); + + return leftmost ? node : NULL; +} + /* * Template for declaring augmented rbtree callbacks (generic case) *