Repository: libbpf/libbpf-rs
Pull request #1114:  Enumerize tracepoint categories as described in #314
Author: login: syogaraj
Created: 2025-03-06T14:15:08Z | Merged: 2025-03-13T16:06:28Z

1. Used `trace-cmd list -e` for the list of tracepoint categories.
2. Tracepoint now has its own file (`tracepoint.rs`). Hence, removed `TracepointOpts` from `program.rs` and placed it in `tracepoint.rs`.


Diff:
diff --git a/libbpf-rs/src/lib.rs b/libbpf-rs/src/lib.rs
index d8f10f19..d03a6c4a 100644
--- a/libbpf-rs/src/lib.rs
+++ b/libbpf-rs/src/lib.rs
@@ -93,6 +93,7 @@ pub mod query;
 mod ringbuf;
 mod skeleton;
 mod tc;
+mod tracepoint;
 mod user_ringbuf;
 mod util;
 mod xdp;
@@ -153,8 +154,6 @@ pub use crate::program::ProgramAttachType;
 pub use crate::program::ProgramImpl;
 pub use crate::program::ProgramMut;
 pub use crate::program::ProgramType;
-pub use crate::program::RawTracepointOpts;
-pub use crate::program::TracepointOpts;
 pub use crate::program::UprobeOpts;
 pub use crate::program::UsdtOpts;
 pub use crate::ringbuf::RingBuffer;
@@ -169,6 +168,9 @@ pub use crate::tc::TC_H_INGRESS;
 pub use crate::tc::TC_H_MIN_EGRESS;
 pub use crate::tc::TC_H_MIN_INGRESS;
 pub use crate::tc::TC_INGRESS;
+pub use crate::tracepoint::RawTracepointOpts;
+pub use crate::tracepoint::TracepointCategory;
+pub use crate::tracepoint::TracepointOpts;
 pub use crate::user_ringbuf::UserRingBuffer;
 pub use crate::user_ringbuf::UserRingBufferSample;
 pub use crate::util::num_possible_cpus;
diff --git a/libbpf-rs/src/program.rs b/libbpf-rs/src/program.rs
index 8b54b5d2..c9bba42b 100644
--- a/libbpf-rs/src/program.rs
+++ b/libbpf-rs/src/program.rs
@@ -34,7 +34,10 @@ use crate::Error;
 use crate::ErrorExt as _;
 use crate::Link;
 use crate::Mut;
+use crate::RawTracepointOpts;
 use crate::Result;
+use crate::TracepointCategory;
+use crate::TracepointOpts;
 
 /// Options to optionally be provided when attaching to a uprobe.
 #[derive(Clone, Debug, Default)]
@@ -87,58 +90,6 @@ impl From<UsdtOpts> for libbpf_sys::bpf_usdt_opts {
     }
 }
 
-/// Options to optionally be provided when attaching to a tracepoint.
-#[derive(Clone, Debug, Default)]
-pub struct TracepointOpts {
-    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
-    pub cookie: u64,
-    #[doc(hidden)]
-    pub _non_exhaustive: (),
-}
-
-impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
-    fn from(opts: TracepointOpts) -> Self {
-        let TracepointOpts {
-            cookie,
-            _non_exhaustive,
-        } = opts;
-
-        #[allow(clippy::needless_update)]
-        libbpf_sys::bpf_tracepoint_opts {
-            sz: size_of::<Self>() as _,
-            bpf_cookie: cookie,
-            // bpf_tracepoint_opts might have padding fields on some platform
-            ..Default::default()
-        }
-    }
-}
-
-/// Options to optionally be provided when attaching to a raw tracepoint.
-#[derive(Clone, Debug, Default)]
-pub struct RawTracepointOpts {
-    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
-    pub cookie: u64,
-    #[doc(hidden)]
-    pub _non_exhaustive: (),
-}
-
-impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
-    fn from(opts: RawTracepointOpts) -> Self {
-        let RawTracepointOpts {
-            cookie,
-            _non_exhaustive,
-        } = opts;
-
-        #[allow(clippy::needless_update)]
-        libbpf_sys::bpf_raw_tracepoint_opts {
-            sz: size_of::<Self>() as _,
-            cookie,
-            // bpf_raw_tracepoint_opts might have padding fields on some platform
-            ..Default::default()
-        }
-    }
-}
-
 /// Options to optionally be provided when attaching to a kprobe.
 #[derive(Clone, Debug, Default)]
 pub struct KprobeOpts {
@@ -1101,7 +1052,7 @@ impl<'obj> ProgramMut<'obj> {
     /// tracepoint](https://www.kernel.org/doc/html/latest/trace/tracepoints.html).
     pub fn attach_tracepoint(
         &self,
-        tp_category: impl AsRef<str>,
+        tp_category: TracepointCategory,
         tp_name: impl AsRef<str>,
     ) -> Result<Link> {
         self.attach_tracepoint_impl(tp_category.as_ref(), tp_name.as_ref(), None)
@@ -1112,7 +1063,7 @@ impl<'obj> ProgramMut<'obj> {
     /// providing additional options.
     pub fn attach_tracepoint_with_opts(
         &self,
-        tp_category: impl AsRef<str>,
+        tp_category: TracepointCategory,
         tp_name: impl AsRef<str>,
         tp_opts: TracepointOpts,
     ) -> Result<Link> {
diff --git a/libbpf-rs/src/tracepoint.rs b/libbpf-rs/src/tracepoint.rs
new file mode 100644
index 00000000..11fd71f9
--- /dev/null
+++ b/libbpf-rs/src/tracepoint.rs
@@ -0,0 +1,557 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+/// Options to optionally be provided when attaching to a raw tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct RawTracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
+    fn from(opts: RawTracepointOpts) -> Self {
+        let RawTracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_raw_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            cookie,
+            // bpf_raw_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[derive(Debug, Clone)]
+pub enum TracepointCategory {
+    /// 9P protocol events.
+    P9,
+    /// Andrew File System events.
+    Afs,
+    /// Alarm timer events.
+    Alarmtimer,
+    /// ALSA System-on-Chip audio events.
+    Asoc,
+    /// Access Vector Cache events.
+    Avc,
+    /// Bcache events.
+    Bcache,
+    /// Block layer events.
+    Block,
+    /// BPF test run events.
+    BpfTestRun,
+    /// BPF trace events.
+    BpfTrace,
+    /// Bridge events.
+    Bridge,
+    /// Btrfs filesystem events.
+    Btrfs,
+    /// Cachefiles events.
+    Cachefiles,
+    /// Control groups events.
+    Cgroup,
+    /// Clock subsystem events.
+    Clk,
+    /// CMA events.
+    Cma,
+    /// Memory compaction events.
+    Compaction,
+    /// Context tracking events.
+    ContextTracking,
+    /// CPU hotplug events.
+    Cpuhp,
+    /// CSD events.
+    Csd,
+    /// Damon events.
+    Damon,
+    /// Devfreq events.
+    Devfreq,
+    /// Device link events.
+    Devlink,
+    /// Distributed lock manager events.
+    Dlm,
+    /// DMA events.
+    Dma,
+    /// DMA fence events.
+    DmaFence,
+    /// EROFS filesystem events.
+    Erofs,
+    /// Error reporting events.
+    ErrorReport,
+    /// Ext4 filesystem events.
+    Ext4,
+    /// F2FS filesystem events.
+    F2Fs,
+    /// FIB events.
+    Fib,
+    /// IPv6 FIB events.
+    Fib6,
+    /// File lock events.
+    Filelock,
+    /// File mapping events.
+    Filemap,
+    /// FS-Cache events.
+    Fscache,
+    /// DAX filesystem events.
+    FsDax,
+    /// FSI events.
+    Fsi,
+    /// FSI master Aspeed events.
+    FsiMasterAspeed,
+    /// FSI master AST-CF events.
+    FsiMasterAstCf,
+    /// FSI master GPIO events.
+    FsiMasterGpio,
+    /// FSI master I2CR events.
+    FsiMasterI2Cr,
+    /// GPIO events.
+    Gpio,
+    /// GPU memory events.
+    GpuMem,
+    /// Habana Labs events.
+    Habanalabs,
+    /// Handshake events.
+    Handshake,
+    /// Host1X events.
+    Host1X,
+    /// Huge memory events.
+    HugeMemory,
+    /// HugeTLB filesystem events.
+    Hugetlbfs,
+    /// Hardware monitoring events.
+    Hwmon,
+    /// Hardware pressure events.
+    HwPressure,
+    /// I2C events.
+    I2C,
+    /// I2C slave events.
+    I2CSlave,
+    /// InfiniBand MAD events.
+    IbMad,
+    /// InfiniBand UMAD events.
+    IbUmad,
+    /// ICMP events.
+    Icmp,
+    /// Initialization call events.
+    Initcall,
+    /// Intel IFS events.
+    IntelIfs,
+    /// Intel ISH events.
+    IntelIsh,
+    /// Intel SST events.
+    IntelSst,
+    /// IO cost events.
+    Iocost,
+    /// IOMMU events.
+    Iommu,
+    /// IO uring events.
+    IoUring,
+    /// Inter-processor interrupt events.
+    Ipi,
+    /// IRQ events.
+    Irq,
+    /// IRQ matrix events.
+    IrqMatrix,
+    /// iSCSI events.
+    Iscsi,
+    /// JBD2 events.
+    Jbd2,
+    /// Kernel memory events.
+    Kmem,
+    /// Kernel same-page merging events.
+    Ksm,
+    /// KVM events.
+    Kvm,
+    /// Kyber events.
+    Kyber,
+    /// Libata events.
+    Libata,
+    /// Lock events.
+    Lock,
+    /// Maple tree events.
+    MapleTree,
+    /// Machine Check Exception events.
+    Mce,
+    /// MCTP events.
+    Mctp,
+    /// MDIO events.
+    Mdio,
+    /// Memory controller events.
+    Memcg,
+    /// Memory migration events.
+    Migrate,
+    /// Mellanox switch events.
+    Mlxsw,
+    /// Memory mapping events.
+    Mmap,
+    /// Memory map lock events.
+    MmapLock,
+    /// MMC events.
+    Mmc,
+    /// Module events.
+    Module,
+    /// Multipath TCP events.
+    Mptcp,
+    /// NAPI events.
+    Napi,
+    /// Network block device events.
+    Nbd,
+    /// Neighbor events.
+    Neigh,
+    /// Networking events.
+    Net,
+    /// Network filesystem events.
+    Netfs,
+    /// Netlink events.
+    Netlink,
+    /// NILFS2 filesystem events.
+    Nilfs2,
+    /// Non-maskable interrupt events.
+    Nmi,
+    /// Notifier events.
+    Notifier,
+    /// Object aggregation events.
+    Objagg,
+    /// Out of memory events.
+    Oom,
+    /// OS noise events.
+    Osnoise,
+    /// Page isolation events.
+    PageIsolation,
+    /// Pagemap events.
+    Pagemap,
+    /// Page pool events.
+    PagePool,
+    /// Page reference events.
+    PageRef,
+    /// Per-CPU events.
+    Percpu,
+    /// Power management events.
+    Power,
+    /// Preemption and IRQ events.
+    Preemptirq,
+    /// Printk events.
+    Printk,
+    /// PWC events.
+    Pwc,
+    /// PWM events.
+    Pwm,
+    /// Queueing discipline events.
+    Qdisc,
+    /// QLogic adapter events.
+    Qla,
+    /// QRTR events.
+    Qrtr,
+    /// Raw syscalls events.
+    RawSyscalls,
+    /// Read-copy-update events.
+    Rcu,
+    /// RDMA core events.
+    RdmaCore,
+    /// Regulator events.
+    Regulator,
+    /// RPC GSS events.
+    Rpcgss,
+    /// RPC RDMA events.
+    Rpcrdma,
+    /// Runtime Power Management events.
+    Rpm,
+    /// Restartable sequences events.
+    Rseq,
+    /// Real-time clock events.
+    Rtc,
+    /// Rust sample events.
+    RustSample,
+    /// Reduced Virtualization events.
+    Rv,
+    /// Read-write memory-mapped I/O events.
+    Rwmmio,
+    /// RxRPC events.
+    Rxrpc,
+    /// Scheduler events.
+    Sched,
+    /// Scheduler extensions events.
+    SchedExt,
+    /// SCMI events.
+    Scmi,
+    /// SCSI events.
+    Scsi,
+    /// SCTP protocol events.
+    Sctp,
+    /// Signal events.
+    Signal,
+    /// SIOX events.
+    Siox,
+    /// Socket buffer events.
+    Skb,
+    /// SMBus events.
+    Smbus,
+    /// Socket events.
+    Sock,
+    /// Sound Open Firmware events.
+    Sof,
+    /// Sound Open Firmware Intel events.
+    SofIntel,
+    /// SPI events.
+    Spi,
+    /// System Power Management Interface events.
+    Spmi,
+    /// SunRPC events.
+    Sunrpc,
+    /// Sunvnet events.
+    Sunvnet,
+    /// Software I/O translation buffer events.
+    Swiotlb,
+    /// System call events.
+    Syscalls,
+    /// Target events.
+    Target,
+    /// Task events.
+    Task,
+    /// TCP (Transmission Control Protocol) events.
+    Tcp,
+    /// Tegra APB DMA events.
+    TegraApbDma,
+    /// Transparent Huge Pages events.
+    Thp,
+    /// Timer events.
+    Timer,
+    /// Timer migration events.
+    TimerMigration,
+    /// Timestamp events.
+    Timestamp,
+    /// Translation Lookaside Buffer events.
+    Tlb,
+    /// UDP (User Datagram Protocol) events.
+    Udp,
+    /// Video4Linux2 events.
+    V4L2,
+    /// Video buffer events.
+    Vb2,
+    /// Virtual memory allocation events.
+    Vmalloc,
+    /// Virtual memory scanning events.
+    Vmscan,
+    /// Virtual socket events.
+    Vsock,
+    /// Watchdog events.
+    Watchdog,
+    /// Writeback throttling events.
+    Wbt,
+    /// Workqueue events.
+    Workqueue,
+    /// Writeback events.
+    Writeback,
+    /// XDP events.
+    Xdp,
+    /// Xen hypervisor events.
+    Xen,
+    /// Custom type. Tracepoint category that is not predefined.
+    Custom(String),
+}
+
+impl AsRef<str> for TracepointCategory {
+    fn as_ref(&self) -> &str {
+        match self {
+            TracepointCategory::P9 => "9p",
+            TracepointCategory::Afs => "afs",
+            TracepointCategory::Alarmtimer => "alarmtimer",
+            TracepointCategory::Asoc => "asoc",
+            TracepointCategory::Avc => "avc",
+            TracepointCategory::Bcache => "bcache",
+            TracepointCategory::Block => "block",
+            TracepointCategory::BpfTestRun => "bpf_test_run",
+            TracepointCategory::BpfTrace => "bpf_trace",
+            TracepointCategory::Bridge => "bridge",
+            TracepointCategory::Btrfs => "btrfs",
+            TracepointCategory::Cachefiles => "cachefiles",
+            TracepointCategory::Cgroup => "cgroup",
+            TracepointCategory::Clk => "clk",
+            TracepointCategory::Cma => "cma",
+            TracepointCategory::Compaction => "compaction",
+            TracepointCategory::ContextTracking => "context_tracking",
+            TracepointCategory::Cpuhp => "cpuhp",
+            TracepointCategory::Csd => "csd",
+            TracepointCategory::Damon => "damon",
+            TracepointCategory::Devfreq => "devfreq",
+            TracepointCategory::Devlink => "devlink",
+            TracepointCategory::Dlm => "dlm",
+            TracepointCategory::Dma => "dma",
+            TracepointCategory::DmaFence => "dma_fence",
+            TracepointCategory::Erofs => "erofs",
+            TracepointCategory::ErrorReport => "error_report",
+            TracepointCategory::Ext4 => "ext4",
+            TracepointCategory::F2Fs => "f2fs",
+            TracepointCategory::Fib => "fib",
+            TracepointCategory::Fib6 => "fib6",
+            TracepointCategory::Filelock => "filelock",
+            TracepointCategory::Filemap => "filemap",
+            TracepointCategory::Fscache => "fscache",
+            TracepointCategory::FsDax => "fs_dax",
+            TracepointCategory::Fsi => "fsi",
+            TracepointCategory::FsiMasterAspeed => "fsi_master_aspeed",
+            TracepointCategory::FsiMasterAstCf => "fsi_master_ast_cf",
+            TracepointCategory::FsiMasterGpio => "fsi_master_gpio",
+            TracepointCategory::FsiMasterI2Cr => "fsi_master_i2cr",
+            TracepointCategory::Gpio => "gpio",
+            TracepointCategory::GpuMem => "gpu_mem",
+            TracepointCategory::Habanalabs => "habanalabs",
+            TracepointCategory::Handshake => "handshake",
+            TracepointCategory::Host1X => "host1x",
+            TracepointCategory::HugeMemory => "huge_memory",
+            TracepointCategory::Hugetlbfs => "hugetlbfs",
+            TracepointCategory::Hwmon => "hwmon",
+            TracepointCategory::HwPressure => "hw_pressure",
+            TracepointCategory::I2C => "i2c",
+            TracepointCategory::I2CSlave => "i2c_slave",
+            TracepointCategory::IbMad => "ib_mad",
+            TracepointCategory::IbUmad => "ib_umad",
+            TracepointCategory::Icmp => "icmp",
+            TracepointCategory::Initcall => "initcall",
+            TracepointCategory::IntelIfs => "intel_ifs",
+            TracepointCategory::IntelIsh => "intel_ish",
+            TracepointCategory::IntelSst => "intel-sst",
+            TracepointCategory::Iocost => "iocost",
+            TracepointCategory::Iommu => "iommu",
+            TracepointCategory::IoUring => "io_uring",
+            TracepointCategory::Ipi => "ipi",
+            TracepointCategory::Irq => "irq",
+            TracepointCategory::IrqMatrix => "irq_matrix",
+            TracepointCategory::Iscsi => "iscsi",
+            TracepointCategory::Jbd2 => "jbd2",
+            TracepointCategory::Kmem => "kmem",
+            TracepointCategory::Ksm => "ksm",
+            TracepointCategory::Kvm => "kvm",
+            TracepointCategory::Kyber => "kyber",
+            TracepointCategory::Libata => "libata",
+            TracepointCategory::Lock => "lock",
+            TracepointCategory::MapleTree => "maple_tree",
+            TracepointCategory::Mce => "mce",
+            TracepointCategory::Mctp => "mctp",
+            TracepointCategory::Mdio => "mdio",
+            TracepointCategory::Memcg => "memcg",
+            TracepointCategory::Migrate => "migrate",
+            TracepointCategory::Mlxsw => "mlxsw",
+            TracepointCategory::Mmap => "mmap",
+            TracepointCategory::MmapLock => "mmap_lock",
+            TracepointCategory::Mmc => "mmc",
+            TracepointCategory::Module => "module",
+            TracepointCategory::Mptcp => "mptcp",
+            TracepointCategory::Napi => "napi",
+            TracepointCategory::Nbd => "nbd",
+            TracepointCategory::Neigh => "neigh",
+            TracepointCategory::Net => "net",
+            TracepointCategory::Netfs => "netfs",
+            TracepointCategory::Netlink => "netlink",
+            TracepointCategory::Nilfs2 => "nilfs2",
+            TracepointCategory::Nmi => "nmi",
+            TracepointCategory::Notifier => "notifier",
+            TracepointCategory::Objagg => "objagg",
+            TracepointCategory::Oom => "oom",
+            TracepointCategory::Osnoise => "osnoise",
+            TracepointCategory::PageIsolation => "page_isolation",
+            TracepointCategory::Pagemap => "pagemap",
+            TracepointCategory::PagePool => "page_pool",
+            TracepointCategory::PageRef => "page_ref",
+            TracepointCategory::Percpu => "percpu",
+            TracepointCategory::Power => "power",
+            TracepointCategory::Preemptirq => "preemptirq",
+            TracepointCategory::Printk => "printk",
+            TracepointCategory::Pwc => "pwc",
+            TracepointCategory::Pwm => "pwm",
+            TracepointCategory::Qdisc => "qdisc",
+            TracepointCategory::Qla => "qla",
+            TracepointCategory::Qrtr => "qrtr",
+            TracepointCategory::RawSyscalls => "raw_syscalls",
+            TracepointCategory::Rcu => "rcu",
+            TracepointCategory::RdmaCore => "rdma_core",
+            TracepointCategory::Regulator => "regulator",
+            TracepointCategory::Rpcgss => "rpcgss",
+            TracepointCategory::Rpcrdma => "rpcrdma",
+            TracepointCategory::Rpm => "rpm",
+            TracepointCategory::Rseq => "rseq",
+            TracepointCategory::Rtc => "rtc",
+            TracepointCategory::RustSample => "rust_sample",
+            TracepointCategory::Rv => "rv",
+            TracepointCategory::Rwmmio => "rwmmio",
+            TracepointCategory::Rxrpc => "rxrpc",
+            TracepointCategory::Sched => "sched",
+            TracepointCategory::SchedExt => "sched_ext",
+            TracepointCategory::Scmi => "scmi",
+            TracepointCategory::Scsi => "scsi",
+            TracepointCategory::Sctp => "sctp",
+            TracepointCategory::Signal => "signal",
+            TracepointCategory::Siox => "siox",
+            TracepointCategory::Skb => "skb",
+            TracepointCategory::Smbus => "smbus",
+            TracepointCategory::Sock => "sock",
+            TracepointCategory::Sof => "sof",
+            TracepointCategory::SofIntel => "sof_intel",
+            TracepointCategory::Spi => "spi",
+            TracepointCategory::Spmi => "spmi",
+            TracepointCategory::Sunrpc => "sunrpc",
+            TracepointCategory::Sunvnet => "sunvnet",
+            TracepointCategory::Swiotlb => "swiotlb",
+            TracepointCategory::Syscalls => "syscalls",
+            TracepointCategory::Target => "target",
+            TracepointCategory::Task => "task",
+            TracepointCategory::Tcp => "tcp",
+            TracepointCategory::TegraApbDma => "tegra_apb_dma",
+            TracepointCategory::Thp => "thp",
+            TracepointCategory::Timer => "timer",
+            TracepointCategory::TimerMigration => "timer_migration",
+            TracepointCategory::Timestamp => "timestamp",
+            TracepointCategory::Tlb => "tlb",
+            TracepointCategory::Udp => "udp",
+            TracepointCategory::V4L2 => "v4l2",
+            TracepointCategory::Vb2 => "vb2",
+            TracepointCategory::Vmalloc => "vmalloc",
+            TracepointCategory::Vmscan => "vmscan",
+            TracepointCategory::Vsock => "vsock",
+            TracepointCategory::Watchdog => "watchdog",
+            TracepointCategory::Wbt => "wbt",
+            TracepointCategory::Workqueue => "workqueue",
+            TracepointCategory::Writeback => "writeback",
+            TracepointCategory::Xdp => "xdp",
+            TracepointCategory::Xen => "xen",
+            TracepointCategory::Custom(category) => category,
+        }
+    }
+}
diff --git a/libbpf-rs/tests/test.rs b/libbpf-rs/tests/test.rs
index 2b083b42..3d633124 100644
--- a/libbpf-rs/tests/test.rs
+++ b/libbpf-rs/tests/test.rs
@@ -43,6 +43,7 @@ use libbpf_rs::Program;
 use libbpf_rs::ProgramInput;
 use libbpf_rs::ProgramType;
 use libbpf_rs::RawTracepointOpts;
+use libbpf_rs::TracepointCategory;
 use libbpf_rs::TracepointOpts;
 use libbpf_rs::UprobeOpts;
 use libbpf_rs::UsdtOpts;
@@ -1203,7 +1204,7 @@ fn test_object_ringbuf_with_closed_map() {
             let mut obj = get_test_object("tracepoint.bpf.o");
             let prog = get_prog_mut(&mut obj, "handle__tracepoint");
             let _link = prog
-                .attach_tracepoint("syscalls", "sys_enter_getpid")
+                .attach_tracepoint(TracepointCategory::Syscalls, "sys_enter_getpid")
                 .expect("failed to attach prog");
 
             let map = get_map_mut(&mut obj, "ringbuf");
@@ -1704,7 +1705,7 @@ fn test_object_tracepoint() {
     let mut obj = get_test_object("tracepoint.bpf.o");
     let prog = get_prog_mut(&mut obj, "handle__tracepoint");
     let _link = prog
-        .attach_tracepoint("syscalls", "sys_enter_getpid")
+        .attach_tracepoint(TracepointCategory::Syscalls, "sys_enter_getpid")
         .expect("failed to attach prog");
 
     let map = get_map_mut(&mut obj, "ringbuf");
@@ -1730,7 +1731,7 @@ fn test_object_tracepoint_with_opts() {
         ..TracepointOpts::default()
     };
     let _link = prog
-        .attach_tracepoint_with_opts("syscalls", "sys_enter_getpid", opts)
+        .attach_tracepoint_with_opts(TracepointCategory::Syscalls, "sys_enter_getpid", opts)
         .expect("failed to attach prog");
 
     let map = get_map_mut(&mut obj, "ringbuf");
@@ -1950,7 +1951,7 @@ fn test_object_perf_buffer_raw() {
         ..TracepointOpts::default()
     };
     let _link = prog
-        .attach_tracepoint_with_opts("syscalls", "sys_enter_getpid", opts)
+        .attach_tracepoint_with_opts(TracepointCategory::Syscalls, "sys_enter_getpid", opts)
         .expect("failed to attach prog");
 
     let map = get_map_mut(&mut obj, "pb");


Reviews:
user: login: danielocfb
body: Nice! Would you mind splitting this into two commits, first the introduction of the `tracepoint` module and the move of `TracepointOpts` and then the addition of `TracepointCategory`? Also, please take a look at my comment for the `Unknown` variant.
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-06T17:04:26Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T03:16:19Z
user: login: chenhengqi
body: Looks good overall. But first commit is incomplete, you can't not refer to TracepointCategory::Syscalls defined in the second commit.
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T05:45:28Z
user: login: chenhengqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T06:24:18Z
user: login: danielocfb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-07T17:39:39Z
user: login: chenhengqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T23:04:09Z
user: login: danielocfb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-11T15:49:57Z
user: login: danielocfb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-11T15:52:19Z
user: login: danielocfb
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-11T15:52:51Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T05:11:37Z
user: login: chenhengqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T05:28:50Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T06:05:59Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T06:27:21Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-12T06:34:27Z
user: login: d-e-s-o
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-12T13:28:48Z
user: login: d-e-s-o
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-12T16:32:57Z
user: login: d-e-s-o
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-12T16:33:59Z
user: login: chenhengqi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-13T01:47:50Z
user: login: syogaraj
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-13T09:19:09Z
user: login: d-e-s-o
body: Looks good to me now.
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-13T16:06:02Z
user: login: d-e-s-o
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-13T16:07:24Z

Review comments:
diff_hunk: @@ -0,0 +1,492 @@
+use std::mem::size_of;
+
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: ```suggestion
/// Represents categories of Linux kernel tracepoints.
///
/// This enum provides a list of tracepoint categories that can be used with
/// BPF programs to attach to various kernel events.
#[non_exhaustive]
#[repr(u32)]
#[derive(Debug)]
```
created_at: 2025-03-06T16:59:28Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,492 @@
+use std::mem::size_of;
+
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+pub enum TracepointCategory {
+    /// Alarm timer events.
+    Alarmtimer = 0,
+    /// AMD CPU events.
+    AmdCpu,
+    /// ASoC (ALSA System on Chip) events.
+    Asoc,
+    /// AVC (Access Vector Cache) events.
+    Avc,
+    /// Block layer events.
+    Block,
+    /// BPF test run events.
+    BpfTestRun,
+    /// BPF trace events.
+    BpfTrace,
+    /// Bridge network device events.
+    Bridge,
+    /// CFG80211 (wireless configuration) events.
+    Cfg80211,
+    /// Cgroup subsystem events.
+    Cgroup,
+    /// Clock subsystem events.
+    Clk,
+    /// Memory compaction events.
+    Compaction,
+    /// Context tracking events.
+    ContextTracking,
+    /// CPU hotplug events.
+    Cpuhp,
+    /// ChromeOS EC (Embedded Controller) events.
+    CrosEc,
+    /// Call state distribution events.
+    Csd,
+    /// Device events.
+    Dev,
+    /// Device frequency events.
+    Devfreq,
+    /// Device link events.
+    Devlink,
+    /// DMA fence events.
+    DmaFence,
+    /// Direct Rendering Manager events.
+    Drm,
+    /// Error reporting events.
+    ErrorReport,
+    /// Exception events.
+    Exceptions,
+    /// Ext4 filesystem events.
+    Ext4,
+    /// IPv4 FIB (Forwarding Information Base) events.
+    Fib,
+    /// IPv6 FIB events.
+    Fib6,
+    /// File lock events.
+    Filelock,
+    /// File map events.
+    Filemap,
+    /// File system DAX events.
+    FsDax,
+    /// Ftrace events.
+    Ftrace,
+    /// GPIO (General Purpose Input/Output) events.
+    Gpio,
+    /// GPU scheduler events.
+    GpuScheduler,
+    /// Handshake events.
+    Handshake,
+    /// High Definition Audio events.
+    Hda,
+    /// HDA (High Definition Audio) controller events.
+    HdaController,
+    /// Intel HDA events.
+    HdaIntel,
+    /// Huge memory events.
+    HugeMemory,
+    /// Hardware monitor events.
+    Hwmon,
+    /// Hyper-V events.
+    Hyperv,
+    /// I2C (Inter-Integrated Circuit) events.
+    I2c,
+    /// Intel Graphics events.
+    I915,
+    /// ICMP (Internet Control Message Protocol) events.
+    Icmp,
+    /// Initialization call events.
+    Initcall,
+    /// Intel AVS (Audio Voice Speech) events.
+    IntelAvs,
+    /// Intel IOMMU (Input Output Memory Management Unit) events.
+    IntelIommu,
+    /// Intel ISH (Integrated Sensor Hub) events.
+    IntelIsh,
+    /// Interconnect events.
+    Interconnect,
+    /// IOCost events.
+    Iocost,
+    /// I/O mapping events.
+    Iomap,
+    /// IOMMU events.
+    Iommu,
+    /// IO uring events.
+    IoUring,
+    /// Inter-processor interrupt events.
+    Ipi,
+    /// IRQ (Interrupt Request) events.
+    Irq,
+    /// IRQ matrix events.
+    IrqMatrix,
+    /// IRQ vector events.
+    IrqVectors,
+    /// Intel wireless events.
+    Iwlwifi,
+    /// Intel wireless data events.
+    IwlwifiData,
+    /// Intel wireless I/O events.
+    IwlwifiIo,
+    /// Intel wireless message events.
+    IwlwifiMsg,
+    /// Intel wireless uCode events.
+    IwlwifiUcode,
+    /// Journaling Block Device v2 events.
+    Jbd2,
+    /// Kernel memory events.
+    Kmem,
+    /// Kernel samepage merging events.
+    Ksm,
+    /// Kernel-based Virtual Machine events.
+    Kvm,
+    /// KVM MMU (Memory Management Unit) events.
+    Kvmmmu,
+    /// Libata (library for ATA) events.
+    Libata,
+    /// Locking events.
+    Lock,
+    /// MAC80211 (wireless networking) events.
+    Mac80211,
+    /// MAC80211 message events.
+    Mac80211Msg,
+    /// Maple tree events.
+    MapleTree,
+    /// Machine check events.
+    Mce,
+    /// MCTP (Management Component Transport Protocol) events.
+    Mctp,
+    /// MDIO (Management Data Input/Output) events.
+    Mdio,
+    /// Management Engine Interface events.
+    Mei,
+    /// Memory migration events.
+    Migrate,
+    /// Memory mapping events.
+    Mmap,
+    /// Memory mapping lock events.
+    MmapLock,
+    /// MultiMediaCard events.
+    Mmc,
+    /// Module events.
+    Module,
+    /// Multipath TCP events.
+    Mptcp,
+    /// Model-Specific Register events.
+    Msr,
+    /// NAPI (New API) events.
+    Napi,
+    /// Neighbor subsystem events.
+    Neigh,
+    /// Networking events.
+    Net,
+    /// Netlink protocol events.
+    Netlink,
+    /// Non-Maskable Interrupt events.
+    Nmi,
+    /// Notifier chain events.
+    Notifier,
+    /// NVMe (Non-Volatile Memory express) events.
+    Nvme,
+    /// Out of memory events.
+    Oom,
+    /// OS noise events.
+    Osnoise,
+    /// Page isolation events.
+    PageIsolation,
+    /// Page mapping events.
+    Pagemap,
+    /// Page pool events.
+    PagePool,
+    /// Per-CPU events.
+    Percpu,
+    /// Power management events.
+    Power,
+    /// Printk (kernel printk) events.
+    Printk,
+    /// PWM (Pulse Width Modulation) events.
+    Pwm,
+    /// Queueing discipline events.
+    Qdisc,
+    /// Qualcomm RTR events.
+    Qrtr,
+    /// Reliability, availability, and serviceability events.
+    Ras,
+    /// Raw syscall events.
+    RawSyscalls,
+    /// Read-Copy-Update events.
+    Rcu,
+    /// Register map events.
+    Regmap,
+    /// Voltage regulator events.
+    Regulator,
+    /// Resource control events.
+    Resctrl,
+    /// Runtime power management events.
+    Rpm,
+    /// Restartable sequences events.
+    Rseq,
+    /// Real-time clock events.
+    Rtc,
+    /// RISC-V events.
+    Rv,
+    /// Scheduler events.
+    Sched,
+    /// SCSI (Small Computer System Interface) events.
+    Scsi,
+    /// Secure Digital events.
+    Sd,
+    /// Signal events.
+    Signal,
+    /// Socket buffer events.
+    Skb,
+    /// SMBus (System Management Bus) events.
+    SmBus,
+    /// Socket events.
+    Sock,
+    /// Sound Open Firmware events.
+    Sof,
+    /// Sound Open Firmware Intel events.
+    SofIntel,
+    /// SPI (Serial Peripheral Interface) events.
+    Spi,
+    /// Software I/O TLB events.
+    SwIotlb,
+    /// Synchronization trace events.
+    SyncTrace,
+    /// System call events.
+    Syscalls,
+    /// Task events.
+    Task,
+    /// TCP (Transmission Control Protocol) events.
+    Tcp,
+    /// Thermal management events.
+    Thermal,
+    /// Thermal power allocator events.
+    ThermalPowerAllocator,
+    /// Transparent huge pages events.
+    Thp,
+    /// Thunderbolt events.
+    Thunderbolt,
+    /// Timer events.
+    Timer,
+    /// Timer migration events.
+    TimerMigration,
+    /// Translation Lookaside Buffer events.
+    Tlb,
+    /// Transport Layer Security events.
+    Tls,
+    /// Universal Serial Bus Type-C Connector System Software Interface events.
+    Ucsi,
+    /// UDP (User Datagram Protocol) events.
+    Udp,
+    /// V4L2 (Video for Linux 2) events.
+    V4l2,
+    /// Video buffer 2 events.
+    Vb2,
+    /// Virtual memory allocation events.
+    Vmalloc,
+    /// Virtual memory scanner events.
+    Vmscan,
+    /// Virtual syscall events.
+    Vsyscall,
+    /// Watchdog events.
+    Watchdog,
+    /// Writeback throttling events.
+    Wbt,
+    /// Work queue events.
+    Workqueue,
+    /// Writeback events.
+    Writeback,
+    /// x86 floating-point unit events.
+    X86Fpu,
+    /// Express Data Path events.
+    Xdp,
+    /// Intel Xe graphics events.
+    Xe,
+    /// Xen hypervisor events.
+    Xen,
+    /// xHCI Host Controller events.
+    XhciHcd,
+    /// Unknown,
+    Unknown,
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: The way I see it this variant doesn't make much sense here. This is user supplied data and the kernel doesn't understand `unknown`.
I think we should replace this with a variant that allows for passing in an arbitrary string, similar to what was possible before. This way, even if a new variant is added in the kernel but hasn't been hoked up to `libbpf-rs` yet, users would still be able to attach the tracepoint.
created_at: 2025-03-06T17:03:57Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,492 @@
+use std::mem::size_of;
+
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+pub enum TracepointCategory {
+    /// Alarm timer events.
+    Alarmtimer = 0,
+    /// AMD CPU events.
+    AmdCpu,
+    /// ASoC (ALSA System on Chip) events.
+    Asoc,
+    /// AVC (Access Vector Cache) events.
+    Avc,
+    /// Block layer events.
+    Block,
+    /// BPF test run events.
+    BpfTestRun,
+    /// BPF trace events.
+    BpfTrace,
+    /// Bridge network device events.
+    Bridge,
+    /// CFG80211 (wireless configuration) events.
+    Cfg80211,
+    /// Cgroup subsystem events.
+    Cgroup,
+    /// Clock subsystem events.
+    Clk,
+    /// Memory compaction events.
+    Compaction,
+    /// Context tracking events.
+    ContextTracking,
+    /// CPU hotplug events.
+    Cpuhp,
+    /// ChromeOS EC (Embedded Controller) events.
+    CrosEc,
+    /// Call state distribution events.
+    Csd,
+    /// Device events.
+    Dev,
+    /// Device frequency events.
+    Devfreq,
+    /// Device link events.
+    Devlink,
+    /// DMA fence events.
+    DmaFence,
+    /// Direct Rendering Manager events.
+    Drm,
+    /// Error reporting events.
+    ErrorReport,
+    /// Exception events.
+    Exceptions,
+    /// Ext4 filesystem events.
+    Ext4,
+    /// IPv4 FIB (Forwarding Information Base) events.
+    Fib,
+    /// IPv6 FIB events.
+    Fib6,
+    /// File lock events.
+    Filelock,
+    /// File map events.
+    Filemap,
+    /// File system DAX events.
+    FsDax,
+    /// Ftrace events.
+    Ftrace,
+    /// GPIO (General Purpose Input/Output) events.
+    Gpio,
+    /// GPU scheduler events.
+    GpuScheduler,
+    /// Handshake events.
+    Handshake,
+    /// High Definition Audio events.
+    Hda,
+    /// HDA (High Definition Audio) controller events.
+    HdaController,
+    /// Intel HDA events.
+    HdaIntel,
+    /// Huge memory events.
+    HugeMemory,
+    /// Hardware monitor events.
+    Hwmon,
+    /// Hyper-V events.
+    Hyperv,
+    /// I2C (Inter-Integrated Circuit) events.
+    I2c,
+    /// Intel Graphics events.
+    I915,
+    /// ICMP (Internet Control Message Protocol) events.
+    Icmp,
+    /// Initialization call events.
+    Initcall,
+    /// Intel AVS (Audio Voice Speech) events.
+    IntelAvs,
+    /// Intel IOMMU (Input Output Memory Management Unit) events.
+    IntelIommu,
+    /// Intel ISH (Integrated Sensor Hub) events.
+    IntelIsh,
+    /// Interconnect events.
+    Interconnect,
+    /// IOCost events.
+    Iocost,
+    /// I/O mapping events.
+    Iomap,
+    /// IOMMU events.
+    Iommu,
+    /// IO uring events.
+    IoUring,
+    /// Inter-processor interrupt events.
+    Ipi,
+    /// IRQ (Interrupt Request) events.
+    Irq,
+    /// IRQ matrix events.
+    IrqMatrix,
+    /// IRQ vector events.
+    IrqVectors,
+    /// Intel wireless events.
+    Iwlwifi,
+    /// Intel wireless data events.
+    IwlwifiData,
+    /// Intel wireless I/O events.
+    IwlwifiIo,
+    /// Intel wireless message events.
+    IwlwifiMsg,
+    /// Intel wireless uCode events.
+    IwlwifiUcode,
+    /// Journaling Block Device v2 events.
+    Jbd2,
+    /// Kernel memory events.
+    Kmem,
+    /// Kernel samepage merging events.
+    Ksm,
+    /// Kernel-based Virtual Machine events.
+    Kvm,
+    /// KVM MMU (Memory Management Unit) events.
+    Kvmmmu,
+    /// Libata (library for ATA) events.
+    Libata,
+    /// Locking events.
+    Lock,
+    /// MAC80211 (wireless networking) events.
+    Mac80211,
+    /// MAC80211 message events.
+    Mac80211Msg,
+    /// Maple tree events.
+    MapleTree,
+    /// Machine check events.
+    Mce,
+    /// MCTP (Management Component Transport Protocol) events.
+    Mctp,
+    /// MDIO (Management Data Input/Output) events.
+    Mdio,
+    /// Management Engine Interface events.
+    Mei,
+    /// Memory migration events.
+    Migrate,
+    /// Memory mapping events.
+    Mmap,
+    /// Memory mapping lock events.
+    MmapLock,
+    /// MultiMediaCard events.
+    Mmc,
+    /// Module events.
+    Module,
+    /// Multipath TCP events.
+    Mptcp,
+    /// Model-Specific Register events.
+    Msr,
+    /// NAPI (New API) events.
+    Napi,
+    /// Neighbor subsystem events.
+    Neigh,
+    /// Networking events.
+    Net,
+    /// Netlink protocol events.
+    Netlink,
+    /// Non-Maskable Interrupt events.
+    Nmi,
+    /// Notifier chain events.
+    Notifier,
+    /// NVMe (Non-Volatile Memory express) events.
+    Nvme,
+    /// Out of memory events.
+    Oom,
+    /// OS noise events.
+    Osnoise,
+    /// Page isolation events.
+    PageIsolation,
+    /// Page mapping events.
+    Pagemap,
+    /// Page pool events.
+    PagePool,
+    /// Per-CPU events.
+    Percpu,
+    /// Power management events.
+    Power,
+    /// Printk (kernel printk) events.
+    Printk,
+    /// PWM (Pulse Width Modulation) events.
+    Pwm,
+    /// Queueing discipline events.
+    Qdisc,
+    /// Qualcomm RTR events.
+    Qrtr,
+    /// Reliability, availability, and serviceability events.
+    Ras,
+    /// Raw syscall events.
+    RawSyscalls,
+    /// Read-Copy-Update events.
+    Rcu,
+    /// Register map events.
+    Regmap,
+    /// Voltage regulator events.
+    Regulator,
+    /// Resource control events.
+    Resctrl,
+    /// Runtime power management events.
+    Rpm,
+    /// Restartable sequences events.
+    Rseq,
+    /// Real-time clock events.
+    Rtc,
+    /// RISC-V events.
+    Rv,
+    /// Scheduler events.
+    Sched,
+    /// SCSI (Small Computer System Interface) events.
+    Scsi,
+    /// Secure Digital events.
+    Sd,
+    /// Signal events.
+    Signal,
+    /// Socket buffer events.
+    Skb,
+    /// SMBus (System Management Bus) events.
+    SmBus,
+    /// Socket events.
+    Sock,
+    /// Sound Open Firmware events.
+    Sof,
+    /// Sound Open Firmware Intel events.
+    SofIntel,
+    /// SPI (Serial Peripheral Interface) events.
+    Spi,
+    /// Software I/O TLB events.
+    SwIotlb,
+    /// Synchronization trace events.
+    SyncTrace,
+    /// System call events.
+    Syscalls,
+    /// Task events.
+    Task,
+    /// TCP (Transmission Control Protocol) events.
+    Tcp,
+    /// Thermal management events.
+    Thermal,
+    /// Thermal power allocator events.
+    ThermalPowerAllocator,
+    /// Transparent huge pages events.
+    Thp,
+    /// Thunderbolt events.
+    Thunderbolt,
+    /// Timer events.
+    Timer,
+    /// Timer migration events.
+    TimerMigration,
+    /// Translation Lookaside Buffer events.
+    Tlb,
+    /// Transport Layer Security events.
+    Tls,
+    /// Universal Serial Bus Type-C Connector System Software Interface events.
+    Ucsi,
+    /// UDP (User Datagram Protocol) events.
+    Udp,
+    /// V4L2 (Video for Linux 2) events.
+    V4l2,
+    /// Video buffer 2 events.
+    Vb2,
+    /// Virtual memory allocation events.
+    Vmalloc,
+    /// Virtual memory scanner events.
+    Vmscan,
+    /// Virtual syscall events.
+    Vsyscall,
+    /// Watchdog events.
+    Watchdog,
+    /// Writeback throttling events.
+    Wbt,
+    /// Work queue events.
+    Workqueue,
+    /// Writeback events.
+    Writeback,
+    /// x86 floating-point unit events.
+    X86Fpu,
+    /// Express Data Path events.
+    Xdp,
+    /// Intel Xe graphics events.
+    Xe,
+    /// Xen hypervisor events.
+    Xen,
+    /// xHCI Host Controller events.
+    XhciHcd,
+    /// Unknown,
+    Unknown,
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: Understood. Updated with this change.
created_at: 2025-03-07T03:16:19Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: chenhengqi
body: A second thought. Could we just add some generic categories ? No arch-specific, No driver-specific.
See https://github.com/torvalds/linux/tree/master/include/trace/events
created_at: 2025-03-07T06:15:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
path: libbpf-rs/src/tracepoint.rs
user: login: chenhengqi
body: repr(u32) does not make sense with `Custom(String)` below.
The `non_exhaustive` prevents clippy from check non-exhaustive matches in AsRef<str> below.

Could we remove this ?

created_at: 2025-03-07T06:24:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: You are saying remove everything that is arch or driver specific? I have no strong preference, but to me that seems like a moving target: over time something may become generic. It also seems somewhat arbitrary and ultimately we just provide possible values, but runtime detection by the kernel should have the last say anyway. So personally I guess I'd err on the side of making more values available.
created_at: 2025-03-07T17:39:39Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: chenhengqi
body: This list seems taken from some random running machine, especially the amdcpu thing.

There are tens of arch and thousands of drivers, trying to keep them here also a moving target.
created_at: 2025-03-07T23:04:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: I see. In that case, fair enough, perhaps it's best to trim it down. @syogaraj what do you think? Let's only provide variants for core categories?
created_at: 2025-03-11T15:49:57Z
author_association: COLLABORATOR
diff_hunk: @@ -52,3 +52,466 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: Let's mark this type as non-exhaustive similar to what we do for the `MapType`. https://github.com/libbpf/libbpf-rs/blob/9d617b054515be03b7dc37897e511a4574197de1/libbpf-rs/src/map.rs#L1211-L1216
created_at: 2025-03-11T15:52:19Z
author_association: COLLABORATOR
diff_hunk: @@ -52,3 +52,466 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[derive(Debug)]
path: libbpf-rs/src/tracepoint.rs
user: login: danielocfb
body: Please also auto-derive a `Clone` impl.
created_at: 2025-03-11T15:52:51Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: > This list seems taken from some random running machine, especially the amdcpu thing.

This list is taken from a machine that is running on Intel CPU (11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz) with kernel v6.11.0-17. Don't know why amdcpu is listed. 

> what do you think? Let's only provide variants for core categories?

Even with numerous non-core variants, users can still utilize the `Custom` category as needed for those categories that are missing. Moreover, reducing the list now would entail extra work and additional checks, which we can avoid. I'm comfortable proceeding with the current list. Your thoughts on this? 
created_at: 2025-03-12T05:11:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: chenhengqi
body: Nope, this should be easy. Just grep `TRACE_SYSTEM` from https://github.com/torvalds/linux/tree/master/include/trace/events
created_at: 2025-03-12T05:28:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: @chenhengqi Thanks for the info. I tried this, but still amd, intel kinds are reported. 
```
amdxdna.h:#define TRACE_SYSTEM amdxdna
intel_ifs.h:#define TRACE_SYSTEM intel_ifs
intel_ish.h:#define TRACE_SYSTEM intel_ish
intel-sst.h:#define TRACE_SYSTEM intel-sst
intel-sst.h:#define TRACE_SYSTEM_VAR intel_sst
sof_intel.h:#define TRACE_SYSTEM sof_intel
```
Also, found some (ex: `9p.h`, `fsi_master_aspeed.h`) that are not present in my system. (Please correct me if I'm wrong). If those are core-variants, guess it should be available for all systems?
created_at: 2025-03-12T06:05:59Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,3 +52,466 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[derive(Debug)]
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: added..
created_at: 2025-03-12T06:27:20Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,3 +52,466 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: @chenhengqi suggested that we remove this non_exhaustive check [earlier](https://github.com/libbpf/libbpf-rs/pull/1114#discussion_r1984519742). Added this again. 
created_at: 2025-03-12T06:34:27Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
path: libbpf-rs/src/tracepoint.rs
user: login: d-e-s-o
body: > The `non_exhaustive` prevents clippy from check non-exhaustive matches in AsRef below.
> 
> Could we remove this ?

The problem with making the enum exhaustive is that it will pose a compatibility hazard: everytime we add a new variant we introduce a breaking change. We want to move towards a more stable API surface and so I think making this (and most other) `enum`s non-exhaustive will be a requirement for that.
created_at: 2025-03-12T13:28:48Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: d-e-s-o
body: On
```
commit ffd294d346d185b70e28b1a28abe367bbfe53c04 (HEAD -> master, tag: v6.13)
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   2025-01-19 15:51:45 -0800

    Linux 6.13
```

The following:
```
$ rg -s '#define TRACE_SYSTEM ' -t c include/trace/events/ | awk '{print $3}' | sort | uniq | sed 's@.*@/tmp/rust-build-artifacts/tmp/ccase/target/debug/ccase -t pascal \0@g' > /tmp/test.sh
$ sh /tmp/test.sh
```

Produces:
```
9P
Afs
Alarmtimer
Asoc
Avc
Bcache
Block
BpfTestRun
Bridge
Btrfs
Cachefiles
Cgroup
Clk
Cma
Compaction
ContextTracking
Cpuhp
Csd
Damon
Devfreq
Devlink
Dlm
Dma
DmaFence
Erofs
ErrorReport
Ext4
F2Fs
Fib
Fib6
Filelock
Filemap
Fscache
FsDax
Fsi
FsiMasterAspeed
FsiMasterAstCf
FsiMasterGpio
FsiMasterI2Cr
Gpio
GpuMem
Habanalabs
Handshake
Host1X
HugeMemory
Hugetlbfs
Hwmon
HwPressure
I2C
I2CSlave
IbMad
IbUmad
Icmp
Initcall
IntelIfs
IntelIsh
IntelSst
Iocost
Iommu
IoUring
Ipi
Irq
IrqMatrix
Iscsi
Jbd2
Kmem
Ksm
Kvm
Kyber
Libata
Lock
MapleTree
Mce
Mctp
Mdio
Memcg
Migrate
Mlxsw
Mmap
MmapLock
Mmc
Module
Mptcp
Napi
Nbd
Neigh
Net
Netfs
Netlink
Nilfs2
Nmi
Notifier
Objagg
Oom
Osnoise
PageIsolation
Pagemap
PagePool
PageRef
Percpu
Power
Preemptirq
Printk
Pwc
Pwm
Qdisc
Qla
Qrtr
RawSyscalls
Rcu
RdmaCore
Regulator
Rpcgss
Rpcrdma
Rpm
Rseq
Rtc
RustSample
Rv
Rwmmio
Rxrpc
Sched
SchedExt
Scmi
Scsi
Sctp
Signal
Siox
Skb
Smbus
Sock
Sof
SofIntel
Spi
Spmi
Sunrpc
Sunvnet
Swiotlb
Target
Task
Tcp
TegraApbDma
Thp
Timer
TimerMigration
Timestamp
Tlb
Udp
V4L2
Vb2
Vmalloc
Vmscan
Vsock
Watchdog
Wbt
Workqueue
Writeback
Xdp
Xen
```

Does this look like a reasonable list to you @chenhengqi ?
created_at: 2025-03-12T16:32:56Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: d-e-s-o
body: > If those are core-variants, guess it should be available for all systems?

I'd guess it depends what you mean by "available". Presumably you could still compile them out by omitting various `CONFIG_*` options.
created_at: 2025-03-12T16:33:59Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: chenhengqi
body: I am with the list above. An allyesconfig should compile all this in.
created_at: 2025-03-13T01:47:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,493 @@
+use std::mem::size_of;
+
+
+/// Options to optionally be provided when attaching to a tracepoint.
+#[derive(Clone, Debug, Default)]
+pub struct TracepointOpts {
+    /// Custom user-provided value accessible through `bpf_get_attach_cookie`.
+    pub cookie: u64,
+    #[doc(hidden)]
+    pub _non_exhaustive: (),
+}
+
+impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
+    fn from(opts: TracepointOpts) -> Self {
+        let TracepointOpts {
+            cookie,
+            _non_exhaustive,
+        } = opts;
+
+        #[allow(clippy::needless_update)]
+        libbpf_sys::bpf_tracepoint_opts {
+            sz: size_of::<Self>() as _,
+            bpf_cookie: cookie,
+            // bpf_tracepoint_opts might have padding fields on some platform
+            ..Default::default()
+        }
+    }
+}
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[repr(u32)]
+#[derive(Debug)]
+pub enum TracepointCategory {
path: libbpf-rs/src/tracepoint.rs
user: login: syogaraj
body: I've pushed the changes with the tracepoint categories shared by @d-e-s-o. However, the "syscalls" and "bpf_trace_event" categories were not in the generated list, so I added these two as extras. I hope this is fine.  
created_at: 2025-03-13T09:19:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -52,3 +52,506 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[derive(Debug, Clone)]
+pub enum TracepointCategory {
+    /// 9P protocol events.
+    P9,
path: libbpf-rs/src/tracepoint.rs
user: login: d-e-s-o
body: Should be `9P`. Will fix it up.
created_at: 2025-03-13T16:05:56Z
author_association: COLLABORATOR
diff_hunk: @@ -52,3 +52,506 @@ impl From<RawTracepointOpts> for libbpf_sys::bpf_raw_tracepoint_opts {
         }
     }
 }
+
+
+/// Represents categories of Linux kernel tracepoints.
+///
+/// This enum provides a list of tracepoint categories that can be used with
+/// BPF programs to attach to various kernel events.
+#[non_exhaustive]
+#[derive(Debug, Clone)]
+pub enum TracepointCategory {
+    /// 9P protocol events.
+    P9,
path: libbpf-rs/src/tracepoint.rs
user: login: d-e-s-o
body: Haha, okay, I see why you chose that now.
created_at: 2025-03-13T16:07:24Z
author_association: COLLABORATOR

PR comments:
user: login: danielocfb
created_at: 2025-03-07T17:33:05Z
body: > But first commit is incomplete, you can't not refer to TracepointCategory::Syscalls defined in the second commit.

Yeah, that's a good catch. Can you please fix that up and make sure everything builds at each point, @syogaraj ?
author_association: COLLABORATOR
user: login: danielocfb
created_at: 2025-03-07T18:47:45Z
body: I see there are some conflicts with the merged https://github.com/libbpf/libbpf-rs/pull/1115. I believe they should be fairly mechanical to resolve, though. Sorry about that, but we'd have conflicts either way.
author_association: COLLABORATOR
user: login: syogaraj
created_at: 2025-03-08T04:15:51Z
body: > > But first commit is incomplete, you can't not refer to TracepointCategory::Syscalls defined in the second commit.
> 
> Yeah, that's a good catch. Can you please fix that up and make sure everything builds at each point, @syogaraj ?

Missed this @chenhengqi. fixed them now. @danielocfb


> I see there are some conflicts with the merged #1115. I believe they should be fairly mechanical to resolve, though. Sorry about that, but we'd have conflicts either way.

@danielocfb, Resolved the merge conflict from #1115 and moved `RawTracepointOpts` to `tracepoint` module.
author_association: CONTRIBUTOR
user: login: danielocfb
created_at: 2025-03-10T15:18:39Z
body: Thanks! Will take another look tomorrow.
author_association: COLLABORATOR