Skip to content
Draft
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
10 changes: 10 additions & 0 deletions assets/performanceprofile/tuned/openshift-node-performance
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,14 @@ cmdline_pstate=+intel_pstate=passive
cmdline_pstate=+intel_pstate=disable
{{end}}

{{ if .ReservedCpuMaxFreq }}
{{- "[sysfs]" -}}
{{ range .ReservedCpuList }}
/sys/devices/system/cpu/cpufreq/policy[{{.}}]/scaling_max_freq={{$.ReservedCpuMaxFreq}}
{{- if $.ReservedCpuMinFreq }}
/sys/devices/system/cpu/cpufreq/policy[{{.}}]/scaling_min_freq={{$.ReservedCpuMinFreq}}
{{- end -}}
{{ end }}
{{ end }}

[rtentsk]
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ spec:
description: Reserved defines a set of CPUs that will not be used
for any container workloads initiated by kubelet.
type: string
reservedCpuMaxFreq:
description: ReservedCpuMaxFreq defines the maximum cpu frequency for reserved CPUs.
type: integer
reservedCpuMinFreq:
description: ReservedCpuMinFreq defines the maximum cpu frequency for reserved CPUs.
type: integer
required:
- isolated
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ spec:
isolated: "2"
reserved: "0-1"
offlined: "3"
reservedCpuMaxFreq: 2800000
reservedCpuMinFreq: 2600000
hugepages:
defaultHugepagesSize: "1G"
pages:
Expand Down
6 changes: 6 additions & 0 deletions manifests/20-performance-profile.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ spec:
description: Reserved defines a set of CPUs that will not be used
for any container workloads initiated by kubelet.
type: string
reservedCpuMaxFreq:
description: ReservedCpuMaxFreq defines the maximum cpu frequency for reserved CPUs.
type: integer
reservedCpuMinFreq:
description: ReservedCpuMinFreq defines the maximum cpu frequency for reserved CPUs.
type: integer
required:
- isolated
type: object
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/performanceprofile/v1/performanceprofile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type PerformanceProfileSpec struct {

// CPUSet defines the set of CPUs(0-3,8-11).
type CPUSet string
type CPUfrequency int

// CPU defines a set of CPU related features.
type CPU struct {
Expand All @@ -102,6 +103,12 @@ type CPU struct {
// Offline defines a set of CPUs that will be unused and set offline
// +optional
Offlined *CPUSet `json:"offlined,omitempty"`
//
// +optional
ReservedCpuMaxFreq *CPUfrequency `json:"reservedCpuMaxFreq,omitempty"`
//
// +optional
ReservedCpuMinFreq *CPUfrequency `json:"reservedCpuMinFreq,omitempty"`
}

// HugePageSize defines size of huge pages, can be 2M or 1G.
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/performanceprofile/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ func (curr *PerformanceProfile) ConvertTo(dstRaw conversion.Hub) error {
if curr.Spec.CPU.BalanceIsolated != nil {
dst.Spec.CPU.BalanceIsolated = pointer.BoolPtr(*curr.Spec.CPU.BalanceIsolated)
}
//test
if curr.Spec.CPU.ReservedCpuMaxFreq != nil {
maxCpuFrequency := v1.CPUfrequency(*curr.Spec.CPU.ReservedCpuMaxFreq)
dst.Spec.CPU.ReservedCpuMaxFreq = &maxCpuFrequency
}
if curr.Spec.CPU.ReservedCpuMinFreq != nil {
minCpuFrequency := v1.CPUfrequency(*curr.Spec.CPU.ReservedCpuMaxFreq)
dst.Spec.CPU.ReservedCpuMinFreq = &minCpuFrequency
}
}

if curr.Spec.HugePages != nil {
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/performanceprofile/v2/performanceprofile_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type PerformanceProfileSpec struct {

// CPUSet defines the set of CPUs(0-3,8-11).
type CPUSet string
type CPUfrequency int

// CPU defines a set of CPU related features.
type CPU struct {
Expand All @@ -110,6 +111,12 @@ type CPU struct {
// Offline defines a set of CPUs that will be unused and set offline
// +optional
Offlined *CPUSet `json:"offlined,omitempty"`
//
// +optional
ReservedCpuMaxFreq *CPUfrequency `json:"reservedCpuMaxFreq,omitempty"`
//
// +optional
ReservedCpuMinFreq *CPUfrequency `json:"reservedCpuMinFreq,omitempty"`
}

// HugePageSize defines size of huge pages, can be 2M or 1G.
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/performanceprofile/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
templateRealTimeHint = "RealTimeHint"
templateHighPowerConsumption = "HighPowerConsumption"
templatePerPodPowerManagement = "PerPodPowerManagement"
templateReservedCpuMaxFreq = "ReservedCpuMaxFreq"
templateReservedCpuMinFreq = "ReservedCpuMinFreq"
templateReservedCpuList = "ReservedCpuList"
)

func new(name string, profiles []tunedv1.TunedProfile, recommends []tunedv1.TunedRecommend) *tunedv1.Tuned {
Expand All @@ -53,7 +56,8 @@ func new(name string, profiles []tunedv1.TunedProfile, recommends []tunedv1.Tune

// NewNodePerformance returns tuned profile for performance sensitive workflows
func NewNodePerformance(profile *performancev2.PerformanceProfile) (*tunedv1.Tuned, error) {
templateArgs := make(map[string]string)
// templateArgs := make(map[string]string)
templateArgs := make(map[string]interface{})

if profile.Spec.CPU.Isolated != nil {
templateArgs[templateIsolatedCpus] = string(*profile.Spec.CPU.Isolated)
Expand All @@ -62,6 +66,19 @@ func NewNodePerformance(profile *performancev2.PerformanceProfile) (*tunedv1.Tun
}
}

if profile.Spec.CPU.Reserved != nil && profile.Spec.CPU.ReservedCpuMaxFreq != nil {

reservedSet, err := cpuset.Parse(string(*profile.Spec.CPU.Reserved))
if err != nil {
return nil, err
}

reservedCPuList := reservedSet.List()
templateArgs[templateReservedCpuList] = reservedCPuList
templateArgs[templateReservedCpuMaxFreq] = int(*profile.Spec.CPU.ReservedCpuMaxFreq)
templateArgs[templateReservedCpuMinFreq] = int(*profile.Spec.CPU.ReservedCpuMinFreq)
}

if profile.Spec.HugePages != nil {
var defaultHugepageSize performancev2.HugePageSize
if profile.Spec.HugePages.DefaultHugePagesSize != nil {
Expand Down
14 changes: 11 additions & 3 deletions pkg/performanceprofile/utils/testing/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const (
IsolatedCPUs = performancev2.CPUSet("4-5")
// ReservedCPUs defines the reserved CPU set used for tests
ReservedCPUs = performancev2.CPUSet("0-3")
//test
ReservedCpuMaxFreq = performancev2.CPUfrequency(2800000)
//test
ReservedCpuMinFreq = performancev2.CPUfrequency(2500000)
// OfflinedCPUs defines the Offline CPU set used for tests
OfflinedCPUs = performancev2.CPUSet("6-7") // SingleNUMAPolicy defines the topologyManager policy used for tests
SingleNUMAPolicy = "single-numa-node"
Expand All @@ -42,6 +46,8 @@ func NewPerformanceProfile(name string) *performancev2.PerformanceProfile {
size := HugePageSize
isolatedCPUs := IsolatedCPUs
reservedCPUs := ReservedCPUs
reservedCpuMaxFreq := ReservedCpuMaxFreq
reservedCpuMinFreq := ReservedCpuMinFreq
offlineCPUs := OfflinedCPUs
numaPolicy := SingleNUMAPolicy
additionalKernelArgs := AdditionalKernelArgs
Expand All @@ -54,9 +60,11 @@ func NewPerformanceProfile(name string) *performancev2.PerformanceProfile {
},
Spec: performancev2.PerformanceProfileSpec{
CPU: &performancev2.CPU{
Isolated: &isolatedCPUs,
Reserved: &reservedCPUs,
Offlined: &offlineCPUs,
Isolated: &isolatedCPUs,
Reserved: &reservedCPUs,
Offlined: &offlineCPUs,
ReservedCpuMaxFreq: &reservedCpuMaxFreq,
ReservedCpuMinFreq: &reservedCpuMinFreq,
},
HugePages: &performancev2.HugePages{
DefaultHugePagesSize: &size,
Expand Down