Skip to content

Commit

Permalink
sched: Rate-limit nohz
Browse files Browse the repository at this point in the history
  • Loading branch information
LorDClockaN authored and LeeDrOiD committed Sep 17, 2011
1 parent ebc6028 commit ad2d036
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,17 @@ extern cpumask_var_t nohz_cpu_mask;
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ)
extern int select_nohz_load_balancer(int cpu);
extern int get_nohz_load_balancer(void);
extern int nohz_ratelimit(int cpu);
#else
static inline int select_nohz_load_balancer(int cpu)
{
return 0;
}

static inline int nohz_ratelimit(int cpu)
{
return 0;
}
#endif

/*
Expand Down
11 changes: 11 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,17 @@ void wake_up_idle_cpu(int cpu)
smp_send_reschedule(cpu);
}

int nohz_ratelimit(int cpu)

{
struct rq *rq = cpu_rq(cpu);
u64 diff = rq->clock - rq->nohz_stamp;

rq->nohz_stamp = rq->clock;

return diff < (NSEC_PER_SEC / HZ) >> 1;
}

#endif /* CONFIG_NO_HZ */

static u64 sched_avg_period(void)
Expand Down
3 changes: 3 additions & 0 deletions kernel/time/tick-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ void tick_nohz_stop_sched_tick(int inidle)
goto end;
}

if (nohz_ratelimit(cpu))
goto end;

ts->idle_calls++;
/* Read jiffies and the time when jiffies were updated last */
do {
Expand Down

0 comments on commit ad2d036

Please sign in to comment.