-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
intelrdt: Add Cache Monitoring Technology stats
Signed-off-by: Paweł Szulik <[email protected]>
- Loading branch information
Paweł Szulik
committed
Apr 25, 2020
1 parent
d1e4c7b
commit 799d948
Showing
10 changed files
with
335 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package intelrdt | ||
|
||
var ( | ||
cmtEnabled bool | ||
) | ||
|
||
// Check if Intel RDT/CMT is enabled. | ||
func IsCMTEnabled() bool { | ||
return cmtEnabled | ||
} | ||
|
||
func getCMTNumaNodeStats(numaPath string) (*CMTNumaNodeStats, error) { | ||
stats := &CMTNumaNodeStats{} | ||
|
||
llcOccupancy, err := getIntelRdtParamUint(numaPath, "llc_occupancy") | ||
if err != nil { | ||
return nil, err | ||
} | ||
stats.LLCOccupancy = llcOccupancy | ||
|
||
return stats, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package intelrdt | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestGetCMTNumaNodeStats(t *testing.T) { | ||
mocksNUMANodesToCreate := []string{"mon_l3_00", "mon_l3_01"} | ||
|
||
mocksFilesToCreate := map[string]uint64{ | ||
"llc_occupancy": 9123911, | ||
} | ||
|
||
mockedL3_MON, err := mockResctrlL3_MON(mocksNUMANodesToCreate, mocksFilesToCreate) | ||
|
||
defer func() { | ||
err := os.RemoveAll(mockedL3_MON) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
}() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
t.Run("Gather mbm", func(t *testing.T) { | ||
enabledMonFeatures.llcOccupancy = true | ||
|
||
stats := make([]CMTNumaNodeStats, 0, len(mocksNUMANodesToCreate)) | ||
for _, numa := range mocksNUMANodesToCreate { | ||
other, err := getCMTNumaNodeStats(filepath.Join(mockedL3_MON, "mon_data", numa)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
stats = append(stats, *other) | ||
} | ||
|
||
expectedStats := CMTNumaNodeStats{ | ||
LLCOccupancy: mocksFilesToCreate["llc_occupancy"], | ||
} | ||
|
||
checkCMTStatCorrection(stats[0], expectedStats, t) | ||
checkCMTStatCorrection(stats[1], expectedStats, t) | ||
}) | ||
} | ||
|
||
func checkCMTStatCorrection(got CMTNumaNodeStats, expected CMTNumaNodeStats, t *testing.T) { | ||
if got.LLCOccupancy != expected.LLCOccupancy { | ||
t.Fatalf("Wrong value of `llc_occupancy`. Expected: %v but got: %v", | ||
expected.LLCOccupancy, | ||
got.LLCOccupancy) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.