From nobody Mon Feb 9 01:15:39 2026 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE3F726E16E for ; Fri, 14 Nov 2025 14:06:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763129212; cv=none; b=ca9qGsm8JnMXObZdaT85hOBzU0f/3HifyfmSyisBO3pt/nCLMy20d6FTdtQjzw8TVF5d3DG9JYozQdu9pdMzT+3t2XsprPQlJr6P42DIK6MzfwU/MMn0vkVWjGqKPtZwODrOz6MUFv+TmD3M6wbf58sdE8YUPes80U0MBsmU4Ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763129212; c=relaxed/simple; bh=oNQL9iYvNRTZVBqXboiLPRAwsvpu0u63F6sdYKZYY7U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jblIDvey9aStaOo7SjJSGhil9bwe8X6nSkjJ8lnmEbfP9hyF5TaQlPcIxNpFSHjFDctLF8/Mgrr0ByVheFPHhdgIBIisx8eEq2/z6PutnRH5IN5F94MoQOPe47TOV2OLojt7zZ3x4mEwrneyP5987lkU03xKB80F2qE0FAMwiEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Iv12OwbB; arc=none smtp.client-ip=209.85.222.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Iv12OwbB" Received: by mail-qk1-f201.google.com with SMTP id af79cd13be357-8b244ef3ed4so614935485a.0 for ; Fri, 14 Nov 2025 06:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763129210; x=1763734010; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=p199NXv4y1rAS/mf/rNg1mVOWhh1nlFD9giH3bYyspE=; b=Iv12OwbBTLvxOIbmtCIM1V8J/69D9QpLItfO9r5F3AJd+MO5Fws1bBjszWNXh5Pzkj cvEQx++jCosZou6UlLN3wolMgn47y1Z4YWxnwBxPrgjcuFTSeU+mxORfcjHvWmYdncbE c8iGBveSNNneQWHwMmaRZzj0uK4Yb7ndhn4QpEMFYy4z/+INZ0jK9t5+hi0RsYBUZTG8 XiqsuwBbXq/dES+oJ0gBB4P3BFFuzrZ3g63BnV8vLau5v7RMS0Iqe4c7J8Qr3Zds7m3t zH28nLJnokFAhd91+QQKrJni32syJT3uP7somMXyQ0A8WrBkAh+jixWa/uMQaTm2XlQX IMaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763129210; x=1763734010; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p199NXv4y1rAS/mf/rNg1mVOWhh1nlFD9giH3bYyspE=; b=JLJuxmOmNvq1MquNMtvtxjea3v8ox9Lf4n/TmLALt99t6hs0acEH3oJneCDo79oxSe Zc+xhKYyKzU6NSufwWNBoCF0Ov/cy+OoMd7M5urbbjI2m4qbqca7dqNXcLa9Poq18dUr 5pdLdKKVh8S6NpJG1AndbQRtzx6VW5pePrpsTZMy2hHxk0wMEnsXONkksQgimaxN27LA QWkEDqcPF45Q2Np0DJVlKlmD12+3L7tiSqLGqLpEey2wNkePd/0Nmm0DZPWO5EAgdObL zN6tE3/lZUs3GyQPriSyUihczGqC6WJp8RLtZqpd4wcP/n0oGaKp5mx3bpmrhrk0OvVQ hOwA== X-Gm-Message-State: AOJu0Yw3PoW6If3aea/hCjX8Hia+2Qtn18JreAG42k4/BXAW/MPswXGW Z3H/rfApXFfBX8ae0BnQY3X702+QAU/BTa6LzBsQ26gleJijMVS/j7EFsOqykAU9oNHaCvzFtuI 3W/Gzo0wgsxcXYA== X-Google-Smtp-Source: AGHT+IFnKwSlCOoJNm5BxGPhmRz/amuoNvsx4cXYb+6Q6QrBidCBXIIeFW3Sr/GWP3mQXZfKTbeDmXlGgmRWpQ== X-Received: from qkpi5.prod.google.com ([2002:a05:620a:27c5:b0:8a2:d4df:9888]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:1911:b0:8a4:107a:6772 with SMTP id af79cd13be357-8b2c31dd43amr401388485a.76.1763129209801; Fri, 14 Nov 2025 06:06:49 -0800 (PST) Date: Fri, 14 Nov 2025 14:06:45 +0000 In-Reply-To: <20251114140646.3817319-1-edumazet@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251114140646.3817319-1-edumazet@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251114140646.3817319-2-edumazet@google.com> Subject: [PATCH 1/2] rbtree: inline rb_first() From: Eric Dumazet To: Andrew Morton , Jakub Kicinski , Paolo Abeni Cc: linux-kernel , netdev@vger.kernel.org, Neal Cardwell , Kuniyuki Iwashima , Eric Dumazet , Eric Dumazet Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is a very small function, inlining it save cpu cycles by reducing register pressure and removing call/ret overhead. It also reduces vmlinux text size by 744 bytes on a typical x86_64 build. Before: size vmlinux text data bss dec hex filename 34812525 22177365 5685248 62675138 3bc58c2 vmlinux After: size vmlinux text data bss dec hex filename 34811781 22177365 5685248 62674394 3bc55da vmlinux Signed-off-by: Eric Dumazet --- include/linux/rbtree.h | 16 +++++++++++++++- lib/rbtree.c | 16 ---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h index 8d2ba3749866f500a492d267e5e13556f6aa3f55..484554900f7d3201d41fb29e04f= b65fe331eee79 100644 --- a/include/linux/rbtree.h +++ b/include/linux/rbtree.h @@ -43,7 +43,21 @@ extern void rb_erase(struct rb_node *, struct rb_root *); /* Find logical next and previous nodes in a tree */ extern struct rb_node *rb_next(const struct rb_node *); extern struct rb_node *rb_prev(const struct rb_node *); -extern struct rb_node *rb_first(const struct rb_root *); + +/* + * This function returns the first node (in sort order) of the tree. + */ +static inline struct rb_node *rb_first(const struct rb_root *root) +{ + struct rb_node *n; + + n =3D root->rb_node; + if (!n) + return NULL; + while (n->rb_left) + n =3D n->rb_left; + return n; +} extern struct rb_node *rb_last(const struct rb_root *); =20 /* Postorder iteration - always visit the parent after its children */ diff --git a/lib/rbtree.c b/lib/rbtree.c index 5114eda6309c9d867a3e1ed9358bf9b3b275eb71..b946eb4b759d3b65f5bc5d54d03= 77348962bdc56 100644 --- a/lib/rbtree.c +++ b/lib/rbtree.c @@ -460,22 +460,6 @@ void __rb_insert_augmented(struct rb_node *node, struc= t rb_root *root, } EXPORT_SYMBOL(__rb_insert_augmented); =20 -/* - * This function returns the first node (in sort order) of the tree. - */ -struct rb_node *rb_first(const struct rb_root *root) -{ - struct rb_node *n; - - n =3D root->rb_node; - if (!n) - return NULL; - while (n->rb_left) - n =3D n->rb_left; - return n; -} -EXPORT_SYMBOL(rb_first); - struct rb_node *rb_last(const struct rb_root *root) { struct rb_node *n; --=20 2.52.0.rc1.455.g30608eb744-goog