History

sched/fair: Don't push cfs_bandwith slack timers forward

When a cfs_rq sleeps and returns its quota, we delay for 5ms before waking any throttled cfs_rqs to coalesce with other cfs_rqs going to sleep, as this has to be done outside of the rq lock we hold. The current code waits for 5ms without any sleeps, instead of waiting for 5ms from the first sleep, which can delay the unthrottle more than we want. Switch this around so that we can't push this forward forever. This requires an extra flag rather than using hrtimer_active, since we need to start a new timer if the current one is in the process of finishing.

bsegall@google.com committed 7 years ago

Commit 66567fc1 parent aacedf22 files · +11 −4Browse files

Unified · Split

2 files
  1. kernel/sched/fair.c +7 −0
  2. kernel/sched/sched.h +4 −4
kernel/sched/fair.c+7−0
@@ -4729,6 +4729,11 @@ static void start_cfs_slack_bandwidth(struct cfs_bandwidth *cfs_b) · 4728 unmodified lines
47294729 if (runtime_refresh_within(cfs_b, min_left))
47304730 return;
47314731
4732+ /* don't push forwards an existing deferred unthrottle */
4733+ if (cfs_b->slack_started)
4734+ return;
4735+ cfs_b->slack_started = true;
4736+
47324737 hrtimer_start(&cfs_b->slack_timer,
47334738 ns_to_ktime(cfs_bandwidth_slack_period),
47344739 HRTIMER_MODE_REL);
@@ -4782,6 +4787,7 @@ static void do_sched_cfs_slack_timer(struct cfs_bandwidth *cfs_b) · 47 unmodified lines
47824787
47834788 /* confirm we're still not at a refresh boundary */
47844789 raw_spin_lock_irqsave(&cfs_b->lock, flags);
4790+ cfs_b->slack_started = false;
47854791 if (cfs_b->distribute_running) {
47864792 raw_spin_unlock_irqrestore(&cfs_b->lock, flags);
47874793 return;
@@ -4945,6 +4951,7 @@ void init_cfs_bandwidth(struct cfs_bandwidth *cfs_b) · 157 unmodified lines
49454951 hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
49464952 cfs_b->slack_timer.function = sched_cfs_slack_timer;
49474953 cfs_b->distribute_running = 0;
4954+ cfs_b->slack_started = false;
49484955 }
49494956
49504957 static void init_cfs_rq_runtime(struct cfs_rq *cfs_rq)
kernel/sched/sched.h+4−4
@@ -338,8 +338,10 @@ struct cfs_bandwidth { · 337 unmodified lines
338338 u64 runtime_expires;
339339 int expires_seq;
340340
341− short idle;
342− short period_active;
341+ u8 idle;
342+ u8 period_active;
343+ u8 distribute_running;
344+ u8 slack_started;
343345 struct hrtimer period_timer;
344346 struct hrtimer slack_timer;
345347 struct list_head throttled_cfs_rq;
@@ -348,8 +350,6 @@ struct cfs_bandwidth { · 2 unmodified lines
348350 int nr_periods;
349351 int nr_throttled;
350352 u64 throttled_time;
351−
352− bool distribute_running;
353353 #endif
354354 };
355355

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t