From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 8DD0E2ECE9E for ; Thu, 18 Dec 2025 22:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766096520; cv=none; b=PwoFCx+NbyyYiYOLsDzXmbJE0+6T0CNtkybmIB2Q2yej1E+OOBvj+GqOJAzD5ynFkSx6iifph4T9ehGiEXmxB5cdMBQg7dUO6QzqwW3RDIxBffU5BX0vUvr/pIbnMJZU05gc2bj37mpAGGWD/o8thOWQHvSI2OiYbPv6cjbU/tk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766096520; c=relaxed/simple; bh=/Ezioviutypmg+WMqOfqJaTRCXcEhsJJkVA/oyK3hMU=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=ZxYezRa7Ss7d1VLFyCh68UWXSV0/nLstDDa38wha8CgjqM6XpiABf2/LpHyNMyCq3zrcr3e0tOcAyj/X/HO5n2cmVgKGVTLTFa900CWj1b27VTtIG677LqgKgi0qmP1TVzGW3jm7DGhq+G03TlRIYV1UcT3rg1Tk6pWSauCC5tU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jq0XViQ7; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jq0XViQ7" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-bc29d64b39dso626217a12.3 for ; Thu, 18 Dec 2025 14:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766096507; x=1766701307; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=Efc046qbNC3P9us3ogii6ibq5RZYvqCH9sCzxOMoveI=; b=jq0XViQ7bhBJfZtImuOEDQ33uGc8khxDNv31OEEHPuBK0jPTVCRPktt/Ms93WLnwZD FduUdigEhafPmJZmzsXkHpTYXiAb0WntbCSTjXENuo2eVaQrzDEcv1hP0kDAs7P2sv1l KTmj7quWT/YobBzC29c8IzPFST3O+hYA7SbdP3kYLDH4QeAkSW6mDSCUTKWz40JN4hTf E9twQj2LL3lKk73Qj1M5Foi4yyvTPs79/21+O/KQkRIbtaW3k98pGjqMRugDyiKCDVDZ Ydz9l4TC9UEFrKpKqaCzce8lIa1Cm0K5+NdXeyUZyj7U496spcIw9XWn2XVF84ccbDhD 0ODQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766096507; x=1766701307; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Efc046qbNC3P9us3ogii6ibq5RZYvqCH9sCzxOMoveI=; b=Y42RI3rAzKqDHdsZZV5+nuQvlzr49kPcQUNqGetLNUjJD/tIZONP7qzgB7fZTMTPFu qgc8vnhLYC7kot2ENKIF1VRJ47bB86e1hiNbc81o0evr/dy3csTv77zmfcu2QXA/ShIA 3sH61imzdYjeQ96Z0ED2D7MMqJ/rcIr/odbZ19YD6oPDCqt62JxUC0IKb+HMBr4l4g1D BfMAgjCr8YPH+DtwEkhKcj9YZn4UFszT1C/Kr0YSMl4bWff7CknF/MGlrEWWjJ3cQzvR yIax4t4IgJJwO1qOrGsG4vB+ZMi3DpjVsAC3flyWnw12gtuROgox0z1GOKAvXnGsaQwf hgNQ== X-Forwarded-Encrypted: i=1; AJvYcCUQDS3kUtrwP2mxcm/zZyOkM6XWowp3q8xa+7UtW+ST2cZ4D93tAxRFWgfH1flz39vYNXgUf+1WEN5SxMg=@vger.kernel.org X-Gm-Message-State: AOJu0YxUOwZqpG12br1FrTI8BIGFRR5JfsNOaGWFP+UsaelTHFsa3B9v SSFtjcgUoC/XtOgUkcLp/LRNU3aZnoX/POY5MuyBVz0AQxNmLoaHmAVD X-Gm-Gg: AY/fxX7cTfjkiDX7vHT9Y4iA6/Hew5Wxjz/N/4aHOHghGVr5yHO/PdWzk99L3RrWBh1 SIe7QdXfq0jh2HnH8GFtHWElxJ9XPJxvAtcsN1/umAgwd8Z9AFTBwYSwc/qQIHbWSIlYNmI12hY d9xipbJC2c3s09D9HtrCiORRC4RKxkAZYIcymWXKkchqjRL1MYeKbDf/a+udIjMsUI/yXl5J9nG ++IVnkakmoxfxVSAztbFtftb3MKEzeTT9Y2wm5yJQ6P+8+g8bFZPxi837ageVKn/gMU8tnrIeNb A+sCxfNIj05rzQOnZFzZsgmBfoz27zp7tX+T8n8OpxBmG/DxWhdaA5MqwkuXUFmHydobotSuEe5 o3M4wH9yi9hoSNCkUF696pjSGlYAvh9PQfa58L/pSMVmseSTB+gi0Pcv4p13MVfkVeEZanhchCQ zxmPHC04sL3CDwS0uH99LsgBBh06ysQNzPHUBK X-Google-Smtp-Source: AGHT+IED7jsYoy8m0Jv0UOu6nQ2sIFS9HNLAix0LSpEDO8WIkd6BRijTogWfa/p+EZdjPvtmA0ssoQ== X-Received: by 2002:a05:7300:e50f:b0:2ae:5e6e:bcbe with SMTP id 5a478bee46e88-2b05ea1b956mr903487eec.0.1766096506511; Thu, 18 Dec 2025 14:21:46 -0800 (PST) Received: from ?IPv6:2a03:83e0:115c:1:4779:aa2b:e8ff:52c4? ([2620:10d:c090:500::5:3eff]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b05ffd5f86sm1182521eec.5.2025.12.18.14.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Dec 2025 14:21:46 -0800 (PST) Message-ID: Subject: Re: [PATCH bpf-next v10 08/13] bpf: Skip anonymous types in type lookup for performance From: Eduard Zingerman To: Donglin Peng , ast@kernel.org, andrii.nakryiko@gmail.com Cc: zhangxiaoqin@xiaomi.com, ihor.solodrai@linux.dev, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, pengdonglin , Alan Maguire Date: Thu, 18 Dec 2025 14:21:44 -0800 In-Reply-To: <20251218113051.455293-9-dolinux.peng@gmail.com> References: <20251218113051.455293-1-dolinux.peng@gmail.com> <20251218113051.455293-9-dolinux.peng@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2025-12-18 at 19:30 +0800, Donglin Peng wrote: > From: pengdonglin >=20 > Currently, vmlinux and kernel module BTFs are unconditionally > sorted during the build phase, with named types placed at the > end. Thus, anonymous types should be skipped when starting the > search. In my vmlinux BTF, the number of anonymous types is > 61,747, which means the loop count can be reduced by 61,747. >=20 > Cc: Eduard Zingerman > Cc: Alexei Starovoitov > Cc: Andrii Nakryiko > Cc: Alan Maguire > Cc: Ihor Solodrai > Cc: Xiaoqin Zhang > Signed-off-by: pengdonglin > --- Acked-by: Eduard Zingerman > include/linux/btf.h | 1 + > kernel/bpf/btf.c | 24 ++++++++++++++++++++---- > kernel/bpf/verifier.c | 7 +------ > 3 files changed, 22 insertions(+), 10 deletions(-) >=20 > diff --git a/include/linux/btf.h b/include/linux/btf.h > index f06976ffb63f..2d28f2b22ae5 100644 > --- a/include/linux/btf.h > +++ b/include/linux/btf.h > @@ -220,6 +220,7 @@ bool btf_is_module(const struct btf *btf); > bool btf_is_vmlinux(const struct btf *btf); > struct module *btf_try_get_module(const struct btf *btf); > u32 btf_nr_types(const struct btf *btf); > +u32 btf_sorted_start_id(const struct btf *btf); > struct btf *btf_base_btf(const struct btf *btf); > bool btf_type_is_i32(const struct btf_type *t); > bool btf_type_is_i64(const struct btf_type *t); > diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c > index a9e2345558c0..3aeb4f00cbfe 100644 > --- a/kernel/bpf/btf.c > +++ b/kernel/bpf/btf.c > @@ -550,6 +550,11 @@ u32 btf_nr_types(const struct btf *btf) > return total; > } > =20 > +u32 btf_sorted_start_id(const struct btf *btf) Nit: the name is a bit confusing, given that it not always returns the start id for sorted part. btf_maybe_first_named_id? Can't figure out a good name :( > +{ > + return btf->sorted_start_id ?: (btf->start_id ?: 1); > +} > + > /* > * Assuming that types are sorted by name in ascending order. > */ [...]