Skip to content

Commit

Permalink
cpuidle: add sched_clock_idle_[sleep|wakeup]_event() hooks
Browse files Browse the repository at this point in the history
Port 2aa44d0
(sched: sched_clock_idle_[sleep|wakeup]_event()) to cpuidle.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Venkatesh Pallipadi authored and Len Brown committed Nov 20, 2007
1 parent c9c860e commit 5062911
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
struct acpi_processor *pr;
struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
u32 t1, t2;
int sleep_ticks = 0;

pr = processors[smp_processor_id()];

if (unlikely(!pr))
Expand Down Expand Up @@ -1440,6 +1442,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
ACPI_FLUSH_CPU_CACHE();

t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
/* Tell the scheduler that we are going deep-idle: */
sched_clock_idle_sleep_event();
acpi_state_timer_broadcast(pr, cx, 1);
acpi_idle_do_entry(cx);
t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
Expand All @@ -1448,14 +1452,18 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
/* TSC could halt in idle, so notify users */
mark_tsc_unstable("TSC halts in idle");;
#endif
sleep_ticks = ticks_elapsed(t1, t2);

/* Tell the scheduler how much we idled: */
sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);

local_irq_enable();
current_thread_info()->status |= TS_POLLING;

cx->usage++;

acpi_state_timer_broadcast(pr, cx, 0);
cx->time += ticks_elapsed(t1, t2);
cx->time += sleep_ticks;
return ticks_elapsed_in_us(t1, t2);
}

Expand All @@ -1475,6 +1483,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
struct acpi_processor *pr;
struct acpi_processor_cx *cx = cpuidle_get_statedata(state);
u32 t1, t2;
int sleep_ticks = 0;

pr = processors[smp_processor_id()];

if (unlikely(!pr))
Expand All @@ -1497,6 +1507,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
return 0;
}

/* Tell the scheduler that we are going deep-idle: */
sched_clock_idle_sleep_event();
/*
* Must be done before busmaster disable as we might need to
* access HPET !
Expand Down Expand Up @@ -1552,14 +1564,17 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
/* TSC could halt in idle, so notify users */
mark_tsc_unstable("TSC halts in idle");
#endif
sleep_ticks = ticks_elapsed(t1, t2);
/* Tell the scheduler how much we idled: */
sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);

local_irq_enable();
current_thread_info()->status |= TS_POLLING;

cx->usage++;

acpi_state_timer_broadcast(pr, cx, 0);
cx->time += ticks_elapsed(t1, t2);
cx->time += sleep_ticks;
return ticks_elapsed_in_us(t1, t2);
}

Expand Down

0 comments on commit 5062911

Please sign in to comment.