From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (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 DE48330F544 for ; Thu, 20 Nov 2025 23:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763682816; cv=none; b=HzQupgLF/5R2s4pAB0pUKsNGJvS6/DNekRr4bsjODz7tMlkulD1mUsQdhwDJy1wlBlj7Yb1gT2UTMW6/3V1UaakoPdUFO49U8CN2LUHRjdBkgBsaZ5F4WBMa6feU0PndeMdTzC3Ce4C/EHSguToTu7Xc/WCpGIvz6opGCJTDV/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763682816; c=relaxed/simple; bh=6MkpqLYBeUtZW2FisGc29Gg2U3zosEG3DPmCkwUavL4=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=i/0/yukJNi3HwXWt4ow+TnvS8wUbmLLRXG3cDFq9zIkdrH9OW9Xz/VrAAH6Yhav6Nrd5frw095W64gfsgB4OQvffORcQgnososI8VNb/FyQ2fAJSf86Y9a5cg8J5gYJLkvh9wLTYbXx6P9+IdL2bWn+jNSFucre9zIJ1CHrJ/Ms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=sAwJ992o; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sAwJ992o" Message-ID: <1bb340a3-2225-46e8-95a9-1923d737442c@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763682811; 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=/yO+eS6R173QWAxVtikFMZODumfxV4GmJp16Uo4SFO8=; b=sAwJ992oVvr+0FVjRwdDxSvSj+Vekrsc7lpXfNVaf24N5KssbfOguyBij04j6fsTa+4TVM TWCHXk4vYZ1mkHiIm/zwXBj+amjITZIkBuYFnMvp71aDIRwTz4ucT3NLUGpgDLIvnPpSNa 96SuYf5qxSFz4U8i+B6CHBDdHXO7YsQ= Date: Thu, 20 Nov 2025 15:53:23 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH v7 3/7] tools/resolve_btfids: Add --btf_sort option for BTF name sorting X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Ihor Solodrai To: Donglin Peng , ast@kernel.org, andrii.nakryiko@gmail.com, eddyz87@gmail.com Cc: zhangxiaoqin@xiaomi.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Donglin Peng , Alan Maguire , Song Liu References: <20251119031531.1817099-1-dolinux.peng@gmail.com> <20251119031531.1817099-4-dolinux.peng@gmail.com> <854f468a-d178-40f4-aa03-e19ff82a1a35@linux.dev> Content-Language: en-US In-Reply-To: <854f468a-d178-40f4-aa03-e19ff82a1a35@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 11/20/25 1:34 PM, Ihor Solodrai wrote: > On 11/18/25 7:15 PM, Donglin Peng wrote: >> From: Donglin Peng >> >> This patch introduces a new --btf_sort option that leverages libbpf's >> btf__permute interface to reorganize BTF layout. The implementation >> sorts BTF types by name in ascending order, placing anonymous types at >> the end to enable efficient binary search lookup. >> >> [...] >> >> +} >> + >> +static int update_btf_section(const char *path, const struct btf *btf, > > Hi Dongling. > > Thanks for working on this, it's a great optimization. Just want to > give you a heads up that I am preparing a patchset changing > resolve_btfids behavior. > > In particular, instead of updating the .BTF_ids section (and now with > your and upcoming changes the .BTF section) *in-place*, resolve_btfids > will only emit the data for the sections. And then it'll be integrated > into vmlinux with objcopy and linker. We already do a similar thing > with .BTF for vmlinux [1]. > > For your patchset it means that the parts handling ELF update will be > unnecessary. > > Also I think the --btf_sort flag is unnecessary. We probably want > kernel BTF to always be sorted in this way. And if resolve_btfids will > be handling more btf2btf transformation, we should avoid adding a > flags for every one of them. The same applies to --distilled_base. AFAIU we always want to do it, so there is not need for the flag. Unless there is a strong use case for generating module BTF *without* the distilled base that I am not aware of. Maybe an explicit "--kmodule" flag would be appropriate?.. For resolve_btfids, is it reasonable to assume it's a module if --base is passed in? Andrii, Eduard, wdyt? > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/scripts/link-vmlinux.sh#n110 > >