From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (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 4287D3FE67B for ; Tue, 26 May 2026 14:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779804938; cv=none; b=iwuFNlg5eVins64iezNWbtHqd9OK83OLxtDEJ9qIdZXMlzJ5zCuqcmGIO18YYRqbguJwY9pxClf7xZIHxGEgcX1L1g2zqEw4cxzPPbGFXhuXOqd1cGi4L2Qcg0zIQ84TwspelEYVTszye+A1XHDjz4kMBy3tP0obIxp3VXLSL9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779804938; c=relaxed/simple; bh=EdQq3aQ9KLzrDuftlkOM+TyHQLT0aDiS6zspb266sQU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=WEnqCl0HcBeYQef7d/H4SQ5VrY7Rzp6Yhe8QEpqRDLdElhZeve18BVJuOWMsm7B3Utj+rzwxTA7xVjQK9tSuoRvcwjN1i6tYrNXz9lUiYaUSaYEVJduD5x+xSxg901EEswXg87jVSbInHNZkdAuZCW8fTvn3iofiQ1sUpgxP0m8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fo/GW3my; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sidnayyar.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fo/GW3my" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-45e55c44ac1so8434879f8f.0 for ; Tue, 26 May 2026 07:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779804936; x=1780409736; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=wzpgf/wuecL2JBBMYkdRk+Xbi/3WeFb52lS50xAT3C0=; b=fo/GW3myFpc7dEflQWZOhwCoVrVaGe/fGDnB0tutrAmkJAtPNBBz7HAt/WFG1syPGj yCfwYreaHRv3K1j/9x19mc6oqSw/FQO9swYMXQvY95NUjjO4Ut4ZJUMkt12Ri+6MMiuQ 9LDveZeNHZ5y+WTEI+yJ7FhR/W3dvXg1pPyZquwDaSDEcpC0ipy6HbwR8iK33P4C4YuR i37ZrVf3aY0QY7OOZxkHTUa4c9THBKd1M+/OiRZcijZnFsrGy0oUPbzYO8F59AgQRp6/ mB56iO69Xhiaovgzpo+QvJu915NRX8iBEZfREsg0s7EST7vEPUs9EH4r1EKCaHdcqJLo 0gCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779804936; x=1780409736; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wzpgf/wuecL2JBBMYkdRk+Xbi/3WeFb52lS50xAT3C0=; b=CC0pzlVOxtrefvETC4qp+u5BdNPqOxe41A91acoX7Zg5Oq9rNskr0GIGidii/Fc3bE jQ43XM2r2FZxoOlGjOd4v+0ItqobFOI97CGqGTNYOj/J9PLD5tWO4KW4AFdHQO2XwCQc RxfOCOZsv+v0lBgnJDqKuxqixoQ563W+XpiuQq7W15Ccpu8g6ckLOuYAsFok7V0WrEbC hBzBG4HE4dY6ySMh/cfFXcMv7dFzbuCfliCdz8479GNeMssbIm1OHg84l48O+4NPu0Wt mq5CVsEpZu56/zJriy2lFYo46efL52QQnCH0rFMo/6ZwZNIBJUvwYO7EJef1i0Yxp7bd vf4Q== X-Forwarded-Encrypted: i=1; AFNElJ8T3xdc7c+kl7d7NR/YOEn8EzL05S61Es7ukeP2LJnIKI9abnMgjVBIKuBxG9s4tD4fEtsvP4W8GOPYt7s=@vger.kernel.org X-Gm-Message-State: AOJu0YyCLYmb1iLB9SJj4ibGNHSkeV8azfylRfSPMs1CG7Xl9aONBsXj BD3GS5tLnZLtih+CYM5vrD4zCqIo7ILmlqd2tM3qHCorsnFruwH6ks0foDEUh4yVrLMBamxLUJh futvbs1G7vvgabyBZ7A== X-Received: from wmxb15-n1.prod.google.com ([2002:a05:600d:844f:10b0:490:507b:f39f]) (user=sidnayyar job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3d96:b0:490:5429:1513 with SMTP id 5b1f17b1804b1-49054291bbamr250856825e9.6.1779804935406; Tue, 26 May 2026 07:15:35 -0700 (PDT) Date: Tue, 26 May 2026 14:15:33 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAAWrFWoC/5WNSw6CMBQAr2K69hla+0FX3sMYU+AVXgItKdhoC HcXSEx06XJmMTOxASPhwM67iUVMNFDwCxz3O1Y21tcIVC3MRCZ0poSAloqid9AGW0HqWvKPJxS jA/JQo7+vHiN0oUKQ0sj8KK2V2rAl2Ed09Nxm19vCDQ1jiK/tnfhqPxv5zyZx4KCdMo6fuDW2u tQh1C0eytCx9ZPEd1v/1RaQgTYqcypXp6LUP+15nt9wNRbpQQEAAA== X-Change-Id: 20260522-libbpf-load-vmlinux-btf-in-gen_loader-mode-4474834aa467 X-Mailer: b4 0.14.3 Message-ID: <20260526-libbpf-load-vmlinux-btf-in-gen_loader-mode-v3-0-5b4fa2a5e1a4@google.com> Subject: [PATCH v3 0/3] libbpf: support STRUCT_OPS in light skeletons From: Siddharth Nayyar To: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, gprocida@google.com, maennich@google.com, Siddharth Nayyar Content-Type: text/plain; charset="utf-8" This series enables support for BPF `STRUCT_OPS` maps (such as `sched_ext_ops` used by sched_ext) when using light skeletons (i.e. `gen_loader` mode). Previously, generating light skeletons for objects containing `STRUCT_OPS` maps would fail or produce incomplete results because `gen_loader` lacked support for several key features required by `STRUCT_OPS` maps, specifically: 1. Loading `vmlinux` BTF to resolve kernel-side type information. 2. Correctly plumbing `btf_vmlinux_value_type_id` into map creation attributes. 3. Ensuring `btf_key_type_id` is zeroed out to satisfy kernel safety checks. 4. Plumbing the userspace BTF FD (`btf_fd`) when `btf_vmlinux_value_type_id` is present but `btf_value_type_id` is zero (which is always the case for `STRUCT_OPS` maps). This series addresses these limitations by: - Loading `vmlinux` BTF in `gen_loader` mode when the BPF object contains `struct_ops` maps. - Explicitly zeroing out `btf_key_type_id` for `STRUCT_OPS` maps to satisfy kernel validations. - Plumbing `btf_vmlinux_value_type_id` during map creation in `gen_loader`. - Fixing `btf_fd` copying logic in `gen_loader` to populate it if either `btf_value_type_id` or `btf_vmlinux_value_type_id` is set. With these changes, it is now possible to generate and use light skeletons for BPF programs utilizing `STRUCT_OPS`, such as custom sched_ext schedulers. Signed-off-by: Siddharth Nayyar --- Changes in v3: - Remove erroneous change contracting map creation attribute size in gen_loader. - Link to v2: https://lore.kernel.org/r/20260526-libbpf-load-vmlinux-btf-in-gen_loader-mode-v2-0-6750f5859bc6@google.com Changes in v2: - Expand the series to 3 patches to fully support STRUCT_OPS in gen_loader. - Add a patch to explicitly zero out btf_key_type_id for STRUCT_OPS maps. - Add a patch to plumb btf_vmlinux_value_type_id and btf_fd in gen_loader. - Link to v1: https://lore.kernel.org/r/20260524-libbpf-load-vmlinux-btf-in-gen_loader-mode-v1-1-6f57f191a7ad@google.com --- Siddharth Nayyar (3): libbpf: load vmlinux BTF in gen_loader mode for struct_ops libbpf: zero out btf_key_type_id for STRUCT_OPS maps libbpf: plumb btf_vmlinux_value_type_id and btf_fd in gen_loader tools/lib/bpf/gen_loader.c | 3 ++- tools/lib/bpf/libbpf.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) --- base-commit: c6e99c10fd9855082568cbd71bb2cc5dc90eda53 change-id: 20260522-libbpf-load-vmlinux-btf-in-gen_loader-mode-4474834aa467 Best regards, -- Siddharth Nayyar