Skip to content

Commit 682ef1a

Browse files
committed
pap: level p1 is treated as noop
1 parent 31f78ee commit 682ef1a

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

pkg/agent/sysadvisor/plugin/poweraware/advisor/action/strategy/evict_first.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ type CapperProber interface {
4949
// evictFirstStrategy always attempts to evict low priority pods if any; only after all are exhausted will it resort to DVFS means.
5050
// besides, it will continue to try the best to meet the alert spec, regardless of the alert update time.
5151
// alert level has the following meanings in this strategy:
52-
// P1 - eviction only;
52+
// P2 - noop and expecting scheduler to bias against the node
53+
// P1 - noop and expecting scheduler not to schedule to the node
5354
// P0 - evict if applicable; otherwise conduct DVFS once if needed (DVFS is limited to 10%);
5455
// S0 - DVFS in urgency (no limit on DVFS)
5556
type evictFirstStrategy struct {
@@ -95,16 +96,17 @@ func (e *evictFirstStrategy) recommendEvictFirstOp() spec.InternalOp {
9596

9697
func (e *evictFirstStrategy) recommendOp(alert spec.PowerAlert, internalOp spec.InternalOp) spec.InternalOp {
9798
if internalOp != spec.InternalOpAuto {
98-
return internalOp
99+
// internal op is only applicable to dvfs related levels, i.e. s0 + p0
100+
if alert == spec.PowerAlertS0 || alert == spec.PowerAlertP0 {
101+
return internalOp
102+
}
99103
}
100104

101105
switch alert {
102106
case spec.PowerAlertS0:
103107
return spec.InternalOpFreqCap
104108
case spec.PowerAlertP0:
105109
return e.recommendEvictFirstOp()
106-
case spec.PowerAlertP1:
107-
return spec.InternalOpEvict
108110
default:
109111
return spec.InternalOpNoop
110112
}
@@ -126,8 +128,8 @@ func (e *evictFirstStrategy) adjustTargetForConstraintDVFS(actualWatt, desiredWa
126128
func (e *evictFirstStrategy) yieldActionPlan(op, internalOp spec.InternalOp, actualWatt, desiredWatt int, alert spec.PowerAlert, ttl time.Duration) action.PowerAction {
127129
switch op {
128130
case spec.InternalOpFreqCap:
129-
// try to conduct freq capping within the allowed limit if not set for hard dvfs
130-
if internalOp != spec.InternalOpFreqCap && !(alert == spec.PowerAlertS0 && internalOp == spec.InternalOpAuto) {
131+
// try to conduct freq capping within the allowed limit except for the unconstrained dvfs
132+
if alert != spec.PowerAlertS0 {
131133
var err error
132134
desiredWatt, err = e.adjustTargetForConstraintDVFS(actualWatt, desiredWatt)
133135
if err != nil {

pkg/agent/sysadvisor/plugin/poweraware/advisor/action/strategy/evict_first_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,55 @@ func Test_evictFirstStrategy_RecommendAction(t *testing.T) {
6969
wantInDVFS bool
7070
}{
7171
{
72-
name: "internal op is always respected if exists",
72+
name: "plan of s0 always targets full range",
7373
fields: fields{
7474
coefficient: exponentialDecay{},
7575
evictableProber: nil,
7676
dvfsUsed: 0,
7777
},
7878
args: args{
79+
alert: spec.PowerAlertS0,
7980
actualWatt: 100,
8081
desiredWatt: 80,
81-
internalOp: spec.InternalOpFreqCap,
8282
},
8383
want: action.PowerAction{
8484
Op: spec.InternalOpFreqCap,
8585
Arg: 80,
8686
},
8787
wantInDVFS: true,
8888
},
89+
{
90+
name: "plan of p0 is constraint when allowing dvfs only",
91+
fields: fields{
92+
coefficient: exponentialDecay{},
93+
evictableProber: nil,
94+
dvfsUsed: 0,
95+
},
96+
args: args{
97+
alert: spec.PowerAlertP0,
98+
actualWatt: 100,
99+
desiredWatt: 80,
100+
internalOp: spec.InternalOpFreqCap,
101+
},
102+
want: action.PowerAction{
103+
Op: spec.InternalOpFreqCap,
104+
Arg: 90,
105+
},
106+
wantInDVFS: true,
107+
},
108+
{
109+
name: "p1 is noop",
110+
fields: fields{},
111+
args: args{
112+
actualWatt: 100,
113+
desiredWatt: 80,
114+
alert: spec.PowerAlertP1,
115+
},
116+
want: action.PowerAction{
117+
Op: spec.InternalOpNoop,
118+
Arg: 0,
119+
},
120+
},
89121
{
90122
name: "p2 is noop",
91123
fields: fields{},

0 commit comments

Comments
 (0)