From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 BE3F52459FD for ; Fri, 12 Dec 2025 07:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765523371; cv=none; b=GpFi9YVEefMYGUSBQRhDMlMB8TMabxiimNQeH62gon8up+9RjQAxi2f3HRh4RrQVidrAVyCGuPl2ZWYig1QN26Em0l0Fu2gbpXby8wVYpua347mamLtgOoxmnCNIopTVDmUWXXgUtWJGD/e21Ke5nmQYDcAREfhJVxZUOctOvTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765523371; c=relaxed/simple; bh=rcFIJSID1VDJnjvbTDVTD6FbXH4CfZBKvwp6ewb69eI=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Wq/iFXmLESDbJfh1aoLIUpKLDvjaZ0h13kpmuEVXDh6cq7IVWP+Bp50SwKVjgOB+/J2eVdyEbAcBy94rZRbRHl7zdHIoRPr1VXbLT31OkTxmIZ0orcsw/GOUh68zUN3moNeujekYdJ9ZHyoiYOoCBJSenNjJlAwuTeNL/GnFb5A= 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=Ubz2INzF; arc=none smtp.client-ip=209.85.214.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="Ubz2INzF" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29e93ab7ff5so11812575ad.3 for ; Thu, 11 Dec 2025 23:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765523369; x=1766128169; 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=taRaJ5VlWHSJuUogRunxbYADYYPRbeksELcn5Rh5qyI=; b=Ubz2INzFYWzJluuIuAe6UXjiqDjUq7/PsZsMLuX40oyGYZwEhENyjbAz3EnZN07AmD t60BW5maS5asuN1Pj9yjR4PY6Z7Z+RK4hhB0KmUwQOirC03p04HojfaYdwaND/Cyc+kl jKqzBanw94QMeYUW+GdqePZsZf9IsSQyL4T0BGOiWNrzQnFYgETncM8BzXkVaheTROKF KEIEaCmjmJGd7JJb22kLnkBbZjLBp12rzi/yKTJIFjfKtvkcy42gvz7pSh676SFmKpDw ZVuUbDZlJ04Z0atZD0GV9X8wlEwOHwkXjUF0FHqAbVeeYl/zuNrR4EQiiWAHUkX3igSB NoHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765523369; x=1766128169; 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=taRaJ5VlWHSJuUogRunxbYADYYPRbeksELcn5Rh5qyI=; b=wssqV7CF2P5vH7Q8K0h1YV09ddeHp6n1H95RZqcJmaGddvKWVbDiWVT+1kHRzLKBH2 9KNKAx33gGm6FWzFXT5rV4fNkHpXdXR4K6WgPOVSqi2DJLnnuH0/S4xNif+3qZAuPxR9 eozWOS/UPh61BJQPOTLonAfH0b0e716IC1/UNuBcbDqBJHXwMbg6DpAVjRC7n/JhiuLb mDuFzQxCjCWUMTu9ZfbST1p2PvUTz5oTjbXD2kViO8FVhcZq7z8intCHDaNLUVYPv54B /b1SgmnxzVetoTWYn5qUPypsEw8Urpq5p52gA15OYwbcUepWtGmrR4pbK00kyXYSufs7 hgfw== X-Forwarded-Encrypted: i=1; AJvYcCVjT571nuMtX8VUoAC+/iuxPv/jtYLY285ShP5/lYG9gQB6D1DgvOF2r3+frHOKuWojf21XApu9Ql6MiuA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7skjGzwlRxJ2WO2lVVvoi32PnF/ahbgmsuvOuKgLVjJ3vzvcD sEO7k/V0XNSi8kaKn+x0ivrKDF33b03vVNB/4ArsQhrC3cx9+SnNV/1e X-Gm-Gg: AY/fxX5trRtZr3UNPcpH6ocQ8rXxWHpUKW4R6DxELsymX70STeNO72hVLnuseyhUqjr Gu4SSkRgagxGV7hSYyn8dXPhHcsoF6vpztcFt5MAC1MfN9WPPo1YUN55DsZbjIfyKjmbxX+7fOy SfahYI9lv+ZpCHav6MwMbILxaJoz9pS6SrsgKczyAsDs79EQeHDw9HqXq4TmrbZU/vaaxBQztw1 9rySK2L2JVz4dY0tgnruMEfZoyfUY2Abuca6BwEfXxSXffpgATira8IG51pcgkU5vw3lG2dATHT O/ghUTPM/q/gSqwzIJpjYUherKhW401+qmF+Bv6qUkUq+kyPkB4+39NSzvlHaZW6oKz7cIbGni2 V7sRfPnE1L3cXHmC4yFik4sdiojN9KMLkG01ROZwHZ5/FuEekuwy/UymcQACpSROstj2OlgdImd /3NM+stz3nmDvlVgjZpRJNR3AXCY7ke3xHY+zjg18m148= X-Google-Smtp-Source: AGHT+IFofls55I9SmzDD+JUpzLkrd9iqjAHtwopQZ9d48ulj+lsYXpWt5ararv/5zaraLa80YwAWHQ== X-Received: by 2002:a17:903:46c6:b0:29d:9b3c:4fc8 with SMTP id d9443c01a7336-29f23d40decmr12993205ad.61.1765523368880; Thu, 11 Dec 2025 23:09:28 -0800 (PST) Received: from [10.200.2.32] (fs98a57d9c.tkyc007.ap.nuro.jp. [152.165.125.156]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29ee9b37356sm43756675ad.2.2025.12.11.23.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 23:09:28 -0800 (PST) Message-ID: <386068b11e146a9dbb502f770d7e012e3dea950f.camel@gmail.com> Subject: Re: [PATCH bpf-next v3 3/6] resolve_btfids: Introduce enum btf_id_kind From: Eduard Zingerman To: Ihor Solodrai , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Andrew Morton , Nathan Chancellor , Nicolas Schier , Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , Shuah Khan , Nick Desaulniers , Bill Wendling , Justin Stitt , Alan Maguire , Donglin Peng Cc: bpf@vger.kernel.org, dwarves@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Date: Fri, 12 Dec 2025 16:09:21 +0900 In-Reply-To: <20251205223046.4155870-4-ihor.solodrai@linux.dev> References: <20251205223046.4155870-1-ihor.solodrai@linux.dev> <20251205223046.4155870-4-ihor.solodrai@linux.dev> 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 Fri, 2025-12-05 at 14:30 -0800, Ihor Solodrai wrote: > Instead of using multiple flags, make struct btf_id tagged with an > enum value indicating its kind in the context of resolve_btfids. >=20 > Signed-off-by: Ihor Solodrai > --- Acked-by: Eduard Zingerman (But see a question below). > @@ -213,14 +218,19 @@ btf_id__add(struct rb_root *root, char *name, bool = unique) > p =3D &(*p)->rb_left; > else if (cmp > 0) > p =3D &(*p)->rb_right; > - else > - return unique ? NULL : id; > + else if (kind =3D=3D BTF_ID_KIND_SYM && id->kind =3D=3D BTF_ID_KIND_SY= M) Nit: I'd keep the 'unique' parameter alongside 'kind' and resolve this condition on the function callsite. > + return id; > + else { > + pr_err("Unexpected duplicate symbol %s of kind %d\n", name, id->kind)= ; > + return NULL; > + } [...] > @@ -491,28 +515,24 @@ static int symbols_collect(struct object *obj) > id =3D add_symbol(&obj->funcs, prefix, sizeof(BTF_FUNC) - 1); > /* set8 */ > } else if (!strncmp(prefix, BTF_SET8, sizeof(BTF_SET8) - 1)) { > - id =3D add_set(obj, prefix, true); > + id =3D add_set(obj, prefix, BTF_ID_KIND_SET8); > /* > * SET8 objects store list's count, which is encoded > * in symbol's size, together with 'cnt' field hence > * that - 1. > */ > - if (id) { > + if (id) > id->cnt =3D sym.st_size / sizeof(uint64_t) - 1; > - id->is_set8 =3D true; > - } > /* set */ > } else if (!strncmp(prefix, BTF_SET, sizeof(BTF_SET) - 1)) { > - id =3D add_set(obj, prefix, false); > + id =3D add_set(obj, prefix, BTF_ID_KIND_SET); > /* > * SET objects store list's count, which is encoded > * in symbol's size, together with 'cnt' field hence > * that - 1. > */ > - if (id) { > + if (id) Current patch is not a culprit, but shouldn't resolve_btfids fail if `id` cannot be added? (here and in a hunk above). > id->cnt =3D sym.st_size / sizeof(int) - 1; > - id->is_set =3D true; > - } > } else { > pr_err("FAILED unsupported prefix %s\n", prefix); > return -1; [...]