From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (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 46C8744D028 for ; Tue, 20 Jan 2026 18:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768934409; cv=none; b=aISZawdHJkdmt4monDUh9heRmuRZy5uMb4YtBr1tcExEBJ15dn78nT8eIRl/L+uTUIpuWFA0brI8DYljHIODHyn9kOqmn4bGbOhvc2vcTCp1WloULij9sf0gF9zWsMoOyfY+yxb/PQHQkdl4gpYfiGDDgjEg11h27atSZvGv8NI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768934409; c=relaxed/simple; bh=BuQ1ShCKV2TIwR4iKcKAM95usz7/aYLJ9oCUKkNrd8I=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=MLJAEISKa1Nv1922hPErxyvYOPWnsUce9krCcEZEr3eyBndKr6TWKuOSNEFPP5UWHkPYBROmaiLyUUwyamNY6IxnP30lXHk6d/RVgKWonRUL6EIR4beOEjEy6H7EF/kifgBtTFQ2hW2F2Q/kKkjkrHh4xzg+9/WMW7Z8ZxcvIU4= 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=CUTs/nPr; arc=none smtp.client-ip=74.125.82.180 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="CUTs/nPr" Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-2b0ea1edf11so10609924eec.0 for ; Tue, 20 Jan 2026 10:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768934406; x=1769539206; 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=LeeG+LydMx9pdpEIlKwJIXhJ7Lz8QyFbhhTyyId5je0=; b=CUTs/nPr3Zbf9YvGWz94tNQCdWKTx0iOYEhqJbDnJWcva067NHTDRqYDhfHZec2ZgJ nc1aCETo5oNJY5oCT9GJs6FoSviJN7j5bs28Y5FOgtBYTOvbS/UtnH3c4uNp4HgowLUY XxVmPbhn8EWqxdHCy3hMRXTMLn2XMD8bUWfYSJvdi7qj+mhesDrB7A4unIn0qxR01AMc 92Yop6qSWAMREAJ4QJ++1EWEm/Ue7HO4WmO+x5I6xxagTaUYkPPwpt6UKDKs8U//inum xAi2bWgHPsQp2iy/JxVnl/Jd4hnRodJizkC7VesTY1GCT8pL62/trv4rXnWvjcbrJfhW yCgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768934406; x=1769539206; 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=LeeG+LydMx9pdpEIlKwJIXhJ7Lz8QyFbhhTyyId5je0=; b=aozStRFXLVluDtT/7fWepm/ZJgPORDl/EFKKEFTsm1S319Qvyxa0VF9J9OWNDWVAz8 lLgSFAVHo4X7b6UrUceIHIp3ihuJJ4ySGjnaxKDqQLGdpqaLyurtK9JpBWAfQ9gmsLdA YVLEmX1EcHQludnJDjDvuYx5PmKsYRUpth9nIubgafYG5ZPy268pBU+7pIqJR4/f2nKc 1Rv8G5clMJOZC4hzQcBy1GA1oMWBlq/CwwDLBwUpEp2lld5OSFIHfUIOFhO5wzsf9K6A kyL/rMl3k6ajeM2AELpTjLY1C46xLHijppfOEFYApj7A1KDdO++XE/j9yACJ2wXAzNXV B+4w== X-Forwarded-Encrypted: i=1; AJvYcCWlKqN7PMIFWDRC/lEUxIUmqNrq2275NoX9hevgawjFDFyb+d8vidUDpwC1Q3D4P8DpEDWabtUjaIXYG78=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6KV4Mb69SRshp6/bxSnGhWkd5LJBISAfgKceHGOzDd75UC3Sx ejQXCrD24Kba3ZT5qZNOPtSjLpua7DjI3XY14ihOzOsSReVsbksCeNFB X-Gm-Gg: AZuq6aKpusXVaAOw+JhbOZVj0vrHfnqhRxu9CxpsftxRjmiGnC/H+b3UOE5+gSPVgJR sHQAQwRYM6j1DoUNlLWx+cWC+kqf1loVjI7k4T2UkbWseTVZAWGtus3qFraSJEhjPO4xue8pPS4 UO0qQSWgNfNDkbEr7c51MOAMonbDEPJcHLihiknZN/KpX3ubQ+QWJim8ZrHgchLlbuc4aZUVzFB E1PBWrsWeCdFGpq9dgNRf3/e7wTLmCvZfrLjO5M9YmsV9O2pSCqIAgq3A6vgM8VPNVtml8NzSiZ BYVvlZnYGmh1NJl2G0FKC+NMn00H2jrtZIZWgyTtAIyK74xVT3o3Ga/TGHxU3uht93oT1QT5SAC xD3Yzw//8XNOMsSNJq/Pa2IRaV7KMBbe2W2HkGENvcPILQjqEoJTm+l3sDdycyEgu0f0BAt4U1s hr8a7k8qyNAY+w3iVjzJi8bdnm4gSRKPTXsgR9kGazQ1VoQehKU2gEWZuCcOgS0F3IoqNve6Dbi 95Iayg= X-Received: by 2002:a05:7300:8188:b0:2ab:c284:d5d2 with SMTP id 5a478bee46e88-2b6b4e2841emr10118777eec.4.1768934405935; Tue, 20 Jan 2026 10:40:05 -0800 (PST) Received: from ?IPv6:2a03:83e0:115c:1:b08c:bb3d:92b9:704d? ([2620:10d:c090:500::3:93b1]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6b3502d22sm18159145eec.10.2026.01.20.10.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 10:40:05 -0800 (PST) Message-ID: <45b3df2a1b83a90c134b265ecd713731173556f0.camel@gmail.com> Subject: Re: [PATCH bpf-next v2 04/13] resolve_btfids: Introduce finalize_btf() step From: Eduard Zingerman To: Ihor Solodrai , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau Cc: Mykyta Yatsenko , Tejun Heo , Alan Maguire , Benjamin Tissoires , Jiri Kosina , Amery Hung , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, sched-ext@lists.linux.dev Date: Tue, 20 Jan 2026 10:40:03 -0800 In-Reply-To: <74fbaa99-024b-4e42-bda0-99ae792d565b@linux.dev> References: <20260116201700.864797-1-ihor.solodrai@linux.dev> <20260116201700.864797-5-ihor.solodrai@linux.dev> <74fbaa99-024b-4e42-bda0-99ae792d565b@linux.dev> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2026-01-20 at 10:35 -0800, Ihor Solodrai wrote: > On 1/20/26 10:19 AM, Eduard Zingerman wrote: > > On Tue, 2026-01-20 at 10:11 -0800, Ihor Solodrai wrote: > >=20 > > [...] > >=20 > > > > > @@ -1099,12 +1116,22 @@ int main(int argc, const char **argv) > > > > > if (obj.efile.idlist_shndx =3D=3D -1 || > > > > > obj.efile.symbols_shndx =3D=3D -1) { > > > > > pr_debug("Cannot find .BTF_ids or symbols sections, skip symbo= ls resolution\n"); > > > > > - goto dump_btf; > > > > > + resolve_btfids =3D false; > > > > > } > > > > > =20 > > > > > - if (symbols_collect(&obj)) > > > > > + if (resolve_btfids) > > > > > + if (symbols_collect(&obj)) > > > > > + goto out; > > > >=20 > > > > Nit: check obj.efile.idlist_shndx and obj.efile.symbols_shndx insid= e symbols_collect()? > > > > To avoid resolve_btfids flag and the `goto dump_btf;` below. > > >=20 > > > Hi Eduard, thank you for review. > > >=20 > > > The issue is that in case of .BTF_ids section absent we have to skip > > > some of the steps, specifically: > > > - symbols_collect() > > > - sequence between symbols_resolve() and dump_raw_btf_ids() > >=20 > > > It's not an exit condition, we still have to do load/dump of the BTF. > > >=20 > > > I tried in symbols_collect(): > > >=20 > > > if (obj.efile.idlist_shndx =3D=3D -1 || obj.efile.symbols_shndx =3D= =3D -1) > > > return 0; > > >=20 > > > But then, we either have to do the same check in symbols_resolve() an= d > > > co, or maybe store a flag in the struct object. So I decided it's > > > better to have an explicit flag in the main control flow, instead of > > > hiding it. > >=20 > > For symbols_resolve() is any special logic necessary? > > I think that `id =3D btf_id__find(root, str);` will just return NULL fo= r > > every type, thus the whole function would be a noop passing through > > BTF types once. > >=20 > > symbols_patch() will be a noop, as it will attempt traversing empty roo= ts. > > dump_raw_btf_ids() already returns if there are no .BTF_ids. >=20 > Hm... Looks like you're right, those would be noops. >=20 > Still, I think it's clearer what steps are skipped with a toplevel > flag. Otherwise to figure out that those are noops you need to check > every subroutine (as you just did), and a future change may > unintentionally break the expectation of noop creating an unnecessary > debugging session. I'd argue that resolve_btfids is written in a clear read data / process data manner, so it should behave correctly even if collected data is empty. Is there a difference between no .BTF_ids and empty .BTF_ids? > And re symbols_resolve(), if we don't like allocating unnecessary > memory, why are we ok with traversing the BTF with noops? Seems > a bit inconsistent to me. He-he, I never heard about consistency :) Just don't like flags, they make me think more.