From nobody Thu Aug 01 22:27:45 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WZk9v3Zfgz5RZXY; Thu, 01 Aug 2024 22:27:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZk9t04LPz4Z2K; Thu, 1 Aug 2024 22:27:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LTJMSjb67SpNYdHjl2LlDDEdGlg6QIB5ktDZQBHnpvU=; b=DoLSszOZyhSzv/6cVzVf8bOZ/wlbnIqKhbECcp+b9YJrCQ2n3peLqHXeezMMnw5DJ0i2aX 4Iu7WtYP+t5G9TQo0oPr5ujZgxvk384/IRPAer9aCw/nrZXfQNo0sOb9mkkYTstxkjUbqW basBuDDXTH5Enr5a0vu3rgimEM1gIbswZZvShpKXZzYeUDNvtQmo0Yud9y1Hr0Qibmi+NU GEp6YywLaYdZnKjsuOw+f+BxzTcdDUWnPIhpGUjllj3D1WnEbehe879WiajD61/SIL8ArA nDuhSSNekak7Y9kR/ivlrtIGduLt0OhNyN/4endMLge/Y20Txkj3VsikqHCxnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551266; a=rsa-sha256; cv=none; b=RgiMzjp8iVA+Arnhe/m0lTN+1UntBwOQrynK91rF5KTMkaTQqnOaAeL8UEGVg/lhGTMRiH sm62bzFtQB5pxUzG5U0JnyYgJ/5uzdtbZ0trp+h/84Zdx2YciHIXaoSeh6GUoC7vP7wK3D JrPAH8XKDqgiW/GywuOGsw3FnjU0yFf5jA/nM4bZETx5XgayVgkt5yOuwqN0vui8T13o/3 2Q926SE4NVF2+Hs794xv905ykF/AbWWBL4LTGH8WfFovr+9gdp67ZMe1+Mx0DpLEkbqKe7 tE66nBKUR2SaKLmUqOW3r/oGWbn53yn5BN+/jF03vP8OmPk7azswdC/pDoksdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LTJMSjb67SpNYdHjl2LlDDEdGlg6QIB5ktDZQBHnpvU=; b=bjveuxwRW/S7ICbMfHmnlbNFqVMrlQ8kQ0AzdNaoaPZ1H32kLzpRtAQR/mfcRWuws0AAOm iNkNHycZ27y+pLNEwKfyDv7u08o8BNf3/FfhHa5szQDo4Jwr1xusFQScrQhP02S8xy45RT Q4Ampr+MWaivuQ7jJaIyK8kFefdY5rcw6gYrTuVqJIE7NgN84mTm2eC0TGmABYb51LsNCx 6IEgPbhSxQGTv+WUVqWAMmEwy4T1XyQvkMs2SYdc1otUgfbnx7hUNShY0PfL8hknMUTian /PfBgg+8iT+vHs4ESw1EgWZ2P1LyR8Ln6AkQXC1XNJjPGXRyT7EsLLjggLOe1Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WZk9s6nTVz12hs; Thu, 1 Aug 2024 22:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471MRjTE027880; Thu, 1 Aug 2024 22:27:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MRjCc027877; Thu, 1 Aug 2024 22:27:45 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:27:45 GMT Message-Id: <202408012227.471MRjCc027877@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 4f0f1f1a6e2a - stable/14 - LinuxKPI: Add rb_add_cached function List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4f0f1f1a6e2aabd265cc6e25fd14c846da1bb8b8 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=4f0f1f1a6e2aabd265cc6e25fd14c846da1bb8b8 commit 4f0f1f1a6e2aabd265cc6e25fd14c846da1bb8b8 Author: Vladimir Kondratyev AuthorDate: 2024-06-26 20:43:16 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:09:40 +0000 LinuxKPI: Add rb_add_cached function rb_add_cached inserts node into the leftmost cached tree Sponsored by: Serenity CyberSecurity, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45608 (cherry picked from commit a5cac2e672a7d94c0391076e7452d6a487f7b5c1) --- sys/compat/linuxkpi/common/include/linux/rbtree.h | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/rbtree.h b/sys/compat/linuxkpi/common/include/linux/rbtree.h index 78bf938eb000..e6033cfd760d 100644 --- a/sys/compat/linuxkpi/common/include/linux/rbtree.h +++ b/sys/compat/linuxkpi/common/include/linux/rbtree.h @@ -175,6 +175,30 @@ rb_replace_node_cached(struct rb_node *old, struct rb_node *new, root->rb_leftmost = new; } +static inline struct rb_node * +rb_add_cached(struct rb_node *node, struct rb_root_cached *tree, + bool (*less)(struct rb_node *, const struct rb_node *)) +{ + struct rb_node **link = &tree->rb_root.rb_node; + struct rb_node *parent = NULL; + bool leftmost = true; + + while (*link != NULL) { + parent = *link; + if (less(node, parent)) { + link = &RB_LEFT(parent, __entry); + } else { + link = &RB_RIGHT(parent, __entry); + leftmost = false; + } + } + + rb_link_node(node, parent, link); + rb_insert_color_cached(node, tree, leftmost); + + return (leftmost ? node : NULL); +} + #undef RB_ROOT #define RB_ROOT (struct rb_root) { NULL } #define RB_ROOT_CACHED (struct rb_root_cached) { RB_ROOT, NULL }