1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
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)]
Self {
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)]
Self {
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 {
Self::P9 => "9p",
Self::Afs => "afs",
Self::Alarmtimer => "alarmtimer",
Self::Asoc => "asoc",
Self::Avc => "avc",
Self::Bcache => "bcache",
Self::Block => "block",
Self::BpfTestRun => "bpf_test_run",
Self::BpfTrace => "bpf_trace",
Self::Bridge => "bridge",
Self::Btrfs => "btrfs",
Self::Cachefiles => "cachefiles",
Self::Cgroup => "cgroup",
Self::Clk => "clk",
Self::Cma => "cma",
Self::Compaction => "compaction",
Self::ContextTracking => "context_tracking",
Self::Cpuhp => "cpuhp",
Self::Csd => "csd",
Self::Damon => "damon",
Self::Devfreq => "devfreq",
Self::Devlink => "devlink",
Self::Dlm => "dlm",
Self::Dma => "dma",
Self::DmaFence => "dma_fence",
Self::Erofs => "erofs",
Self::ErrorReport => "error_report",
Self::Ext4 => "ext4",
Self::F2Fs => "f2fs",
Self::Fib => "fib",
Self::Fib6 => "fib6",
Self::Filelock => "filelock",
Self::Filemap => "filemap",
Self::Fscache => "fscache",
Self::FsDax => "fs_dax",
Self::Fsi => "fsi",
Self::FsiMasterAspeed => "fsi_master_aspeed",
Self::FsiMasterAstCf => "fsi_master_ast_cf",
Self::FsiMasterGpio => "fsi_master_gpio",
Self::FsiMasterI2Cr => "fsi_master_i2cr",
Self::Gpio => "gpio",
Self::GpuMem => "gpu_mem",
Self::Habanalabs => "habanalabs",
Self::Handshake => "handshake",
Self::Host1X => "host1x",
Self::HugeMemory => "huge_memory",
Self::Hugetlbfs => "hugetlbfs",
Self::Hwmon => "hwmon",
Self::HwPressure => "hw_pressure",
Self::I2C => "i2c",
Self::I2CSlave => "i2c_slave",
Self::IbMad => "ib_mad",
Self::IbUmad => "ib_umad",
Self::Icmp => "icmp",
Self::Initcall => "initcall",
Self::IntelIfs => "intel_ifs",
Self::IntelIsh => "intel_ish",
Self::IntelSst => "intel-sst",
Self::Iocost => "iocost",
Self::Iommu => "iommu",
Self::IoUring => "io_uring",
Self::Ipi => "ipi",
Self::Irq => "irq",
Self::IrqMatrix => "irq_matrix",
Self::Iscsi => "iscsi",
Self::Jbd2 => "jbd2",
Self::Kmem => "kmem",
Self::Ksm => "ksm",
Self::Kvm => "kvm",
Self::Kyber => "kyber",
Self::Libata => "libata",
Self::Lock => "lock",
Self::MapleTree => "maple_tree",
Self::Mce => "mce",
Self::Mctp => "mctp",
Self::Mdio => "mdio",
Self::Memcg => "memcg",
Self::Migrate => "migrate",
Self::Mlxsw => "mlxsw",
Self::Mmap => "mmap",
Self::MmapLock => "mmap_lock",
Self::Mmc => "mmc",
Self::Module => "module",
Self::Mptcp => "mptcp",
Self::Napi => "napi",
Self::Nbd => "nbd",
Self::Neigh => "neigh",
Self::Net => "net",
Self::Netfs => "netfs",
Self::Netlink => "netlink",
Self::Nilfs2 => "nilfs2",
Self::Nmi => "nmi",
Self::Notifier => "notifier",
Self::Objagg => "objagg",
Self::Oom => "oom",
Self::Osnoise => "osnoise",
Self::PageIsolation => "page_isolation",
Self::Pagemap => "pagemap",
Self::PagePool => "page_pool",
Self::PageRef => "page_ref",
Self::Percpu => "percpu",
Self::Power => "power",
Self::Preemptirq => "preemptirq",
Self::Printk => "printk",
Self::Pwc => "pwc",
Self::Pwm => "pwm",
Self::Qdisc => "qdisc",
Self::Qla => "qla",
Self::Qrtr => "qrtr",
Self::RawSyscalls => "raw_syscalls",
Self::Rcu => "rcu",
Self::RdmaCore => "rdma_core",
Self::Regulator => "regulator",
Self::Rpcgss => "rpcgss",
Self::Rpcrdma => "rpcrdma",
Self::Rpm => "rpm",
Self::Rseq => "rseq",
Self::Rtc => "rtc",
Self::RustSample => "rust_sample",
Self::Rv => "rv",
Self::Rwmmio => "rwmmio",
Self::Rxrpc => "rxrpc",
Self::Sched => "sched",
Self::SchedExt => "sched_ext",
Self::Scmi => "scmi",
Self::Scsi => "scsi",
Self::Sctp => "sctp",
Self::Signal => "signal",
Self::Siox => "siox",
Self::Skb => "skb",
Self::Smbus => "smbus",
Self::Sock => "sock",
Self::Sof => "sof",
Self::SofIntel => "sof_intel",
Self::Spi => "spi",
Self::Spmi => "spmi",
Self::Sunrpc => "sunrpc",
Self::Sunvnet => "sunvnet",
Self::Swiotlb => "swiotlb",
Self::Syscalls => "syscalls",
Self::Target => "target",
Self::Task => "task",
Self::Tcp => "tcp",
Self::TegraApbDma => "tegra_apb_dma",
Self::Thp => "thp",
Self::Timer => "timer",
Self::TimerMigration => "timer_migration",
Self::Timestamp => "timestamp",
Self::Tlb => "tlb",
Self::Udp => "udp",
Self::V4L2 => "v4l2",
Self::Vb2 => "vb2",
Self::Vmalloc => "vmalloc",
Self::Vmscan => "vmscan",
Self::Vsock => "vsock",
Self::Watchdog => "watchdog",
Self::Wbt => "wbt",
Self::Workqueue => "workqueue",
Self::Writeback => "writeback",
Self::Xdp => "xdp",
Self::Xen => "xen",
Self::Custom(category) => category,
}
}
}