Skip to content

Commit

Permalink
Add active idle values to uncore table
Browse files Browse the repository at this point in the history
  • Loading branch information
harp-intel committed Jun 29, 2023
1 parent 02357a0 commit 7b53c8d
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ src/collector/collector
src/collector/collector.exe
src/collector/collector_arm64
src/rdmsr/rdmsr
src/wrmsr/wrmsr
src/msrbusy/msrbusy
src/calcfreq/calcfreq
# src
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ./src/msrbusy
use ./src/orchestrator
use ./src/rdmsr
use ./src/reporter
use ./src/wrmsr
use ./src/pkg/commandfile
use ./src/pkg/core
use ./src/pkg/cpu
Expand Down
17 changes: 13 additions & 4 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/xuri/excelize/v2 v2.7.0 h1:Hri/czwyRCW6f6zrCDWXcXKshlq4xAZNpNOpdfnFhEw=
github.com/xuri/excelize/v2 v2.7.0/go.mod h1:ebKlRoS+rGyLMyUx3ErBECXs/HNYqyj+PbkkKRK5vSI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
22 changes: 14 additions & 8 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ VERSION_NUMBER := $(shell cat ${VERSION_FILE})
VERSION := $(VERSION_NUMBER)_$(COMMIT_DATE)_$(COMMIT_ID)

default: check orchestrator
.PHONY: default test check format_check format linux-source collector reporter orchestrator rdmsr msrbusy reset clean tools libs async-profiler calcfreq cpuid dmidecode ethtool fio flamegraph ipmitool lshw lspci mlc perf spectre-meltdown-checker sshpass stress-ng sysstat turbostat oss-source
.PHONY: default test check format_check format linux-source collector reporter orchestrator rdmsr wrmsr msrbusy reset clean tools libs async-profiler calcfreq cpuid dmidecode ethtool fio flamegraph ipmitool lshw lspci mlc perf spectre-meltdown-checker sshpass stress-ng sysstat turbostat oss-source

collector_tools: async-profiler calcfreq cpuid dmidecode ethtool fio flamegraph ipmitool lshw lspci mlc msrbusy perf rdmsr spectre-meltdown-checker stress-ng sysstat turbostat
collector_tools: async-profiler calcfreq cpuid dmidecode ethtool fio flamegraph ipmitool lshw lspci mlc msrbusy perf rdmsr wrmsr spectre-meltdown-checker stress-ng sysstat turbostat

test:
cd pkg/commandfile && go test -v -vet=all .
Expand All @@ -25,6 +25,7 @@ test:
cd collector && go test -v -vet=all .
cd reporter && go test -v -vet=all .
cd rdmsr && go test -v -vet=all .
cd wrmsr && go test -v -vet=all .
cd msrbusy && go test -v -vet=all .

format:
Expand All @@ -45,20 +46,23 @@ orchestrator: sshpass reporter collector collector-deps
cp reporter/reporter orchestrator/resources/
cp collector/collector orchestrator/resources/
cp collector/collector_arm64 orchestrator/resources/
cd orchestrator && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o orchestrator
cd orchestrator && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o orchestrator

collector:
cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o collector
cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o collector_arm64
cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o collector
cd collector && CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o collector_arm64

reporter:
cd reporter && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o reporter
cd reporter && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o reporter

rdmsr:
cd rdmsr && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o rdmsr
cd rdmsr && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o rdmsr

wrmsr:
cd wrmsr && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o wrmsr

msrbusy:
cd msrbusy && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -X main.gVersion=$(VERSION)' -o msrbusy
cd msrbusy && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '-s -w -X main.gVersion=$(VERSION)' -o msrbusy

async-profiler:
ifeq ("$(wildcard async-profiler)","")
Expand Down Expand Up @@ -232,6 +236,7 @@ collector-deps-amd64: collector_tools
cp -R async-profiler $(TMPDIR)
cp flamegraph/stackcollapse-perf.pl $(TMPDIR)
cp rdmsr/rdmsr $(TMPDIR)
cp wrmsr/wrmsr $(TMPDIR)
cp spectre-meltdown-checker/spectre-meltdown-checker.sh $(TMPDIR)
cp stress-ng/stress-ng $(TMPDIR)
cp sysstat/mpstat $(TMPDIR)
Expand Down Expand Up @@ -271,6 +276,7 @@ clean:
rm -f orchestrator/resources/reporter
rm -f orchestrator/resources/sshpass
rm -f rdmsr/rdmsr
rm -f wrmsr/wrmsr
rm -f msrbusy/msrbusy

reset:
Expand Down
2 changes: 1 addition & 1 deletion src/collector/collector_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func runCommand(label string, command string, superuser bool, superuserPassword
if binPath != "" {
path := getUserPath()
newPath := fmt.Sprintf("%s%c%s", binPath, os.PathListSeparator, path)
cmdWithPath = fmt.Sprintf("PATH=\"%s\" %s", newPath, cmdWithPath)
cmdWithPath = fmt.Sprintf("PATH=\"%s\"\n%s", newPath, command)
}
if superuser {
return runSuperUserCommand(cmdWithPath, superuserPassword, timeout)
Expand Down
14 changes: 14 additions & 0 deletions src/orchestrator/resources/collector_reports.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ commands:
superuser: true
modprobe: msr
parallel: true
- label: active idle utilization point
command: |-
wrmsr 0xb0 0x80000694 # must write this value to this MSR before reading 0xb1
rdmsr -f 15:8 0xb1 # ACTIVE IDLE - UTILIZATION POINT
superuser: true
modprobe: msr
parallel: true
- label: active idle mesh frequency
command: |-
wrmsr 0xb0 0x80000694 # must write this value to this MSR before reading 0xb1
rdmsr -f 7:0 0xb1 # ACTIVE IDLE - MESH FREQUENCY
superuser: true
modprobe: msr
parallel: true
- label: ipmitool sel time get
command: LC_ALL=C ipmitool sel time get
superuser: true
Expand Down
43 changes: 43 additions & 0 deletions src/pkg/msr/msr.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ func (msr *MSR) read(reg uint64, fileName string, bytes int) (val uint64, err er
return
}

func (msr *MSR) write(reg uint64, fileName string, bytes int, val uint64) (err error) {
f, err := os.OpenFile(fileName, os.O_RDWR, 0644)
if err != nil {
return
}
defer f.Close()
buf := make([]byte, 0, 8)
buf = binary.LittleEndian.AppendUint64(buf, val)
written, err := f.WriteAt(buf, int64(reg))
if err != nil {
return
}
if written != bytes {
err = fmt.Errorf("didn't write intended number of bytes: %d,%d", bytes, written)
return
}
return
}

// SetBitRange filters bits for subsequent calls to Read* functions
func (msr *MSR) SetBitRange(highBit int, lowBit int) (err error) {
if lowBit >= highBit {
Expand Down Expand Up @@ -160,6 +179,19 @@ func (msr *MSR) ReadAll(reg uint64) (out []uint64, err error) {
return
}

// WriteAll writes the given value to all cores at the given register offset
func (msr *MSR) WriteAll(reg uint64, val uint64) (err error) {
fileNames := msr.getMSRFileNames(-1, false)
for _, fileName := range fileNames {
var val uint64
err = msr.write(reg, fileName, 8, val)
if err != nil {
return
}
}
return
}

// ReadOne returns the register value for the specified core
func (msr *MSR) ReadOne(reg uint64, core int) (out uint64, err error) {
fileNames := msr.getMSRFileNames(core, false)
Expand All @@ -171,6 +203,17 @@ func (msr *MSR) ReadOne(reg uint64, core int) (out uint64, err error) {
return
}

// WriteOne writes the given value to the the specified core at the given register offset
func (msr *MSR) WriteOne(reg uint64, core int, val uint64) (err error) {
fileNames := msr.getMSRFileNames(core, false)
if len(fileNames) != 1 {
err = fmt.Errorf("did not find filenames for msr,core: %d, %d", reg, core)
return
}
err = msr.write(reg, fileNames[0], 8, val)
return
}

// ReadPackages returns the specified register value for each package (CPU/Socket)
func (msr *MSR) ReadPackages(reg uint64) (out []uint64, err error) {
fileNames := msr.getMSRFileNames(-1, true)
Expand Down
11 changes: 11 additions & 0 deletions src/pkg/msr/msr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ func TestReadOne(t *testing.T) {
}
}

func TestWriteOne(t *testing.T) {
msr, err := NewMSR()
if err != nil {
t.Fatal(err)
}
err = msr.WriteOne(0xB0, 0, 0x80000694)
if err != nil {
t.Fatal(err)
}
}

func TestReadAll(t *testing.T) {
msr, err := NewMSR()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/reporter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func NewConfigurationReport(sources []*Source, cpusInfo *cpu.CPU) (report *Repor
newISATable(sources, CPUCategory),
newAcceleratorTable(sources, CPUCategory),
newFeatureTable(sources, CPUCategory),
newUncoreTable(sources, CPUCategory),

newPowerTable(sources, Power),
newUncoreTable(sources, Power),
}...,
)

Expand Down
4 changes: 4 additions & 0 deletions src/reporter/report_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,16 @@ func newUncoreTable(sources []*Source, category TableCategory) (table *Table) {
"CHA Count",
"Minimum Frequency",
"Maximum Frequency",
"Active Idle Frequency",
"Active Idle Utilization Point",
},
Values: [][]string{
{
source.getCHACount(),
source.getUncoreMinFrequency(),
source.getUncoreMaxFrequency(),
source.getActiveIdleFrequency(),
source.getActiveIdleUtilizationPoint(),
},
},
}
Expand Down
22 changes: 22 additions & 0 deletions src/reporter/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,28 @@ func (s *Source) getNUMACPUList() (val string) {
return
}

func (s *Source) getActiveIdleFrequency() (val string) {
hex := s.getCommandOutputLine("active idle mesh frequency")
if hex != "" {
parsed, err := strconv.ParseInt(hex, 16, 64)
if err == nil {
val = fmt.Sprintf("%.1fGHz", float64(parsed)/10)
}
}
return
}

func (s *Source) getActiveIdleUtilizationPoint() (val string) {
hex := s.getCommandOutputLine("active idle utilization point")
if hex != "" {
parsed, err := strconv.ParseInt(hex, 16, 64)
if err == nil {
val = fmt.Sprintf("%d", parsed)
}
}
return
}

func (s *Source) getUncoreMaxFrequency() (val string) {
hex := s.getCommandOutputLine("uncore max frequency")
if hex != "" && hex != "0" {
Expand Down
7 changes: 7 additions & 0 deletions src/wrmsr/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module intel.com/svr-info/wrmsr/v2

go 1.20

replace intel.com/svr-info/pkg/msr => ../pkg/msr

require intel.com/svr-info/pkg/msr v0.0.0-00010101000000-000000000000
Loading

0 comments on commit 7b53c8d

Please sign in to comment.