Skip to content

Commit ad0cd94

Browse files
committed
Add new scaling parameters
Signed-off-by: Rafal Lal <[email protected]>
1 parent bf4edac commit ad0cd94

8 files changed

+81
-21
lines changed

api/v1/cpuscalingconfiguration_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ type ConfigItem struct {
3636
//+kubebuilder:validation:Format=duration
3737
SamplePeriod metav1.Duration `json:"samplePeriod"`
3838

39+
// Minimum time to elapse after setting CPU frequency
40+
//+kubebuilder:validation:Format=duration
41+
CooldownPeriod metav1.Duration `json:"cooldownPeriod"`
42+
43+
// Target of CPU busyness in percents
44+
// +kubebuilder:validation:Minimum=0
45+
// +kubebuilder:validation:Maximum=100
46+
TargetBusyness int `json:"targetBusyness"`
47+
48+
// Max difference between target and actual CPU busyness on which
49+
// frequency re-evaluation won't happen in percent points
50+
// +kubebuilder:validation:Minimum=0
51+
// +kubebuilder:validation:Maximum=100
52+
AllowedBusynessDifference int `json:"allowedBusynessDifference"`
53+
3954
// UID of the Pod that this ConfigItem is associated with
4055
PodUID types.UID `json:"podUID"`
4156
}

api/v1/cpuscalingprofile_types.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,33 @@ import (
2525

2626
// CPUScalingProfileSpec defines the desired state of CPUScalingProfile
2727
type CPUScalingProfileSpec struct {
28-
// Name of the CPUScalingProfile
29-
Name string `json:"name"`
30-
3128
// Minimum time to elapse between two CPU sample periods
3229
//+kubebuilder:validation:Format=duration
33-
//+kubebuilder:default="10ms"
3430
SamplePeriod metav1.Duration `json:"samplePeriod,omitempty"`
3531

32+
// Minimum time to elapse after setting CPU frequency
33+
//+kubebuilder:validation:Format=duration
34+
CooldownPeriod metav1.Duration `json:"cooldownPeriod,omitempty"`
35+
36+
// Target of CPU busyness in percents
37+
// +kubebuilder:validation:Minimum=0
38+
// +kubebuilder:validation:Maximum=100
39+
TargetBusyness int `json:"targetBusyness,omitempty"`
40+
41+
// Max difference between target and actual CPU busyness on which
42+
// frequency re-evaluation won't happen in percent points
43+
// +kubebuilder:validation:Minimum=0
44+
// +kubebuilder:validation:Maximum=100
45+
AllowedBusynessDifference int `json:"allowedBusynessDifference,omitempty"`
46+
3647
// Minimum frequency cores can run at
3748
Min int `json:"min,omitempty"`
3849

3950
// Maximum frequency cores can run at
4051
Max int `json:"max,omitempty"`
4152

4253
// The priority value associated with this CPUScalingProfile
43-
Epp string `json:"epp,omitempty"`
54+
EPP string `json:"epp,omitempty"`
4455
}
4556

4657
// CPUScalingProfileStatus defines the observed state of CPUScalingProfile

api/v1/zz_generated.deepcopy.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/power.intel.com_cpuscalingconfigurations.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ spec:
4545
description: List of configurations that should be applied on a node.
4646
items:
4747
properties:
48+
allowedBusynessDifference:
49+
description: |-
50+
Max difference between target and actual CPU busyness on which
51+
frequency re-evaluation won't happen in percent points
52+
maximum: 100
53+
minimum: 0
54+
type: integer
55+
cooldownPeriod:
56+
description: Minimum time to elapse after setting CPU frequency
57+
format: duration
58+
type: string
4859
cpuIDs:
4960
description: List of CPU IDs which should adhere to the configuration
5061
in this item
@@ -64,11 +75,19 @@ spec:
6475
description: Minimum time to elapse between two CPU sample periods
6576
format: duration
6677
type: string
78+
targetBusyness:
79+
description: Target of CPU busyness in percents
80+
maximum: 100
81+
minimum: 0
82+
type: integer
6783
required:
84+
- allowedBusynessDifference
85+
- cooldownPeriod
6886
- cpuIDs
6987
- podUID
7088
- powerProfile
7189
- samplePeriod
90+
- targetBusyness
7291
type: object
7392
type: array
7493
type: object

config/crd/bases/power.intel.com_cpuscalingprofiles.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ spec:
3939
spec:
4040
description: CPUScalingProfileSpec defines the desired state of CPUScalingProfile
4141
properties:
42+
allowedBusynessDifference:
43+
description: |-
44+
Max difference between target and actual CPU busyness on which
45+
frequency re-evaluation won't happen in percent points
46+
maximum: 100
47+
minimum: 0
48+
type: integer
49+
cooldownPeriod:
50+
description: Minimum time to elapse after setting CPU frequency
51+
format: duration
52+
type: string
4253
epp:
4354
description: The priority value associated with this CPUScalingProfile
4455
type: string
@@ -48,16 +59,15 @@ spec:
4859
min:
4960
description: Minimum frequency cores can run at
5061
type: integer
51-
name:
52-
description: Name of the CPUScalingProfile
53-
type: string
5462
samplePeriod:
55-
default: 10ms
5663
description: Minimum time to elapse between two CPU sample periods
5764
format: duration
5865
type: string
59-
required:
60-
- name
66+
targetBusyness:
67+
description: Target of CPU busyness in percents
68+
maximum: 100
69+
minimum: 0
70+
type: integer
6171
type: object
6272
status:
6373
description: CPUScalingProfileStatus defines the observed state of CPUScalingProfile

internal/controller/cpuscalingprofile_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *CPUScalingProfileReconciler) createOrUpdatePowerProfile(scalingProfile
117117
Min: scalingProfile.Spec.Min,
118118
Governor: userspaceGovernor,
119119
Shared: false,
120-
Epp: scalingProfile.Spec.Epp,
120+
Epp: scalingProfile.Spec.EPP,
121121
}
122122

123123
if err := controllerutil.SetControllerReference(scalingProfile, powerProfile, r.Scheme); err != nil {

internal/controller/cpuscalingprofile_controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
270270
Min: 2000,
271271
Max: 3000,
272272
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
273-
Epp: "power",
273+
EPP: "power",
274274
},
275275
},
276276
},
@@ -326,7 +326,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
326326
Min: 2000,
327327
Max: 3000,
328328
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
329-
Epp: "power",
329+
EPP: "power",
330330
},
331331
},
332332
&powerv1.PowerProfile{
@@ -430,7 +430,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
430430
Min: 2000,
431431
Max: 3000,
432432
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
433-
Epp: "power",
433+
EPP: "power",
434434
},
435435
},
436436
&powerv1.PowerProfile{
@@ -508,7 +508,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
508508
Min: 2000,
509509
Max: 3000,
510510
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
511-
Epp: "power",
511+
EPP: "power",
512512
},
513513
},
514514
&powerv1.PowerProfile{
@@ -595,7 +595,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
595595
Min: 2000,
596596
Max: 3000,
597597
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
598-
Epp: "power",
598+
EPP: "power",
599599
},
600600
},
601601
&powerv1.PowerProfile{
@@ -676,7 +676,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
676676
Min: 1000,
677677
Max: 2000,
678678
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
679-
Epp: "power",
679+
EPP: "power",
680680
},
681681
},
682682
&powerv1.PowerProfile{
@@ -739,7 +739,7 @@ func TestCPUScalingProfile_Reconcile_PowerProfile(t *testing.T) {
739739
Min: 1000,
740740
Max: 2000,
741741
SamplePeriod: metav1.Duration{Duration: 15 * time.Millisecond},
742-
Epp: "power",
742+
EPP: "power",
743743
},
744744
},
745745
},

internal/scaling/common.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package scaling
33
import "time"
44

55
type CPUScalingOpts struct {
6-
CPUID uint
7-
SamplePeriod time.Duration
6+
CPUID uint
7+
SamplePeriod time.Duration
8+
CooldownPeriod time.Duration
9+
TargetBusyness int
10+
AllowedBusynessDifference int
811
}

0 commit comments

Comments
 (0)