Skip to content

Commit

Permalink
intelrdt: add mbm stats
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Szulik <pawel.szulik@intel.com>
  • Loading branch information
Paweł Szulik committed Apr 15, 2020
1 parent 4eb533d commit ad197e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
12 changes: 1 addition & 11 deletions libcontainer/intelrdt/mbm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (
type monFeatures struct {
mbmTotalBytes bool
mbmLocalBytes bool
llcOccupancy bool
}

// Check if Intel RDT/MBM is enabled
Expand Down Expand Up @@ -52,10 +51,8 @@ func parseMonFeatures(reader io.Reader) (monFeatures, error) {
monFeatures.mbmTotalBytes = true
case "mbm_local_bytes":
monFeatures.mbmLocalBytes = true
case "llc_occupancy":
monFeatures.llcOccupancy = true
default:
logrus.Warnf("Unsupported RDT Memory Bandwidth Monitoring (MBM) feature: %s", feature)
logrus.Warnf("Unsupported Intel RDT monitoring feature: %s", feature)
}
}

Expand Down Expand Up @@ -101,12 +98,5 @@ func getMBMNumaNodeStats(numaPath string) (*MBMNumaNodeStats, error) {
stats.MBMLocalBytes = mbmLocalBytes
}

if enabledMonFeatures.llcOccupancy {
llcOccupancy, err := getIntelRdtParamUint(numaPath, "llc_occupancy")
if err != nil {
return nil, err
}
stats.LLCOccupancy = llcOccupancy
}
return stats, nil
}
14 changes: 3 additions & 11 deletions libcontainer/intelrdt/mbm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
func TestParseMonFeatures(t *testing.T) {
t.Run("All features available", func(t *testing.T) {
parsedMonFeatures, err := parseMonFeatures(
strings.NewReader("mbm_total_bytes\nmbm_local_bytes\nllc_occupancy"))
strings.NewReader("mbm_total_bytes\nmbm_local_bytes"))
if err != nil {
t.Errorf("Error while parsing mon features err = %v", err)
}

expectedMonFeatures := monFeatures{true, true, true}
expectedMonFeatures := monFeatures{true, true}

if parsedMonFeatures != expectedMonFeatures {
t.Error("Cannot gather all features!")
Expand All @@ -33,7 +33,7 @@ func TestParseMonFeatures(t *testing.T) {
t.Errorf("Error while parsing mon features err = %v", err)
}

expectedMonFeatures := monFeatures{false, false, false}
expectedMonFeatures := monFeatures{false, false}

if parsedMonFeatures != expectedMonFeatures {
t.Error("Expected no features available but there is any!")
Expand Down Expand Up @@ -73,7 +73,6 @@ func TestGetMbmStats(t *testing.T) {
mocksFilesToCreate := map[string]uint64{
"mbm_total_bytes": 9123911,
"mbm_local_bytes": 2361361,
"llc_occupancy": 123013,
}

mockedMBM, err := mockMBM(mocksNUMANodesToCreate, mocksFilesToCreate)
Expand All @@ -92,7 +91,6 @@ func TestGetMbmStats(t *testing.T) {
t.Run("Gather mbm", func(t *testing.T) {
enabledMonFeatures.mbmTotalBytes = true
enabledMonFeatures.mbmLocalBytes = true
enabledMonFeatures.llcOccupancy = true

stats, err := getMBMStats(mockedMBM)
if err != nil {
Expand All @@ -117,17 +115,11 @@ func TestGetMbmStats(t *testing.T) {
got.MBMLocalBytes)
}

if got.LLCOccupancy != expected.LLCOccupancy {
t.Fatalf("Wrong value of llc_occupancy. Expected: %v but got: %v",
expected.LLCOccupancy,
got.LLCOccupancy)
}
}

expectedStats := MBMNumaNodeStats{
MBMTotalBytes: mocksFilesToCreate["mbm_total_bytes"],
MBMLocalBytes: mocksFilesToCreate["mbm_local_bytes"],
LLCOccupancy: mocksFilesToCreate["llc_occupancy"],
}

checkStatCorrection((*stats)[0], expectedStats, t)
Expand Down
3 changes: 0 additions & 3 deletions libcontainer/intelrdt/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ type MBMNumaNodeStats struct {

// The 'mbm_local_bytes' in 'container_id' group
MBMLocalBytes uint64 `json:"mbm_local_bytes,omitempty"`

// The 'llc_occupancy' in 'container_id' group
LLCOccupancy uint64 `json:"llc_occupancy,omitempty"`
}

type Stats struct {
Expand Down

0 comments on commit ad197e6

Please sign in to comment.