|
@@ -814,14 +814,20 @@ int sched_tick_bsp(void)
|
|
|
{
|
|
{
|
|
|
struct cpu *c = this_cpu();
|
|
struct cpu *c = this_cpu();
|
|
|
struct process *p;
|
|
struct process *p;
|
|
|
- unsigned int flags = sched_lock_acquire();
|
|
|
|
|
|
|
+ unsigned int flags, ms;
|
|
|
int r;
|
|
int r;
|
|
|
|
|
|
|
|
|
|
+ /* Read the period this tick covered before anything else: waking a
|
|
|
|
|
+ * sleeper shortens the next period (smp_resched_wake() reprograms the
|
|
|
|
|
+ * PIT and sets tick_ms to 1), and charging the elapsed tick with the
|
|
|
|
|
+ * new value made every 10 ms idle tick look like 1 ms of idle. */
|
|
|
|
|
+ ms = timer_tick_ms();
|
|
|
|
|
+ flags = sched_lock_acquire();
|
|
|
thermal_tick();
|
|
thermal_tick();
|
|
|
p = c->current;
|
|
p = c->current;
|
|
|
- power_tick(p == c->idle, timer_tick_ms());
|
|
|
|
|
|
|
+ power_tick(p == c->idle, ms);
|
|
|
wake_sleepers_locked();
|
|
wake_sleepers_locked();
|
|
|
- r = tick_decide_locked(c, p, 0, timer_tick_ms());
|
|
|
|
|
|
|
+ r = tick_decide_locked(c, p, 0, ms);
|
|
|
sched_lock_release(flags);
|
|
sched_lock_release(flags);
|
|
|
return r;
|
|
return r;
|
|
|
}
|
|
}
|
|
@@ -833,12 +839,13 @@ int sched_tick_ap(void)
|
|
|
struct cpu *c = this_cpu();
|
|
struct cpu *c = this_cpu();
|
|
|
struct process *p;
|
|
struct process *p;
|
|
|
unsigned int flags = sched_lock_acquire();
|
|
unsigned int flags = sched_lock_acquire();
|
|
|
|
|
+ unsigned int ms = c->tick_ms;
|
|
|
int r;
|
|
int r;
|
|
|
|
|
|
|
|
thermal_tick();
|
|
thermal_tick();
|
|
|
p = c->current;
|
|
p = c->current;
|
|
|
- power_tick(p == c->idle, c->tick_ms);
|
|
|
|
|
- r = tick_decide_locked(c, p, 1, c->tick_ms);
|
|
|
|
|
|
|
+ power_tick(p == c->idle, ms);
|
|
|
|
|
+ r = tick_decide_locked(c, p, 1, ms);
|
|
|
if (!r && p == c->idle && c->tick_ms != 10) {
|
|
if (!r && p == c->idle && c->tick_ms != 10) {
|
|
|
/* Entered idle without a schedule(): stretch this CPU's LAPIC
|
|
/* Entered idle without a schedule(): stretch this CPU's LAPIC
|
|
|
* period so MWAIT can hold C2 for 10 ms. */
|
|
* period so MWAIT can hold C2 for 10 ms. */
|