From nobody Sat Feb 7 06:21:38 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8C673451DB; Wed, 29 Oct 2025 12:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761740524; cv=none; b=NkN0hd9vOtC83VBFoOVrQ9a6bAsw+pJcqgILn0xY4CVLc6O1755GrXTulXP0sD/2Dxy/cS7cQzeHkDAEHrDn+400iW93tvGAFrVVjEUQx1pvtbqJzPbBmqmb2Fhe/7DJuK6QiryM7q1hgcAf8NXzbkAGHnctHHzNgtHzp7jL4uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761740524; c=relaxed/simple; bh=96Z7otohCUrNqJl7r8gnx6tjRso9CQWk7dyZx4Mnc2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qWNvuYmKkoKZDgV9h90mA4bG1vgY/yCtc8ctl7a13Irwt+KKz7NABaY2jfeAH4COYUCIOYxHfLTarmUpKlHV5tYsxPKZ0gGKMlmE7sOMWZNG4SZG50qykjg7GVACxxPHmmG+7IGX7QnOfjZDxuHWuhdZTT2Kb4UPHy7dw1EQFn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EltZ3oTK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EltZ3oTK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E3D6C4CEFF; Wed, 29 Oct 2025 12:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761740524; bh=96Z7otohCUrNqJl7r8gnx6tjRso9CQWk7dyZx4Mnc2A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EltZ3oTK5dsrsqmcFJPqkhX1RynQ+/6+WTQ0gXHlhphXrTTXs93fEADcDz6YqrCqM usFHPwT5t/S2ADdtbErgv9rjEJy3tRPNK9q4MdoKnJQnSVQcl0tkkVPG++vHQ40J95 7OgCS/ghc3Erbfv2BXn9tEKHxIsjlq2huAVTlZ21hd2AG5Rm7BSwjTKdTcCs/GjusB FrFmKwaNTbIUC8Qb70zl27LYGlShOSVSDSZmyvZQ5h/ADXAbGVQpgquWRrls4FgQgX 2MGb56stXnTaIOcw5X65/xEO/+kGL8VsE/RGa9KfFO9PI5/XRMTA1yGQR/kBLXrBVE Fqh8+Rx0tpBCw== From: Christian Brauner Date: Wed, 29 Oct 2025 13:20:30 +0100 Subject: [PATCH v4 17/72] nstree: simplify rbtree comparison helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251029-work-namespace-nstree-listns-v4-17-2e6f823ebdc0@kernel.org> References: <20251029-work-namespace-nstree-listns-v4-0-2e6f823ebdc0@kernel.org> In-Reply-To: <20251029-work-namespace-nstree-listns-v4-0-2e6f823ebdc0@kernel.org> To: linux-fsdevel@vger.kernel.org, Josef Bacik , Jeff Layton Cc: Jann Horn , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Amir Goldstein , Tejun Heo , Johannes Weiner , Thomas Gleixner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, Arnd Bergmann , Christian Brauner X-Mailer: b4 0.15-dev-96507 X-Developer-Signature: v=1; a=openpgp-sha256; l=2145; i=brauner@kernel.org; h=from:subject:message-id; bh=96Z7otohCUrNqJl7r8gnx6tjRso9CQWk7dyZx4Mnc2A=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWQysfXs8fWZc5Dp3r2uQ+mxTun+3W/bnsQmuRVynsoLe /aG4cOijlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIksi2T4p8Om/X/FuSYdxk0n +b/LhzefO7NtmU3Dlb9XcnpzT+1zzWL477MlOGV+U97cWrP3D1J2Lr/Qve7lu/m2L4K27yxl/O1 3iQkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 They all do the same basic thing. Signed-off-by: Christian Brauner Reviewed-by: Jeff Layton --- kernel/nstree.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/kernel/nstree.c b/kernel/nstree.c index 59ec7d6ba302..1779fa314a7d 100644 --- a/kernel/nstree.c +++ b/kernel/nstree.c @@ -109,46 +109,28 @@ static inline struct ns_common *node_to_ns_owner(cons= t struct rb_node *node) return rb_entry(node, struct ns_common, ns_owner_tree_node); } =20 -static inline int ns_cmp(struct rb_node *a, const struct rb_node *b) +static int ns_id_cmp(u64 id_a, u64 id_b) { - struct ns_common *ns_a =3D node_to_ns(a); - struct ns_common *ns_b =3D node_to_ns(b); - u64 ns_id_a =3D ns_a->ns_id; - u64 ns_id_b =3D ns_b->ns_id; - - if (ns_id_a < ns_id_b) + if (id_a < id_b) return -1; - if (ns_id_a > ns_id_b) + if (id_a > id_b) return 1; return 0; } =20 -static inline int ns_cmp_unified(struct rb_node *a, const struct rb_node *= b) +static int ns_cmp(struct rb_node *a, const struct rb_node *b) { - struct ns_common *ns_a =3D node_to_ns_unified(a); - struct ns_common *ns_b =3D node_to_ns_unified(b); - u64 ns_id_a =3D ns_a->ns_id; - u64 ns_id_b =3D ns_b->ns_id; - - if (ns_id_a < ns_id_b) - return -1; - if (ns_id_a > ns_id_b) - return 1; - return 0; + return ns_id_cmp(node_to_ns(a)->ns_id, node_to_ns(b)->ns_id); } =20 -static inline int ns_cmp_owner(struct rb_node *a, const struct rb_node *b) +static int ns_cmp_unified(struct rb_node *a, const struct rb_node *b) { - struct ns_common *ns_a =3D node_to_ns_owner(a); - struct ns_common *ns_b =3D node_to_ns_owner(b); - u64 ns_id_a =3D ns_a->ns_id; - u64 ns_id_b =3D ns_b->ns_id; + return ns_id_cmp(node_to_ns_unified(a)->ns_id, node_to_ns_unified(b)->ns_= id); +} =20 - if (ns_id_a < ns_id_b) - return -1; - if (ns_id_a > ns_id_b) - return 1; - return 0; +static int ns_cmp_owner(struct rb_node *a, const struct rb_node *b) +{ + return ns_id_cmp(node_to_ns_owner(a)->ns_id, node_to_ns_owner(b)->ns_id); } =20 void __ns_tree_add_raw(struct ns_common *ns, struct ns_tree *ns_tree) --=20 2.47.3