Documentation
¶
Overview ¶
irq package provides low-level functions to read interrupts from /proc/interrupts and to read and write CPU affinities of interrupts through /proc/irq/NUMBER/smp_affinity_list.
Interrupt data read from procfs is cached, which assumes that interrupts are neither added nor removed at runtime and that no entity outside this package alters interrupt affinities. Affinities set between BlockWrites and UnblockWrites are buffered, and only the affinity set last for an interrupt reaches procfs.
Index ¶
- Variables
- func BlockWrites()
- func DropCache()
- func ForEachInterrupt(fn func(*Irq) error) error
- func IsAllowedInterrupt(description string) bool
- func SetAllowedInterrupts(patterns []string) ([]string, error)
- func SetProcRoot(root string)
- func UnblockWrites()
- func ValidateAllowedPatterns(patterns []string) error
- type Irq
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeniedInterrupt is the error returned for attempts to reference or control // globally disallowed interrupts. ErrDeniedInterrupt = errors.New("denied interrupt") )
Functions ¶
func BlockWrites ¶
func BlockWrites()
BlockWrites starts buffering interrupt affinities instead of writing them to procfs. Every call must be paired with an UnblockWrites call, and the calls may be nested.
func DropCache ¶
func DropCache()
DropCache drops all cached interrupt data: the interrupts read from the interrupts file, the affinities read from or written to procfs, and the affinities which are buffered but not written yet.
func ForEachInterrupt ¶
ForEachInterrupt collects all numbered interrupts listed in /proc/interrupts, calling the given function on each. If the function returns an error, iteration is stopped early and the received error is returned. It uses the currently set allowed patterns to determine if an interrupt is allowed to be controller by this package.
func IsAllowedInterrupt ¶
IsAllowedInterrupt returns true if the IRQ corresponding to the given description is allowed to be controlled via this package, as defined by the currently set allowed patterns.
func SetAllowedInterrupts ¶
SetAllowedInterrupts configures which interrupts can be controller using this package. With allow patterns unset any interrupt can be controlled. With patterns set, only interrupts with a matching description in /proc/interrupts can be controlled. If any pattern fails validity checking an error is returned. On success, the old patterns previously in effect are returned.
func SetProcRoot ¶
func SetProcRoot(root string)
SetProcRoot sets the procfs root directory and proc mountpoint. All data cached from the previous mountpoint is dropped, including buffered interrupt affinities.
func UnblockWrites ¶
func UnblockWrites()
UnblockWrites removes one write block set by BlockWrites. Removing the last block writes all buffered interrupt affinities to procfs, logging write errors instead of returning them.
func ValidateAllowedPatterns ¶
ValidateAllowedPatterns validates zero or more globbing patterns for interrupt description matching.
Types ¶
type Irq ¶
type Irq struct {
// contains filtered or unexported fields
}
Irq represents a single numbered hardware interrupt.
func Interrupts ¶
Interrupts collects and returns the numbered interrupts listed in /proc/interrupts which can be controlled by this package according to the currently set allowed patterns.
func ValidateAllowedReferencedInterrupts ¶
ValidateAllowedReferencedInterrupts takes a set of user interrupt glob patterns and validates them against the denied set of HW IRQs, as defined by the given allow patterns. Returns denied IRQs referenced by any pattern, with denied reference details in errors.
func ValidateReferencedInterrupts ¶
ValidateReferencedInterrupts takes a set of user interrupt glob patterns and validates them against the denied set of HW IRQs, as defined by the currently set allowed patterns. Returns denied IRQs referenced by any pattern, with denied reference details in errors.
func (*Irq) AffinityCpus ¶
AffinityCpus returns the CPUs in the affinity of the interrupt. The returned CPUs are the ones set last through this package, even if they have not reached procfs yet.
func (*Irq) Description ¶
Description returns the chip and device description of the interrupt.
func (*Irq) Match ¶
Match returns whether the interrupt matches the pattern string, that is either the exact interrupt number or a shell-like wildcard pattern match of its description.
func (*Irq) SetAffinityCpus ¶
SetAffinityCpus sets the CPUs in the affinity of the interrupt. While writes are blocked, the affinity is only buffered and write errors are logged instead of being returned.