From nobody Thu Dec 15 10:27:20 2022 X-Original-To: dev-commits-src-branches@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 4NXpMT2n1yz4jm2v; Thu, 15 Dec 2022 10:27:33 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mx.blih.net (mx.blih.net [212.83.155.74]) (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 (2048 bits) client-digest SHA256) (Client CN "mx.blih.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NXpMR5NpHz4Gpd; Thu, 15 Dec 2022 10:27:31 +0000 (UTC) (envelope-from manu@bidouilliste.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bidouilliste.com header.s=mx header.b="VAkXQk/H"; spf=pass (mx1.freebsd.org: domain of manu@bidouilliste.com designates 212.83.155.74 as permitted sender) smtp.mailfrom=manu@bidouilliste.com; dmarc=pass (policy=none) header.from=bidouilliste.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bidouilliste.com; s=mx; t=1671100043; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x/MiJyWqp7JjNhU8NhFyeoWxPJybxi9HgdA/WlIXni0=; b=VAkXQk/HO3mPKZaaWdv+uov0EmgKuOoC388fbOIScQDFG58afufK+C0ZvZvDM8e6Yw1X/r uxsB3KBN0EPvDDfr98j8kgOP8NE8LJD7GiFa+9hoMd4ouBQ1m++781ZtZA4mxdxYPqBj0L msnnpGEqaa5XPr8NBJa/zswnJ2srKhk= Received: from skull.home.blih.net (lfbn-lyo-1-2174-135.w90-66.abo.wanadoo.fr [90.66.97.135]) by mx.blih.net (OpenSMTPD) with ESMTPSA id 9de36126 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 15 Dec 2022 10:27:23 +0000 (UTC) Date: Thu, 15 Dec 2022 11:27:20 +0100 From: Emmanuel Vadot To: Doug Moore Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: Re: git: deeaf9c4d85d - stable/13 - rb_tree: pass parent to RB_INSERT_COLOR Message-Id: <20221215112720.73b0bb9770df3c3fd9c67485@bidouilliste.com> In-Reply-To: <202210120300.29C30NVa079471@gitrepo.freebsd.org> References: <202210120300.29C30NVa079471@gitrepo.freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.0) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-3.50 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.996]; DMARC_POLICY_ALLOW(-0.50)[bidouilliste.com,none]; MV_CASE(0.50)[]; R_DKIM_ALLOW(-0.20)[bidouilliste.com:s=mx]; R_SPF_ALLOW(-0.20)[+ip4:212.83.155.74/32]; MIME_GOOD(-0.10)[text/plain]; ASN(0.00)[asn:12876, ipnet:212.83.128.0/19, country:FR]; MIME_TRACE(0.00)[0:+]; MLMMJ_DEST(0.00)[dev-commits-src-branches@FreeBSD.org,dev-commits-src-all@FreeBSD.org]; DKIM_TRACE(0.00)[bidouilliste.com:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FREEFALL_USER(0.00)[manu]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 4NXpMR5NpHz4Gpd X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N Hello Doug, On Wed, 12 Oct 2022 03:00:23 GMT Doug Moore wrote: > The branch stable/13 has been updated by dougm: > > URL: https://cgit.FreeBSD.org/src/commit/?id=deeaf9c4d85d937d3c935291e913ae614a28f824 > > commit deeaf9c4d85d937d3c935291e913ae614a28f824 > Author: Doug Moore > AuthorDate: 2022-09-13 06:11:47 +0000 > Commit: Doug Moore > CommitDate: 2022-10-12 02:42:55 +0000 > > rb_tree: pass parent to RB_INSERT_COLOR > > Change RB_COLOR_INSERT to take a parent parameter, to avoid looking up > a value already available. Make adjustments to a linux rbtree header, > which invokes it. > > Reviewed by: alc, hselasky > Differential Revision: https://reviews.freebsd.org/D36114 > > (cherry picked from commit 4893472c9a18cd8ce3b68d0c54084ef6f0285d0f) > --- > sys/compat/linuxkpi/common/include/linux/rbtree.h | 11 ++++++++--- > sys/sys/tree.h | 18 ++++++++++-------- > 2 files changed, 18 insertions(+), 11 deletions(-) > > diff --git a/sys/compat/linuxkpi/common/include/linux/rbtree.h b/sys/compat/linuxkpi/common/include/linux/rbtree.h > index 1f337d59545c..37537d4b2724 100644 > --- a/sys/compat/linuxkpi/common/include/linux/rbtree.h > +++ b/sys/compat/linuxkpi/common/include/linux/rbtree.h > @@ -74,8 +74,11 @@ RB_PROTOTYPE(linux_root, rb_node, __entry, panic_cmp); > #define RB_EMPTY_NODE(node) (RB_PARENT(node, __entry) == node) > #define RB_CLEAR_NODE(node) RB_SET_PARENT(node, node, __entry) > > -#define rb_insert_color(node, root) \ > - linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node)) > +#define rb_insert_color(node, root) do { \ > + if (rb_parent(node)) \ > + linux_root_RB_INSERT_COLOR((struct linux_root *)(root), \ > + rb_parent(node), (node)); \ > +} while (0) > #define rb_erase(node, root) \ > linux_root_RB_REMOVE((struct linux_root *)(root), (node)) > #define rb_next(node) RB_NEXT(linux_root, NULL, (node)) > @@ -145,7 +148,9 @@ static inline void > rb_insert_color_cached(struct rb_node *node, struct rb_root_cached *root, > bool leftmost) > { > - linux_root_RB_INSERT_COLOR((struct linux_root *)&root->rb_root, node); > + if (rb_parent(node)) > + linux_root_RB_INSERT_COLOR((struct linux_root *)&root->rb_root, > + rb_parent(node), node); > if (leftmost) > root->rb_leftmost = node; > } > diff --git a/sys/sys/tree.h b/sys/sys/tree.h > index 6a64498f6deb..c0cd65f41acb 100644 > --- a/sys/sys/tree.h > +++ b/sys/sys/tree.h > @@ -422,7 +422,8 @@ struct { \ > #define RB_PROTOTYPE_RANK(name, type, attr) > #endif > #define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \ > - attr void name##_RB_INSERT_COLOR(struct name *, struct type *) > + attr void name##_RB_INSERT_COLOR(struct name *, \ > + struct type *, struct type *) > #define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \ > attr void name##_RB_REMOVE_COLOR(struct name *, \ > struct type *, struct type *) > @@ -491,7 +492,8 @@ name##_RB_RANK(struct type *elm) \ > > #define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ > attr void \ > -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ > +name##_RB_INSERT_COLOR(struct name *head, \ > + struct type *parent, struct type *elm) \ > { \ > /* \ > * Initially, elm is a leaf. Either its parent was previously \ > @@ -503,12 +505,11 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ > * uninitialized 'child', and a later iteration can only happen \ > * when a value has been assigned to 'child' in the previous \ > * one. \ > - */ \ > - struct type *child, *child_up, *gpar, *parent; \ > + */ \ > + struct type *child, *child_up, *gpar; \ > __uintptr_t elmdir, sibdir; \ > \ > - gpar = _RB_UP(elm, field); \ > - while ((parent = gpar) != NULL) { \ > + do { \ > /* the rank of the tree rooted at elm grew */ \ > gpar = _RB_UP(parent, field); \ > elmdir = RB_RIGHT(parent, field) == elm ? _RB_R : _RB_L; \ > @@ -584,7 +585,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ > RB_AUGMENT(elm); \ > RB_AUGMENT(parent); \ > break; \ > - } \ > + } while ((parent = gpar) != NULL); \ > } > > #ifndef RB_STRICT_HST > @@ -774,7 +775,8 @@ name##_RB_INSERT(struct name *head, struct type *elm) \ > } \ > RB_SET(elm, parent, field); \ > *tmpp = elm; \ > - name##_RB_INSERT_COLOR(head, elm); \ > + if (parent != NULL) \ > + name##_RB_INSERT_COLOR(head, parent, elm); \ > RB_UPDATE_AUGMENT(elm, field); \ > return (NULL); \ > } This breaks drm-kmod for stable/13 So it means that drm-kmod compiled for 13.1 will not work (either won't load or more likely freeze the machine) on stable/13 and more importantly 13.2 We've succefully succeeded in keeping compatibility between 13.0 and 13.1 for drm-kmod and I'd really like that it also works on 13.2 Cheers, -- Emmanuel Vadot