Skip to content

Commit

Permalink
sched/fair: Reduce the window for duplicated update
Browse files Browse the repository at this point in the history
Start to update last_blocked_load_update_tick to reduce the possibility
of another cpu starting the update one more time

Signed-off-by: Vincent Guittot <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Reviewed-by: Valentin Schneider <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
vingu-linaro authored and Ingo Molnar committed Mar 6, 2021
1 parent c6f8865 commit 39b6a42
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -7852,16 +7852,20 @@ static inline bool others_have_blocked(struct rq *rq)
return false;
}

static inline void update_blocked_load_status(struct rq *rq, bool has_blocked)
static inline void update_blocked_load_tick(struct rq *rq)
{
rq->last_blocked_load_update_tick = jiffies;
WRITE_ONCE(rq->last_blocked_load_update_tick, jiffies);
}

static inline void update_blocked_load_status(struct rq *rq, bool has_blocked)
{
if (!has_blocked)
rq->has_blocked_load = 0;
}
#else
static inline bool cfs_rq_has_blocked(struct cfs_rq *cfs_rq) { return false; }
static inline bool others_have_blocked(struct rq *rq) { return false; }
static inline void update_blocked_load_tick(struct rq *rq) {}
static inline void update_blocked_load_status(struct rq *rq, bool has_blocked) {}
#endif

Expand Down Expand Up @@ -8022,6 +8026,7 @@ static void update_blocked_averages(int cpu)
struct rq_flags rf;

rq_lock_irqsave(rq, &rf);
update_blocked_load_tick(rq);
update_rq_clock(rq);

decayed |= __update_blocked_others(rq, &done);
Expand Down Expand Up @@ -8363,7 +8368,7 @@ static bool update_nohz_stats(struct rq *rq)
if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
return false;

if (!time_after(jiffies, rq->last_blocked_load_update_tick))
if (!time_after(jiffies, READ_ONCE(rq->last_blocked_load_update_tick)))
return true;

update_blocked_averages(cpu);
Expand Down

0 comments on commit 39b6a42

Please sign in to comment.