Skip to content

Include CpusAllowedList for better user experience #41

@yanniszark

Description

@yanniszark

In the process_status.go file, CpusAllowed is given as an array of uint32 representing the mask format. This requires the user to implement the logic to translate this to meaningful core numbers. The status file also provides a field called Cpus_allowed_list, which gives the cores in a list format. In that spirit I propose these additions:

Note: I'm intentionally not touching the format of CpusAllowed in order to ensure backwards compatibility.

// New type for list format
type ListFormat []uint32

// Add new field to ProcessStatus struct
type ProcessStatus struct {
...
    CpusAllowedList ListFormat
}

// Parsing code
// Decode the listformat of CpusAllowedList into a slice of numbers representing one core each
// eg ParsedCpusAllowedList = "1-3"  -> CpusAllowedList = [1,2,3]

// The user can print the CpusAllowedList in canonical list form 
// by calling the implemented String() method
// eg cpusAllowedList.String() = "1-3"
func (c ListFormat) String() string {
   ...
}

// The user can easily find out the number of cores the 
// application is allowed to run on by calling:
cores := len(cpusAllowedList)

All in all, this enables users to have easy access to what cores are allowed as well as the number of cores allowed. The same can be done for MemsAllowed. Reference man page.

I'm willing to implement this but I want to see if there is an objection about the design/feature before I start!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions