core

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrioHighMin is the minimum (highest) priority for preemptive tasks
	PrioHighMin = 0
	// PrioHighMax is the maximum priority for preemptive tasks (0-9 can preempt)
	PrioHighMax = 9
	// PrioMedMin is the minimum priority for vtime-reduced tasks
	PrioMedMin = 10
	// PrioMedMax is the maximum priority for vtime-reduced tasks
	PrioMedMax = 20
)

Priority level constants

View Source
const (
	UEI_REASON_LEN = 128
	UEI_MSG_LEN    = 1024
)
View Source
const (
	RL_CPU_ANY = 1 << 20
)

Variables

This section is empty.

Functions

func GetUserSchedPid

func GetUserSchedPid() int

func IsSMTActive

func IsSMTActive() (bool, error)

func KhugepagePid

func KhugepagePid() uint32

KhugepagePid finds and returns the PID of the khugepaged process

func LoadSkel

func LoadSkel() unsafe.Pointer

func NotifyComplete

func NotifyComplete(nr_pending uint64) error

Types

type BssData

type BssData struct {
	Nr_running            uint64 `json:"nr_running"`            // Number of tasks currently running in the userspace scheduler
	Nr_queued             uint64 `json:"nr_queued"`             // Number of tasks queued in the userspace scheduler
	Nr_scheduled          uint64 `json:"nr_scheduled"`          // Number of tasks scheduled by the userspace scheduler
	Nr_online_cpus        uint64 `json:"nr_online_cpus"`        // Number of online CPUs in the system
	Usersched_last_run_at uint64 `json:"usersched_last_run_at"` // The PID of the userspace scheduler
	Nr_user_dispatches    uint64 `json:"nr_user_dispatches"`    // Number of user-space dispatches
	Nr_kernel_dispatches  uint64 `json:"nr_kernel_dispatches"`  // Number of kernel-space dispatches
	Nr_cancel_dispatches  uint64 `json:"nr_cancel_dispatches"`  // Number of cancelled dispatches
	Nr_bounce_dispatches  uint64 `json:"nr_bounce_dispatches"`  // Number of bounce dispatches
	Nr_failed_dispatches  uint64 `json:"nr_failed_dispatches"`  // Number of failed dispatches
	Nr_sched_congested    uint64 `json:"nr_sched_congested"`    // Number of times the scheduler was congested
}

func (BssData) String

func (data BssData) String() string

type BssMap

type BssMap struct {
	*bpf.BPFMap
}

type DispatchedTask

type DispatchedTask struct {
	Pid        int32  // pid that uniquely identifies a task
	Cpu        int32  // target CPU selected by the scheduler
	Flags      uint64 // special dispatch flags
	SliceNs    uint64 // time slice assigned to the task (0 = default)
	Vtime      uint64 // task deadline / vruntime
	CpuMaskCnt uint64 // cpumask generation counter (private)
}

Task queued for dispatching to the BPF component (see bpf_intf::dispatched_task_ctx).

func NewDispatchedTask

func NewDispatchedTask(task *models.QueuedTask) *DispatchedTask

NewDispatchedTask creates a DispatchedTask from a QueuedTask.

type Rodata

type Rodata struct {
	DefaultSlice           uint64   `json:"default_slice"`
	SmtEnabled             bool     `json:"smt_enabled"`
	Debug                  bool     `json:"debug"`
	Pad0                   [54]byte `json:"-"` // __pad0[54]
	SCXOpsNameLen          uint64   `json:"scx_ops_name_len"`
	SCXSliceDfl            uint64   `json:"scx_slice_dfl"`
	SCXSliceInf            uint64   `json:"scx_slice_inf"`
	SCXRqOnline            uint64   `json:"scx_rq_online"`
	SCXRqCanStopTick       uint64   `json:"scx_rq_can_stop_tick"`
	SCXRqBalPending        uint64   `json:"scx_rq_bal_pending"`
	SCXRqBalKeep           uint64   `json:"scx_rq_bal_keep"`
	SCXRqBypassing         uint64   `json:"scx_rq_bypassing"`
	SCXRqClkValid          uint64   `json:"scx_rq_clk_valid"`
	SCXRqInWakeup          uint64   `json:"scx_rq_in_wakeup"`
	SCXRqInBalance         uint64   `json:"scx_rq_in_balance"`
	SCXDsqFlagBuiltin      uint64   `json:"scx_dsq_flag_builtin"`
	SCXDsqFlagLocalOn      uint64   `json:"scx_dsq_flag_local_on"`
	SCXDsqInvalid          uint64   `json:"scx_dsq_invalid"`
	SCXDsqGlobal           uint64   `json:"scx_dsq_global"`
	SCXDsqLocal            uint64   `json:"scx_dsq_local"`
	SCXDsqLocalOn          uint64   `json:"scx_dsq_local_on"`
	SCXDsqLocalCpuMask     uint64   `json:"scx_dsq_local_cpu_mask"`
	SCXTaskQueued          uint64   `json:"scx_task_queued"`
	SCXTaskResetRunnableAt uint64   `json:"scx_task_reset_runnable_at"`
	SCXTaskDeqdForSleep    uint64   `json:"scx_task_deqd_for_sleep"`
	SCXTaskStateShift      uint64   `json:"scx_task_state_shift"`
	SCXTaskStateBits       uint64   `json:"scx_task_state_bits"`
	SCXTaskStateMask       uint64   `json:"scx_task_state_mask"`
	SCXTaskCursor          uint64   `json:"scx_task_cursor"`
	SCXTaskNone            uint64   `json:"scx_task_none"`
	SCXTaskInit            uint64   `json:"scx_task_init"`
	SCXTaskReady           uint64   `json:"scx_task_ready"`
	SCXTaskEnabled         uint64   `json:"scx_task_enabled"`
	SCXTaskNrStates        uint64   `json:"scx_task_nr_states"`
	SCXTaskDsqOnPriq       uint64   `json:"scx_task_dsq_on_priq"`
	SCXKickIdle            uint64   `json:"scx_kick_idle"`
	SCXKickPreempt         uint64   `json:"scx_kick_preempt"`
	SCXKickWait            uint64   `json:"scx_kick_wait"`
	SCXEnqWakeup           uint64   `json:"scx_enq_wakeup"`
	SCXEnqHead             uint64   `json:"scx_enq_head"`
	SCXEnqPreempt          uint64   `json:"scx_enq_preempt"`
	SCXEnqReenq            uint64   `json:"scx_enq_reenq"`
	SCXEnqLast             uint64   `json:"scx_enq_last"`
	SCXEnqClearOpss        uint64   `json:"scx_enq_clear_opss"`
	SCXEnqDsqPriq          uint64   `json:"scx_enq_dsq_priq"`
	UeiDumpLen             uint32   `json:"uei_dump_len"`
	UserschedPid           uint32   `json:"usersched_pid"`
	KhugepagePid           uint32   `json:"khugepage_pid"`
	SwitchPartial          bool     `json:"switch_partial"`
	EarlyProcessing        bool     `json:"early_processing"`
	BuiltinIdle            bool     `json:"builtin_idle"`
}

type RodataMap

type RodataMap struct {
	*bpf.BPFMap
}

type Sched

type Sched struct {
	// contains filtered or unexported fields
}

func LoadSched

func LoadSched(objPath string) *Sched

func (*Sched) AssignUserSchedPid

func (s *Sched) AssignUserSchedPid(pid int) error

func (*Sched) Attach

func (s *Sched) Attach() error

func (*Sched) BlockTilReadyForDequeue

func (s *Sched) BlockTilReadyForDequeue(ctx context.Context)

func (*Sched) Close

func (s *Sched) Close()

func (*Sched) DecNrQueued added in v0.4.2

func (s *Sched) DecNrQueued(num uint64) error

func (*Sched) DefaultSelectCPU

func (s *Sched) DefaultSelectCPU(t *models.QueuedTask) (error, int32)

func (*Sched) DequeueTask

func (s *Sched) DequeueTask(task *models.QueuedTask)

func (*Sched) DetermineTimeSlice

func (s *Sched) DetermineTimeSlice(t *models.QueuedTask) uint64

func (*Sched) DisableMaxTimeWatchdog added in v0.4.3

func (s *Sched) DisableMaxTimeWatchdog()

func (*Sched) DispatchTask

func (s *Sched) DispatchTask(t *DispatchedTask) error

func (*Sched) DrainQueuedTask

func (s *Sched) DrainQueuedTask() uint64

func (*Sched) EnableKernelMode added in v0.4.2

func (s *Sched) EnableKernelMode()

func (*Sched) EnableSiblingCpu

func (s *Sched) EnableSiblingCpu(lvlId, cpuId, siblingCpuId int32) error

func (*Sched) GetBssData

func (s *Sched) GetBssData() (BssData, error)

func (*Sched) GetNrQueued added in v0.4.3

func (s *Sched) GetNrQueued() uint64

func (*Sched) GetNrScheduled added in v0.4.3

func (s *Sched) GetNrScheduled() uint64

func (*Sched) GetPoolCount

func (s *Sched) GetPoolCount() uint64

func (*Sched) GetRoData

func (s *Sched) GetRoData() (Rodata, error)

func (*Sched) GetUeiData

func (s *Sched) GetUeiData() (UserExitInfo, error)

func (*Sched) PreemptCpu

func (s *Sched) PreemptCpu(cpuId int32) error

func (*Sched) ReadyForDequeue

func (s *Sched) ReadyForDequeue() bool

func (*Sched) RemovePriorityTask added in v0.4.2

func (s *Sched) RemovePriorityTask(pid uint32) error

RemovePriorityTask removes a task from the priority_tasks BPF map. After removal, the task will no longer be treated as a priority task. pid: the process ID of the task to remove

func (*Sched) SelectCPU

func (s *Sched) SelectCPU(t *models.QueuedTask) (error, int32)

func (*Sched) SelectQueuedTask

func (s *Sched) SelectQueuedTask() *models.QueuedTask

func (*Sched) SetBuiltinIdle

func (s *Sched) SetBuiltinIdle(enabled bool)

func (*Sched) SetDebug

func (s *Sched) SetDebug(enabled bool)

func (*Sched) SetDefaultSlice

func (s *Sched) SetDefaultSlice(t uint64)

func (*Sched) SetEarlyProcessing

func (s *Sched) SetEarlyProcessing(enabled bool)

func (*Sched) SetPlugin

func (s *Sched) SetPlugin(p plugin.CustomScheduler)

func (*Sched) Start

func (s *Sched) Start()

func (*Sched) Stopped

func (s *Sched) Stopped() bool

func (*Sched) SubNrQueued

func (s *Sched) SubNrQueued() error

func (*Sched) UpdatePriorityTask added in v0.4.2

func (s *Sched) UpdatePriorityTask(pid uint32, slice uint64) error

UpdatePriorityTask adds or updates a task in the priority_tasks BPF map. When a task is in this map, it will be prioritized during scheduling. This function uses the default highest priority (0). pid: the process ID of the task slice: the time slice to assign to this priority task (in nanoseconds)

func (*Sched) UpdatePriorityTaskWithPrio added in v0.5.0

func (s *Sched) UpdatePriorityTaskWithPrio(pid uint32, slice uint64, prio uint32) error

UpdatePriorityTaskWithPrio adds or updates a task in the priority_tasks BPF map with a specific priority level.

Priority levels:

  • 0-9: High priority - can preempt tasks with lower priority (higher number)
  • 10-20: Medium priority - gets vtime reduction but no preemption. Priority 10 gets 50% vtime reduction, priority 20 gets 5% reduction.

pid: the process ID of the task slice: the time slice to assign to this priority task (in nanoseconds) prio: priority level (0-20), where lower is higher priority

type UeiMap

type UeiMap struct {
	*bpf.BPFMap
}

type UserExitInfo

type UserExitInfo struct {
	Kind     int32
	Paid     uint32
	ExitCode int64
	Reason   [UEI_REASON_LEN]C.char
	Message  [UEI_MSG_LEN]C.char
}

func (*UserExitInfo) GetMessage

func (uei *UserExitInfo) GetMessage() string

func (*UserExitInfo) GetReason

func (uei *UserExitInfo) GetReason() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL