Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,32 @@ func runCmd(cmd *cobra.Command, args []string) error {
return nil
}

// prepareTarget prepares the target for configuration changes
// almost all set scripts require the msr kernel module to be loaded and
// use wrmsr and rdmsr, so we do that here so that the goroutines for the
// set scripts can run in parallel without conflicts
func prepareTarget(myTarget target.Target, localTempDir string) (err error) {
prepareScript := script.ScriptDefinition{
Name: "prepare-target",
ScriptTemplate: "exit 0",
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr", "rdmsr"},
Lkms: []string{"msr"},
}
_, err = runScript(myTarget, prepareScript, localTempDir)
return err
}

func setOnTarget(cmd *cobra.Command, myTarget target.Target, flagGroups []flagGroup, localTempDir string, channelError chan error, statusUpdate progress.MultiSpinnerUpdateFunc) {
// prepare the target for configuration changes
_ = statusUpdate(myTarget.GetName(), "preparing target for configuration changes")
if err := prepareTarget(myTarget, localTempDir); err != nil {
_ = statusUpdate(myTarget.GetName(), fmt.Sprintf("error preparing target: %v", err))
slog.Error(fmt.Sprintf("error preparing target %s: %v", myTarget.GetName(), err))
channelError <- nil
Comment thread
harp-intel marked this conversation as resolved.
return
}
channelSetComplete := make(chan setOutput)
var successMessages []string
var errorMessages []string
Expand Down
73 changes: 38 additions & 35 deletions cmd/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func setLlcSize(desiredLlcSize float64, myTarget target.Target, localTempDir str
ScriptTemplate: fmt.Sprintf("wrmsr -a 0xC90 %d", msrVal),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
Lkms: []string{"msr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
Comment thread
harp-intel marked this conversation as resolved.
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -227,7 +227,8 @@ func setCoreFrequency(coreFrequency float64, myTarget target.Target, localTempDi
ScriptTemplate: fmt.Sprintf("wrmsr 0x774 %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
} else {
value := freqInt << uint(2*8)
Expand All @@ -236,7 +237,8 @@ func setCoreFrequency(coreFrequency float64, myTarget target.Target, localTempDi
ScriptTemplate: fmt.Sprintf("wrmsr 0x199 %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
}
} else {
Expand All @@ -250,7 +252,8 @@ func setCoreFrequency(coreFrequency float64, myTarget target.Target, localTempDi
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x1AD %d", value),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
}
_, err = runScript(myTarget, setScript, localTempDir)
Expand Down Expand Up @@ -333,9 +336,9 @@ func setUncoreFrequency(maxFreq bool, uncoreFrequency float64, myTarget target.T
Name: "get uncore frequency MSR",
ScriptTemplate: "rdmsr 0x620",
Vendors: []string{"GenuineIntel"},
Depends: []string{"rdmsr"},
Lkms: []string{"msr"},
Superuser: true,
// Depends: []string{"rdmsr"},
// Lkms: []string{"msr"},
})
outputs, err := script.RunScripts(myTarget, scripts, true, localTempDir)
if err != nil {
Expand Down Expand Up @@ -379,8 +382,8 @@ func setUncoreFrequency(maxFreq bool, uncoreFrequency float64, myTarget target.T
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x620 %d", newVal),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand All @@ -395,8 +398,8 @@ func setTDP(power int, myTarget target.Target, localTempDir string, completeChan
ScriptTemplate: "rdmsr 0x610",
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
readOutput, err := script.RunScript(myTarget, readScript, localTempDir)
if err != nil {
Expand All @@ -418,8 +421,8 @@ func setTDP(power int, myTarget target.Target, localTempDir string, completeChan
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x610 %d", newVal),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err := runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -457,9 +460,9 @@ func setEPB(epb int, myTarget target.Target, localTempDir string, completeChanne
Name: "read " + msr,
ScriptTemplate: "rdmsr " + msr,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
readOutput, err := runScript(myTarget, readScript, localTempDir)
if err != nil {
Expand All @@ -481,8 +484,8 @@ func setEPB(epb int, myTarget target.Target, localTempDir string, completeChanne
ScriptTemplate: fmt.Sprintf("wrmsr -a %s %d", msr, msrValue),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand All @@ -500,9 +503,9 @@ func setEPP(epp int, myTarget target.Target, localTempDir string, completeChanne
Name: "get epp msr",
ScriptTemplate: "rdmsr 0x774", // IA32_HWP_REQUEST
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
stdout, err := runScript(myTarget, getScript, localTempDir)
if err != nil {
Expand All @@ -524,8 +527,8 @@ func setEPP(epp int, myTarget target.Target, localTempDir string, completeChanne
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x774 %d", eppValue),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand All @@ -537,9 +540,9 @@ func setEPP(epp int, myTarget target.Target, localTempDir string, completeChanne
Name: "get epp pkg msr",
ScriptTemplate: "rdmsr 0x772", // IA32_HWP_REQUEST_PKG
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
stdout, err = runScript(myTarget, getScript, localTempDir)
if err != nil {
Expand All @@ -561,8 +564,8 @@ func setEPP(epp int, myTarget target.Target, localTempDir string, completeChanne
ScriptTemplate: fmt.Sprintf("wrmsr -a 0x772 %d", eppValue),
Superuser: true,
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -601,7 +604,7 @@ func setELC(elc string, myTarget target.Target, localTempDir string, completeCha
Superuser: true,
Vendors: []string{"GenuineIntel"},
Models: []string{"173", "174", "175", "221"}, // GNR, GNR-D, SRF, CWF
Depends: []string{"bhs-power-mode.sh"},
Depends: []string{"bhs-power-mode.sh", "pcm-tpmi"},
}
_, err := runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -642,9 +645,9 @@ func setPrefetcher(enableDisable string, myTarget target.Target, localTempDir st
Name: "get prefetcher msr",
ScriptTemplate: fmt.Sprintf("rdmsr %d", pf.Msr),
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
stdout, err := runScript(myTarget, getScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -675,10 +678,10 @@ func setPrefetcher(enableDisable string, myTarget target.Target, localTempDir st
setScript := script.ScriptDefinition{
Name: "set prefetcher" + prefetcherType,
ScriptTemplate: fmt.Sprintf("wrmsr -a %d %d", pf.Msr, newVal),
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
Superuser: true,
Vendors: []string{"GenuineIntel"},
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -747,9 +750,9 @@ func setC1Demotion(enableDisable string, myTarget target.Target, localTempDir st
Name: "get C1 demotion",
ScriptTemplate: "rdmsr 0xe2",
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"rdmsr"},
Superuser: true,
// Lkms: []string{"msr"},
// Depends: []string{"rdmsr"},
}
stdout, err := runScript(myTarget, getScript, localTempDir)
if err != nil {
Expand Down Expand Up @@ -782,9 +785,9 @@ func setC1Demotion(enableDisable string, myTarget target.Target, localTempDir st
Name: "set C1 demotion",
ScriptTemplate: fmt.Sprintf("wrmsr -a %d %d", 0xe2, newVal),
Vendors: []string{"GenuineIntel"},
Lkms: []string{"msr"},
Depends: []string{"wrmsr"},
Superuser: true,
// Depends: []string{"wrmsr"},
// Lkms: []string{"msr"},
}
_, err = runScript(myTarget, setScript, localTempDir)
if err != nil {
Expand Down