cpu_bpfel.go - Katyusha's blog
mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
cpu_bpfel.go
Go Source File · 136 lines
cpu_bpfel.go
// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64
package collector
import (
"bytes"
_ "embed"
"fmt"
"io"
"github.com/cilium/ebpf"
)
type cpuTaskStat struct {
RunNs uint64
RunqNs uint64
Ctx uint64
Comm [16]int8
}
// loadCpu returns the embedded CollectionSpec for cpu.
func loadCpu() (*ebpf.CollectionSpec, error) {
reader := bytes.NewReader(_CpuBytes)
spec, err := ebpf.LoadCollectionSpecFromReader(reader)
if err != nil {
return nil, fmt.Errorf("can't load cpu: %w", err)
}
return spec, err
}
// loadCpuObjects loads cpu and converts it into a struct.
//
// The following types are suitable as obj argument:
//
// *cpuObjects
// *cpuPrograms
// *cpuMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadCpuObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
spec, err := loadCpu()
if err != nil {
return err
}
return spec.LoadAndAssign(obj, opts)
}
// cpuSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type cpuSpecs struct {
cpuProgramSpecs
cpuMapSpecs
}
// cpuSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type cpuProgramSpecs struct {
HandleSwitch *ebpf.ProgramSpec `ebpf:"handle_switch"`
HandleWakeup *ebpf.ProgramSpec `ebpf:"handle_wakeup"`
}
// cpuMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type cpuMapSpecs struct {
OncpuStart *ebpf.MapSpec `ebpf:"oncpu_start"`
Stats *ebpf.MapSpec `ebpf:"stats"`
WakeupTs *ebpf.MapSpec `ebpf:"wakeup_ts"`
}
// cpuObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadCpuObjects or ebpf.CollectionSpec.LoadAndAssign.
type cpuObjects struct {
cpuPrograms
cpuMaps
}
func (o *cpuObjects) Close() error {
return _CpuClose(
&o.cpuPrograms,
&o.cpuMaps,
)
}
// cpuMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadCpuObjects or ebpf.CollectionSpec.LoadAndAssign.
type cpuMaps struct {
OncpuStart *ebpf.Map `ebpf:"oncpu_start"`
Stats *ebpf.Map `ebpf:"stats"`
WakeupTs *ebpf.Map `ebpf:"wakeup_ts"`
}
func (m *cpuMaps) Close() error {
return _CpuClose(
m.OncpuStart,
m.Stats,
m.WakeupTs,
)
}
// cpuPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadCpuObjects or ebpf.CollectionSpec.LoadAndAssign.
type cpuPrograms struct {
HandleSwitch *ebpf.Program `ebpf:"handle_switch"`
HandleWakeup *ebpf.Program `ebpf:"handle_wakeup"`
}
func (p *cpuPrograms) Close() error {
return _CpuClose(
p.HandleSwitch,
p.HandleWakeup,
)
}
func _CpuClose(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 cpu_bpfel.o
var _CpuBytes []byte

目录