proc

package
v0.2.2-0...-aec2f31 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CPUInfoPath is the patch to cpuinfo
	CPUInfoPath = "/proc/cpuinfo"
	// MountInfoPath is the mount info path
	MountInfoPath = "/proc/self/mountinfo"
	//Mounts to check the resctrl is mounted in the same path
	Mounts = "/proc/self/mounts"
)

Variables

View Source
var (
	// ResctrlPath is the patch to resctrl
	ResctrlPath string
	// MbaInfoPath is the MBA path of
	MbaInfoPath string
)
View Source
var IsEnableMba = func() (bool, error) {
	_, err := findMountDir(ResctrlPath)
	if err != nil {
		return false, err
	}
	if stat, err := os.Stat(MbaInfoPath); err == nil {
		if stat.IsDir() {
			return true, nil
		}
		return false, nil
	}
	return false, err
}

IsEnableMba returns if MBA is enabled or not

View Source
var IsL3CatAvailable = func() (bool, error) {
	return parseCPUInfoFile("cat_l3")
}

IsL3CatAvailable returns L3 CAT feature available or not

View Source
var IsMbaAvailable = func() (bool, error) {
	return parseCPUInfoFile("mba")
}

IsMbaAvailable returns MBA feature available or not

View Source
var ListProcesses = func() map[string]Process {
	processes := make(map[string]Process)
	files, _ := filepath.Glob("/proc/[0-9]*/cmdline")
	for _, file := range files {

		listfs := strings.Split(file, "/")
		if pid, err := strconv.Atoi(listfs[2]); err == nil {

			cmd, _ := ioutil.ReadFile(file)
			cmdString := strings.Join(strings.Split(string(cmd), "\x00"), " ")
			processes[listfs[2]] = Process{pid, cmdString}
		}
	}

	return processes
}

ListProcesses returns all process on the host

Functions

func GetCPUAffinity

func GetCPUAffinity(Pid string) (*util.Bitmap, error)

GetCPUAffinity returns the affinity of a given task id

func GetMbaMbpsMode

func GetMbaMbpsMode() bool

GetMbaMbpsMode returns MBA mode currently supported by rmd

func Init

func Init() error

Init does config initial

func IsCdpAvailable

func IsCdpAvailable() (bool, error)

IsCdpAvailable returns CDP feature available or not

func IsCqmAvailable

func IsCqmAvailable() (bool, error)

IsCqmAvailable returns CMT feature available or not

func IsEnableCat

func IsEnableCat() bool

IsEnableCat returns if CAT is enabled or not

func IsEnableCdp

func IsEnableCdp() bool

IsEnableCdp returns if CDP is enabled or not

func IsEnableRdt

func IsEnableRdt() bool

IsEnableRdt returns if RDT is enabled or not

func IsRdtAvailable

func IsRdtAvailable() (bool, error)

IsRdtAvailable returns RDT feature available or not

func IsResctrlMounted

func IsResctrlMounted(flag string) bool

IsResctrlMounted Checks if ResCtrl is mounted and if the path is valid

func SetCPUAffinity

func SetCPUAffinity(Pid string, cpus *util.Bitmap) error

SetCPUAffinity set a process/thread's CPU affinity func SetCPUAffinity(Pid string, affinity []int) error {

func SetMbaMbpsMode

func SetMbaMbpsMode(flag bool)

SetMbaMbpsMode stores MBA mode currently supported by rmd

Types

type Process

type Process struct {
	Pid     int
	CmdLine string
}

Process struct with pid and command line

Jump to

Keyboard shortcuts

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