From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (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 44F262E03F1 for ; Tue, 23 Jun 2026 21:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782251116; cv=none; b=YTP5GA3GdEpt8Tqa9SvgWvQf644hmub/16l2Vldbh1DdRs30F1F/pM8fUSqlT6q/XPmdcCl4RwaBz8ORtmfCT46v0J+PRJQYrYT3tZjMBV9z/lD3YkIxmsBtODW6VU3OE3UScHmd2HRmhqbct5P7kbCjkMqhBCDhfKYdN9wPLds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782251116; c=relaxed/simple; bh=KVXTpBigc4LOIOv9wF0VWg5u69S8Jzw23jcmP1kPT64=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=JhGDezbYNg9L1yYvbnNj0sdngwnnYx5r1ekZXgXfMa2GHSRGQrpGg9GBLhYT4xQAT5rkBQjEw35+2X/PmgLo/1cALBXWffdCLPoFmL+da1Ix/E1P4DTQPY9eimWywxSbpDQ3q6cbf0TJam9spTJKz4BPJX6Kk9g4RKJTKO6j0K0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=uy3QDpjC; arc=none smtp.client-ip=74.125.82.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="uy3QDpjC" Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-30c591fb1cbso478011eec.1 for ; Tue, 23 Jun 2026 14:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1782251114; x=1782855914; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=aHXAd/f5rDSr7v51TVuMcnH6ZaDV9eNTIeTTyhu5DWE=; b=uy3QDpjCbzEU4jRqfn5skKhOOckPuuOgW55+El+SaOXhB/amgzs4JN7fp6zwZeX1mS VxnR/Gep5e6NSOh9xwuR8Rk/V9RnkUiOZaT/JxSdvP2cHU3vGDkJDxx65BYH90rXc2Sl pI5DfnmJW/iY9SqHojDxj0iZlQC6+xzjA7vD3ikaB9JqsK0R9vEB131WRJ0Y2K+TTI6P gK4j8cfPAAWj/Y6pHs98IBNxMvKrewKBy3pjpz27WhjcG4CBNuc/5BovQX2l4dmrfmrw NYUL+///wSFMQrVJLlMH5q7bdIEeCB7Y3KSvvdfwxKI+qC/QdP2gmqfiN0Ma++IlMqlO Fc1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782251114; x=1782855914; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aHXAd/f5rDSr7v51TVuMcnH6ZaDV9eNTIeTTyhu5DWE=; b=bZodPggZN0qwsUI0k3OwaEw3YjJIN4virjrkcGuGKJ/+cgqMVtGq6wi/L2orLp/ieG 1aqQy3bYMy/83VPk5oNDXZPfkEH2Q4lwCrnEzy2I5W3gCXszRdNt/j0qSY8rMCNEbC72 O8TXxcVJ76QAGF+BD9a6jq2xFiUXcXcOD15KKrCPdmB0h76SlkY25d2rpxxH64gmY1IZ 0qcZuKcpsnDgc4R0kQ9/+BuJuDvSrjpB3Zd5CuELODaWdSo/+yZflgLXwhAUCfEqqgoH psjbZhoHUEkLOO7REji06YChqiIzWkRDYVzaqo/SpxWIwNPJN70U+9PkDBPQumHRCgpp 90PA== X-Forwarded-Encrypted: i=1; AHgh+RrEkvOuq5VMDvIhDj6etT81n8BsbA0LFN/RHFNGzPjK4U5rbaJelDnWe96k9LaRVyqMZatcJwwdL2f3XIw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxjtdj6lMGvDWcry9QBcyKn63GYd+YjN9+YUrgXCKzydzXKE+Sw Qvp1vCY61cHRqzdbEDbqyWwCbXh+8lER6JDGYThf0c1rOPhgOm4Yr0HLYIU99b69n2s= X-Gm-Gg: AfdE7cls+jalPjzbtPdXDknxk6/qd8fOn83JixRoWQDaC+loedgF3J+i8apiKkbvd9Y 1bLP52i7/OWlcgicRfNM0wnqGbEjMjVxAou48kRBFU6nafZ+nrQBevP6cKxHkFU00CbTG3ML21t 8CNtZIo6Os6ZKjS+fhpuYnhR8SQkWIlaSNLj6K3XEk3dl6TH7+ZF8m5BE69gMbyBxnL8Bxc7qM2 qcPsMGK8V6IaDFifpWfIDPItPdEe0m5phMoWz++mbon0Vgh8O91J1YDI1KB3l+qZXRVNXiCTvJa GP3OM590U0vOnRPwwgipHna7173vpjuZebizzMsMDd6tSShRPckF+r7uzlG3gzMuglplq0sWOgb o7bf0aftD4QMnY6oL4QmViK4UImoFLzScxj7HHeKp5bmooazCvpG7NxvEsDaZCMHX7+IsqfG8fq Mj8azW X-Received: by 2002:a05:7300:80cf:b0:2f2:6dde:df54 with SMTP id 5a478bee46e88-30c68e904d5mr1013855eec.33.1782251114258; Tue, 23 Jun 2026 14:45:14 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::2526]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c1be45a00sm18657595eec.25.2026.06.23.14.45.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 14:45:13 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 Jun 2026 17:45:11 -0400 Message-Id: Cc: , , , , , , Subject: Re: [PATCH v3 2/2] tools/bpf/bpftool: Reset vmlinux BTF after struct_ops commands From: "Emil Tsalapatis" To: "Yichong Chen" , , , , , , X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260623072220.1421837-1-chenyichong@uniontech.com> <871EC84E76334A24+20260623072220.1421837-3-chenyichong@uniontech.com> In-Reply-To: <871EC84E76334A24+20260623072220.1421837-3-chenyichong@uniontech.com> On Tue Jun 23, 2026 at 3:22 AM EDT, Yichong Chen wrote: > struct_ops frees the global btf_vmlinux object. > > In batch mode, a later struct_ops command can reuse stale state. > > Reset the BTF pointer and cached map info state. > > Fixes: 65c93628599d ("bpftool: Add struct_ops support") > Signed-off-by: Yichong Chen > --- > tools/bpf/bpftool/struct_ops.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/tools/bpf/bpftool/struct_ops.c b/tools/bpf/bpftool/struct_op= s.c > index aa43dead249c..4dba7c96e5f6 100644 > --- a/tools/bpf/bpftool/struct_ops.c > +++ b/tools/bpf/bpftool/struct_ops.c > @@ -21,6 +21,15 @@ static __u32 map_info_alloc_len; > static struct btf *btf_vmlinux; > static __s32 map_info_type_id; > =20 > +static void free_btf_vmlinux(void) > +{ > + btf__free(btf_vmlinux); > + btf_vmlinux =3D NULL; > + map_info_type =3D NULL; > + map_info_alloc_len =3D 0; > + map_info_type_id =3D 0; > +} Nit but I don't think we need this to be a separate helper. We use it once, and it has the exact same name and type as the one in the previous patch. pw-bot: cr > + > struct res { > unsigned int nr_maps; > unsigned int nr_errs; > @@ -642,7 +651,7 @@ int do_struct_ops(int argc, char **argv) > =20 > err =3D cmd_select(cmds, argc, argv, do_help); > =20 > - btf__free(btf_vmlinux); > + free_btf_vmlinux(); > =20 > return err; > }