Documentation
¶
Index ¶
- func NewSysfs() sysfsIface
- type AttrID
- type BasicFilter
- func (f *BasicFilter) Match(args *FilterInput) bool
- func (f *BasicFilter) SetAttributeValues(attr AttrID, values ...string) *BasicFilter
- func (f *BasicFilter) SetAttributes(attrs ...AttrID) *BasicFilter
- func (f *BasicFilter) SetCPUs(cpus ...utils.ID) *BasicFilter
- func (f *BasicFilter) SetCstateNames(names ...string) *BasicFilter
- type Cstate
- func (c *Cstate) AttrCount() int
- func (c *Cstate) Attrs() []AttrID
- func (c *Cstate) CPU() utils.ID
- func (c *Cstate) Copy(filter Filter) *Cstate
- func (c *Cstate) GetAttr(id AttrID) *string
- func (c *Cstate) Name() string
- func (c *Cstate) SetAttr(id AttrID, value *string)
- func (c *Cstate) State() int
- func (c *Cstate) String() string
- type CstateAttribute
- type Cstates
- func (cs *Cstates) Add(cstate *Cstate)
- func (cs *Cstates) Apply() error
- func (cs *Cstates) Attrs() []AttrID
- func (cs *Cstates) CPUs() utils.IDSet
- func (cs *Cstates) ClearAttrs(attrs ...AttrID)
- func (cs *Cstates) Copy(filter Filter) *Cstates
- func (cs *Cstates) Cstate(cpu utils.ID, name string) *Cstate
- func (cs *Cstates) GetAttr(cpu utils.ID, name string, attr AttrID) *string
- func (cs *Cstates) Names() []string
- func (cs *Cstates) Read(filter Filter) error
- func (cs *Cstates) SetAttrs(attr AttrID, val string)
- func (c *Cstates) SetFs(fs sysfsIface)
- func (cs *Cstates) String() string
- type Filter
- type FilterInput
- type FilterInputOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BasicFilter ¶
type BasicFilter struct {
// contains filtered or unexported fields
}
BasicFilter implements a simple filter based on CPU IDs, cstate names and attributes.
func NewBasicFilter ¶
func NewBasicFilter() *BasicFilter
func (*BasicFilter) Match ¶
func (f *BasicFilter) Match(args *FilterInput) bool
Match evaluates the filter against the provided input arguments. Implements a logical AND of all filter criteria.
func (*BasicFilter) SetAttributeValues ¶
func (f *BasicFilter) SetAttributeValues(attr AttrID, values ...string) *BasicFilter
SetAttributeValues sets the values of a given attribute accepted by the filter. This does not imply that the attribute itself is accepted or other attributes would be rejected; use SetAttributes for filtering attribute IDs.
func (*BasicFilter) SetAttributes ¶
func (f *BasicFilter) SetAttributes(attrs ...AttrID) *BasicFilter
SetAttributes sets the attribute IDs accepted by the filter.
func (*BasicFilter) SetCPUs ¶
func (f *BasicFilter) SetCPUs(cpus ...utils.ID) *BasicFilter
SetCPUs sets the CPU IDs accepted by the filter.
func (*BasicFilter) SetCstateNames ¶
func (f *BasicFilter) SetCstateNames(names ...string) *BasicFilter
SetCstateNames sets the cstate names accepted by the filter.
type Cstate ¶
type Cstate struct {
// contains filtered or unexported fields
}
Cstate represents single C-state, e.g. "C6" of a single CPU, e.g. cpu2.
Attribute values correspond to files located in sysfs. For example, Cstate{cpu: 2, state: 3}.attrVal[AttrResidency] corresponds to the file /sys/devices/system/cpu/cpu2/cpuidle/state3/residency.
If an attribute value is nil, file has not been read value has been cleared to skip writing it to sysfs.
func (*Cstate) Copy ¶
Copy returns a new Cstate instance containing a copy attribute values. If filters are given, only matching attributes will be copied and while others will be nil.
func (*Cstate) GetAttr ¶
GetAttr returns the attribute value, or nil if the attribute has not been read from sysfs or it has been cleared.
func (*Cstate) SetAttr ¶
SetAttr sets the attribute value. If value is nil, the attribute is cleared and will not be written to sysfs.
type CstateAttribute ¶
type CstateAttribute struct {
// contains filtered or unexported fields
}
CstateAttribute represents a single C-state attribute, e.g. "residency".
type Cstates ¶
type Cstates struct {
// contains filtered or unexported fields
}
Cstates represents a collection of Cstate instances.
func NewCstatesFromSysfs ¶
NewCstatesFromSysfs creates a new Cstates instance by reading the C-state information from sysfs.
If filters are given, only matching C-states and attributes are read.
func (*Cstates) ClearAttrs ¶
ClearAttrs clears the given attribute for all C-states in the collection.
func (*Cstates) Copy ¶
Copy returns a new Cstates instance containing copies of the C-states. If filters are given, result includes only matching C-states with matching attributes and values, and C-states without attributes are omitted.
func (*Cstates) Cstate ¶
Cstate returns the Cstate instance for the given CPU ID and C-state name, or nil if not found.
func (*Cstates) GetAttr ¶
GetAttr returns the attribute value for the given CPU ID and C-state name,
func (*Cstates) Names ¶
Names returns a sorted list of unique C-state names in the collection. The order of names corresponds to the order of state numbers, e.g. ["POLL", "C1E", "C6", "C8", "C10"], where "POLL" is state0, "C1E" is state1, etc. Lists C-state names present in the collection, not all possible names.
func (*Cstates) Read ¶
Read populates the Cstates instance from filesystem that implements the sysfsIface interface.
func (*Cstates) SetAttrs ¶
SetAttrs sets the given attribute to the given value for all C-states in the collection.
type Filter ¶
type Filter interface {
// Match returns true if the given arguments match the filter criteria.
Match(*FilterInput) bool
}
Filter defines the interface for filtering cstate data.
type FilterInput ¶
type FilterInput struct {
CPU *utils.ID
CstateName *string
Attribute *AttrID
AttributeValue *string
}
FilterInput holds the input values for evaluating the filter. All fields are optional. Nil values indicate "not defined" and should be ignored in filter evaluation.
func NewFilterInput ¶
func NewFilterInput(opts ...FilterInputOpt) *FilterInput
NewFilterInput creates a new FilterInput instance.
func (*FilterInput) SetAttribute ¶
func (f *FilterInput) SetAttribute(attr AttrID) *FilterInput
SetAttribute sets the attribute ID in the FilterInput. It clears any existing AttributeValue causing the filter to match any value for the attribute.
func (*FilterInput) SetAttributeValue ¶
func (f *FilterInput) SetAttributeValue(attr AttrID, value string) *FilterInput
SetAttributeValue sets the attribute ID and value in the FilterInput.
func (*FilterInput) SetCPU ¶
func (f *FilterInput) SetCPU(cpu utils.ID) *FilterInput
SetCPU sets the CPU ID in the FilterInput.
func (*FilterInput) SetCstateName ¶
func (f *FilterInput) SetCstateName(name string) *FilterInput
SetCstateName sets the cstate name in the FilterInput.
type FilterInputOpt ¶
type FilterInputOpt func(*FilterInput)