Documentation ¶
Index ¶
- func AddDefaultFiles(adder FilesAdder, dir string, cpuid CPUidStringer) error
- func AggregateValues(values []CounterValue) (raw *big.Int, enabled *big.Int, running *big.Int)
- func AllCPUs() ([]int, error)
- func AllSockets() ([]int, error)
- func EventScaledValue(values CounterValue) *big.Int
- type Activator
- type ActiveEvent
- type ActiveEventGroup
- type ActiveEventMonitor
- type ActiveMultiEvent
- type CPUidStringer
- type CounterValue
- type CustomizableEvent
- type DeprecatedFormatError
- type EventGroupMonitor
- type EventTargetProcess
- type FilesAdder
- type JSONData
- type JSONEvent
- type JSONFilesReader
- type JSONHeader
- type Matcher
- type MultiActivator
- type NameMatcher
- type NamedPMUType
- type Options
- type OptionsBuilder
- type PerfEvent
- func (pe *PerfEvent) Activate(placement PlacementProvider, targetProcess TargetProcess, options Options) (*ActiveEvent, error)
- func (pe *PerfEvent) ActivateMulti(placements []PlacementProvider, process TargetProcess, options Options) (*ActiveMultiEvent, error)
- func (pe *PerfEvent) Decoded() string
- func (pe *PerfEvent) NewPlacements(unit string, cpu int, cpus ...int) ([]PlacementProvider, error)
- func (pe *PerfEvent) String() string
- type PerfEventOptions
- type PerfTransformer
- type Placement
- type PlacementFactory
- type PlacementProvider
- func NewCorePlacement(factory PlacementFactory, cpu int) (PlacementProvider, error)
- func NewCorePlacements(factory PlacementFactory, cpu int, cpus ...int) ([]PlacementProvider, error)
- func NewUncoreAllPlacements(factory PlacementFactory, socket int) ([]PlacementProvider, error)
- func NewUncorePlacement(factory PlacementFactory, unit string, socket int) (PlacementProvider, error)
- type Reader
- type TargetProcess
- type TransformationError
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDefaultFiles ¶
func AddDefaultFiles(adder FilesAdder, dir string, cpuid CPUidStringer) error
AddDefaultFiles adds core and uncore events from specified dir for provided cpuid
func AggregateValues ¶
AggregateValues lets aggregate multiple counter values.
func AllSockets ¶
AllSockets returns slice of all available sockets.
func EventScaledValue ¶
func EventScaledValue(values CounterValue) *big.Int
EventScaledValue calculates scaled value from CounterValue. Scaled value is equal to raw * enabled / running. If more events are activated than available counter slots on the PMU, then multiplexing happens and events only run part of the time. In that case the enabled and running values can be used to scale an estimated value for the count.
Types ¶
type Activator ¶
type Activator interface {
Activate(placement PlacementProvider, targetProcess TargetProcess, options Options) (*ActiveEvent, error)
}
Activator is the interface that wraps the activate method. Activate is able to return activated (being counted) perf event as ActiveEvent. Returned active event is configured to fulfill provided configuration placement provides a specific hardware placement for event, targetProcess provides a specific process (or cgroup) for event to monitor, options specify any additional perf configuration options. Activate must return a non-nil error if event cannot be activated, or provided parameters are invalid.
type ActiveEvent ¶
type ActiveEvent struct { PerfEvent *PerfEvent FileDescriptor int Decoded string // contains filtered or unexported fields }
ActiveEvent holds active perf event. Active - means that perf event has been opened by perf_event_open syscall (https://man7.org/linux/man-pages/man2/perf_event_open.2.html) and is able to provide counter values for specific, previously settled configuration and placement.
func (*ActiveEvent) Deactivate ¶
func (ae *ActiveEvent) Deactivate() error
Deactivate stops counting active event by closing its file descriptor.
func (*ActiveEvent) PMUName ¶
func (ae *ActiveEvent) PMUName() string
PMUName returns name of the ActiveEvent's PMU.
func (*ActiveEvent) PMUPlacement ¶
func (ae *ActiveEvent) PMUPlacement() (int, uint32)
func (*ActiveEvent) ReadValue ¶
func (ae *ActiveEvent) ReadValue() (CounterValue, error)
func (*ActiveEvent) String ¶
func (ae *ActiveEvent) String() string
type ActiveEventGroup ¶
type ActiveEventGroup struct {
// contains filtered or unexported fields
}
ActiveEventGroup contains set of active events belonging to the same perf event group.
func ActivateGroup ¶
func ActivateGroup(placement PlacementProvider, targetProcess TargetProcess, events []CustomizableEvent) (*ActiveEventGroup, error)
ActivateGroup is able to create ActiveEventGroup from provided events, placement, process and options. If events size is 0 no group will be created, and error will be returned. In case of single event contained in events slice, only one event perf group will be activated. In other cases, first event in slice will be treated as a leader and rest of them will be activated with its file descriptor as group file descriptor (group_fd argument) in perf_event_open syscall (https://man7.org/linux/man-pages/man2/perf_event_open.2.html).
func (*ActiveEventGroup) Deactivate ¶
func (ae *ActiveEventGroup) Deactivate()
func (*ActiveEventGroup) Events ¶
func (ae *ActiveEventGroup) Events() []*ActiveEvent
func (*ActiveEventGroup) String ¶
func (ae *ActiveEventGroup) String() string
type ActiveEventMonitor ¶
type ActiveEventMonitor interface { ReadValue() (CounterValue, error) Deactivate() error }
ActiveEventMonitor is and interface that wraps methods around monitoring active perf event.
ReadValue reads actual active perf event counter values and returns CounterValue. If values cannot be obtained, error is propagated. Close deactivates and closes active perf event.
type ActiveMultiEvent ¶
type ActiveMultiEvent struct {
// contains filtered or unexported fields
}
ActiveMultiEvent contains set of active multi PMU uncore events.
func (*ActiveMultiEvent) Deactivate ¶
func (am *ActiveMultiEvent) Deactivate()
func (*ActiveMultiEvent) Events ¶
func (am *ActiveMultiEvent) Events() []*ActiveEvent
func (*ActiveMultiEvent) PerfEvent ¶
func (am *ActiveMultiEvent) PerfEvent() *PerfEvent
PerfEvent returns original multi PMU perf event.
func (*ActiveMultiEvent) ReadValues ¶
func (am *ActiveMultiEvent) ReadValues() ([]CounterValue, error)
ReadValues returns all active multi PMU events counter value.
func (*ActiveMultiEvent) String ¶
func (am *ActiveMultiEvent) String() string
type CPUidStringer ¶
CPUidStringer interface to get the CPU ID in full form 'vendor-family-model-stepping' or short without stepping 'vendor-family-model'
func CheckCPUid ¶
func CheckCPUid() (CPUidStringer, error)
CheckCPUid gets the CPU ID Stringer which provides the ID for current cpu in forms: 'vendor-family-model-stepping' (for example 'GenuineIntel-6-55-4') or shorter 'vendor-family-model' (for example 'GenuineIntel-6-55')
type CounterValue ¶
CounterValue holds specific perf event Raw, Enabled and Running counter values.
func (*CounterValue) String ¶
func (cv *CounterValue) String() string
type CustomizableEvent ¶
CustomizableEvent unites PerfEvent with specific Options.
type DeprecatedFormatError ¶ added in v1.1.0
type DeprecatedFormatError struct {
// contains filtered or unexported fields
}
DeprecatedFormatError - error to indicate if a file has the deprecated JSON format
func (*DeprecatedFormatError) Error ¶ added in v1.1.0
func (e *DeprecatedFormatError) Error() string
func (*DeprecatedFormatError) Is ¶ added in v1.1.0
func (e *DeprecatedFormatError) Is(target error) bool
Is - the implementation to support errors.Is
type EventGroupMonitor ¶
type EventGroupMonitor interface { Events() []*ActiveEvent Deactivate() }
EventGroupMonitor is an interface for group monitoring functionalities.
Events return all active events within event group that the EventGroupMonitor is monitoring. Deactivate closes, deactivates all active events within event group.
type EventTargetProcess ¶
type EventTargetProcess struct {
// contains filtered or unexported fields
}
EventTargetProcess holds target process data.
func NewEventTargetProcess ¶
func NewEventTargetProcess(pid int, processType int) *EventTargetProcess
NewEventTargetProcess returns new EventTargetProcess.
func (*EventTargetProcess) ProcessID ¶
func (etp *EventTargetProcess) ProcessID() int
func (*EventTargetProcess) ProcessType ¶
func (etp *EventTargetProcess) ProcessType() int
func (*EventTargetProcess) String ¶
func (etp *EventTargetProcess) String() string
type FilesAdder ¶
FilesAdder interface to add JSON files with events
type JSONData ¶ added in v1.1.0
type JSONData struct { Header *JSONHeader `json:"Header"` Events []*JSONEvent `json:"Events"` }
JSONData - new data format of perfmon
type JSONEvent ¶
type JSONEvent struct { AnyThread string `json:"AnyThread"` BriefDescription string `json:"BriefDescription"` CounterMask string `json:"CounterMask"` Deprecated string `json:"Deprecated"` EdgeDetect string `json:"EdgeDetect"` EventCode string `json:"EventCode"` EventName string `json:"EventName"` ExtSel string `json:"ExtSel"` Invert string `json:"Invert"` MSRIndex string `json:"MSRIndex"` MSRValue string `json:"MSRValue"` SampleAfterValue string `json:"SampleAfterValue"` UMask string `json:"UMask"` Unit string `json:"Unit"` }
JSONEvent - fields in JSON definition of PMU events
type JSONFilesReader ¶
type JSONFilesReader struct {
// contains filtered or unexported fields
}
JSONFilesReader load events definition from specified JSON files
func NewFilesReader ¶
func NewFilesReader() *JSONFilesReader
NewFilesReader returns new JSONFilesReader with default members
func (*JSONFilesReader) AddFiles ¶
func (r *JSONFilesReader) AddFiles(firstPath string, optionalPaths ...string) error
AddFiles add files for Reader to read
func (*JSONFilesReader) GetHeaders ¶ added in v1.1.0
func (r *JSONFilesReader) GetHeaders() map[string]JSONHeader
GetHeaders - return the headers from event files Key of the map is the path of the file
func (*JSONFilesReader) Read ¶
func (r *JSONFilesReader) Read() ([]*JSONEvent, error)
Read and return JSON events from path(s)
func (*JSONFilesReader) String ¶
func (r *JSONFilesReader) String() string
type JSONHeader ¶ added in v1.1.0
type JSONHeader struct { Copyright string `json:"Copyright"` Info string `json:"Info"` DatePublished string `json:"DatePublished"` Version string `json:"Version"` Legend string `json:"Legend"` }
JSONHeader - struct contains the Header info of events
type MultiActivator ¶
type MultiActivator interface {
ActivateMulti(placements []PlacementProvider, process TargetProcess, options Options) (*ActiveMultiEvent, error)
}
MultiActivator is an interface that wraps ActivateMulti method.
ActivateMulti activates multi PMU perf event on specific placements. Returns this activated events as ActiveMultiEvent.
type NameMatcher ¶
type NameMatcher struct {
// contains filtered or unexported fields
}
NameMatcher match events by exact name.
func NewNameMatcher ¶
func NewNameMatcher(eventsNames ...string) *NameMatcher
NewNameMatcher returns new NameMatcher with default members. If no arguments are passed the matcher will match all events.
func (*NameMatcher) Match ¶
func (m *NameMatcher) Match(event *JSONEvent) (bool, error)
Match checks if the provided event matches the stored list of event names.
func (*NameMatcher) String ¶
func (m *NameMatcher) String() string
type NamedPMUType ¶
NamedPMUType wraps PMUType with its name
type Options ¶
type Options interface { PerfStatString() []string Attr() *unix.PerfEventAttr }
Options is an interface for extra perf options.
PerfStatString() returns user specified extra modifiers as string. Attr() returns modified unix.PerfEventAttr struct properly set.
type OptionsBuilder ¶
type OptionsBuilder interface { SetEnableOnExec(bool) OptionsBuilder SetAttrModifiers([]string) OptionsBuilder Build() (Options, error) }
OptionsBuilder is an builder for Options.
SetEnableOnExec decides if set perf event attribute bits with PerfBitDisabled and PerfBitEnableOnExec. SetAttrModifiers updates perf event attribute qualifiers. Build builds new Options.
type PerfEvent ¶
type PerfEvent struct { Name string Uncore bool PMUName string PMUTypes []NamedPMUType Attr *unix.PerfEventAttr // contains filtered or unexported fields }
PerfEvent contains event general data.
func (*PerfEvent) Activate ¶
func (pe *PerfEvent) Activate(placement PlacementProvider, targetProcess TargetProcess, options Options) (*ActiveEvent, error)
func (*PerfEvent) ActivateMulti ¶
func (pe *PerfEvent) ActivateMulti(placements []PlacementProvider, process TargetProcess, options Options) (*ActiveMultiEvent, error)
func (*PerfEvent) NewPlacements ¶
NewPlacements returns slice of newly created placements for provided cpus and unit. It also checks if provided unit and cpus are valid for the PerfEvent. In case of uncore events, cpus are interpreted as socket CPUs. If unit == "" it returns all units for distributed uncore PMU.
type PerfEventOptions ¶
type PerfEventOptions struct {
// contains filtered or unexported fields
}
PerfEventOptions contains some of the perf event configuration options and modifiers.
func (*PerfEventOptions) Attr ¶
func (pfo *PerfEventOptions) Attr() *unix.PerfEventAttr
func (*PerfEventOptions) PerfStatString ¶
func (pfo *PerfEventOptions) PerfStatString() []string
func (*PerfEventOptions) String ¶
func (pfo *PerfEventOptions) String() string
type PerfTransformer ¶
type PerfTransformer struct {
// contains filtered or unexported fields
}
PerfTransformer uses reader and matcher to provide perf events
func NewPerfTransformer ¶
func NewPerfTransformer() *PerfTransformer
NewPerfTransformer returns new PerfTransformer with default members
type Placement ¶
Placement holds info about single placement for event
func (*Placement) PMUPlacement ¶
PMUPlacement returns single placement - CPU and PMU TypeID on which the event should be placed
type PlacementFactory ¶
type PlacementFactory interface {
NewPlacements(unit string, cpu int, cpus ...int) ([]PlacementProvider, error)
}
PlacementFactory interface to get placement providers for specified unit and CPUs
type PlacementProvider ¶
PlacementProvider interface to provide single placement by means of CPU and PMU TypeID
func NewCorePlacement ¶
func NewCorePlacement(factory PlacementFactory, cpu int) (PlacementProvider, error)
NewCorePlacement creates new core placement for given CPU
func NewCorePlacements ¶
func NewCorePlacements(factory PlacementFactory, cpu int, cpus ...int) ([]PlacementProvider, error)
NewCorePlacements creates new core placements for given CPUs
func NewUncoreAllPlacements ¶
func NewUncoreAllPlacements(factory PlacementFactory, socket int) ([]PlacementProvider, error)
NewUncoreAllPlacements creates new uncore placements for given socket and all units available from given factory
func NewUncorePlacement ¶
func NewUncorePlacement(factory PlacementFactory, unit string, socket int) (PlacementProvider, error)
NewUncorePlacement creates new uncore placement for given unit and socket
type TargetProcess ¶
TargetProcess is an interface with methods specialized in gathering information about desired system process.
ProcessID returns specific process identifier. ProcessType returns type of process identifier. Value 0 is for process id (PID) and 1 is for cgroup identifier.
type TransformationError ¶
type TransformationError struct {
// contains filtered or unexported fields
}
func (*TransformationError) Error ¶
func (t *TransformationError) Error() string
func (*TransformationError) Errors ¶
func (t *TransformationError) Errors() []error