/
rustwizard
/
pgtrace
Обзор
Документация
Войти
/
rustwizard
/
pgtrace
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
internal/bpf/offcpu_bpfeb.go
178 строк
4 KB
Rust Wizard
fix(offcpu): capture stack at block time via kprobe:schedule
08 авг 2026, 10:55
Верифицирован
08 авг 2026, 10:55
d84b1f0
Код
Авторство
О чём код?
// Code generated by bpf2go; DO NOT EDIT. //go:build mips || mips64 || ppc64 || s390x package bpf import ( "bytes" _ "embed" "fmt" "io" "structs" "github.com/cilium/ebpf" ) type offcpuOffCpuStart struct { _ structs.HostLayout StartTs uint64 Stack [8]uint64 } type offcpuOffcpuConfig struct { _ structs.HostLayout ThresholdNs uint64 Comm [16]int8 } type offcpuOffcpuEvent struct { _ structs.HostLayout Pid uint32 WaitType uint32 DurationNs uint64 Ts uint64 Stack [8]uint64 } // Names of all BPF objects in the ELF. // // Used for safe lookups in a Collection or CollectionSpec. const ( offcpuMapOffCpuStart = "off_cpu_start" offcpuMapOffcpuConfigMap = "offcpu_config_map" offcpuMapOffcpuEvents = "offcpu_events" offcpuProgTraceSchedSwitch = "trace_sched_switch" offcpuProgTraceSchedule = "trace_schedule" offcpuVarOffcpuEvent = "_offcpu_event" ) // loadOffcpu returns the embedded CollectionSpec for offcpu. func loadOffcpu() (*ebpf.CollectionSpec, error) { reader := bytes.NewReader(_OffcpuBytes) spec, err := ebpf.LoadCollectionSpecFromReader(reader) if err != nil { return nil, fmt.Errorf("can't load offcpu: %w", err) } return spec, err } // loadOffcpuObjects loads offcpu and converts it into a struct. // // The following types are suitable as obj argument: // // *offcpuObjects // *offcpuPrograms // *offcpuMaps // // See ebpf.CollectionSpec.LoadAndAssign documentation for details. func loadOffcpuObjects(obj any, opts *ebpf.CollectionOptions) error { spec, err := loadOffcpu() if err != nil { return err } return spec.LoadAndAssign(obj, opts) } // offcpuSpecs contains maps and programs before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type offcpuSpecs struct { offcpuProgramSpecs offcpuMapSpecs offcpuVariableSpecs } // offcpuProgramSpecs contains programs before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type offcpuProgramSpecs struct { TraceSchedSwitch *ebpf.ProgramSpec `ebpf:"trace_sched_switch"` TraceSchedule *ebpf.ProgramSpec `ebpf:"trace_schedule"` } // offcpuMapSpecs contains maps before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type offcpuMapSpecs struct { OffCpuStart *ebpf.MapSpec `ebpf:"off_cpu_start"` OffcpuConfigMap *ebpf.MapSpec `ebpf:"offcpu_config_map"` OffcpuEvents *ebpf.MapSpec `ebpf:"offcpu_events"` } // offcpuVariableSpecs contains global variables before they are loaded into the kernel. // // It can be passed ebpf.CollectionSpec.Assign. type offcpuVariableSpecs struct { OffcpuEvent *ebpf.VariableSpec `ebpf:"_offcpu_event"` } // offcpuObjects contains all objects after they have been loaded into the kernel. // // It can be passed to loadOffcpuObjects or ebpf.CollectionSpec.LoadAndAssign. type offcpuObjects struct { offcpuPrograms offcpuMaps offcpuVariables } func (o *offcpuObjects) Close() error { return _OffcpuClose( &o.offcpuPrograms, &o.offcpuMaps, ) } // offcpuMaps contains all maps after they have been loaded into the kernel. // // It can be passed to loadOffcpuObjects or ebpf.CollectionSpec.LoadAndAssign. type offcpuMaps struct { OffCpuStart *ebpf.Map `ebpf:"off_cpu_start"` OffcpuConfigMap *ebpf.Map `ebpf:"offcpu_config_map"` OffcpuEvents *ebpf.Map `ebpf:"offcpu_events"` } func (m *offcpuMaps) Close() error { return _OffcpuClose( m.OffCpuStart, m.OffcpuConfigMap, m.OffcpuEvents, ) } // offcpuVariables contains all global variables after they have been loaded into the kernel. // // It can be passed to loadOffcpuObjects or ebpf.CollectionSpec.LoadAndAssign. type offcpuVariables struct { OffcpuEvent *ebpf.Variable `ebpf:"_offcpu_event"` } // offcpuPrograms contains all programs after they have been loaded into the kernel. // // It can be passed to loadOffcpuObjects or ebpf.CollectionSpec.LoadAndAssign. type offcpuPrograms struct { TraceSchedSwitch *ebpf.Program `ebpf:"trace_sched_switch"` TraceSchedule *ebpf.Program `ebpf:"trace_schedule"` } func (p *offcpuPrograms) Close() error { return _OffcpuClose( p.TraceSchedSwitch, p.TraceSchedule, ) } func _OffcpuClose(closers ...io.Closer) error { for _, closer := range closers { if err := closer.Close(); err != nil { return err } } return nil } // Do not access this directly. // //go:embed offcpu_bpfeb.o var _OffcpuBytes []byte