cpuidle: suspend/resume scheduler tick timer during cpu idle state entry/exit

cpuidle can collaborate with scheduler to reduce unnecessary timer
interrupt. For example, credit scheduler accounting timer
doesn't need to be active at idle time, so it can be stopped at
cpuidle entry and resumed at cpuidle exit. This patch implements this
function by adding two ops in scheduler: tick_suspend/tick_resume, and
implement them for credit scheduler

Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Tian Kevin <kevin.tian@intel.com>
This commit is contained in:
Keir Fraser committed 2009-03-31 11:51:56 +01:00
1 parent f02c18fff7
commit 964fae8ac2
5 files changed
+64 -14

No files matched your search

+14
View File
@@ -195,6 +195,15 @@ static void acpi_processor_idle(void)
int sleep_ticks = 0;
u32 t1, t2 = 0;
sched_tick_suspend();
/*
* sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer,
* which will break the later assumption of no sofirq pending,
* so add do_softirq
*/
if ( softirq_pending(smp_processor_id()) )
do_softirq();
/*
* Interrupts must be disabled during bus mastering calculations and
* for C2/C3 transitions.
@@ -204,6 +213,7 @@ static void acpi_processor_idle(void)
if ( softirq_pending(smp_processor_id()) )
{
local_irq_enable();
sched_tick_resume();
return;
}
@@ -223,6 +233,7 @@ static void acpi_processor_idle(void)
pm_idle_save();
else
acpi_safe_halt();
sched_tick_resume();
return;
}
@@ -329,6 +340,7 @@ static void acpi_processor_idle(void)
default:
local_irq_enable();
sched_tick_resume();
return;
}
@@ -339,6 +351,8 @@ static void acpi_processor_idle(void)
cx->time += sleep_ticks;
}
sched_tick_resume();
if ( cpuidle_current_governor->reflect )
cpuidle_current_governor->reflect(power);
}
+35 -14
View File
@@ -154,6 +154,7 @@ struct csched_private {
spinlock_t lock;
struct list_head active_sdom;
uint32_t ncpus;
struct timer master_ticker;
unsigned int master;
cpumask_t idlers;
uint32_t weight;
@@ -757,7 +758,7 @@ csched_runq_sort(unsigned int cpu)
}
static void
csched_acct(void)
csched_acct(void* dummy)
{
unsigned long flags;
struct list_head *iter_vcpu, *next_vcpu;
@@ -792,7 +793,7 @@ csched_acct(void)
csched_priv.credit_balance = 0;
spin_unlock_irqrestore(&csched_priv.lock, flags);
CSCHED_STAT_CRANK(acct_no_work);
return;
goto out;
}
CSCHED_STAT_CRANK(acct_run);
@@ -950,6 +951,10 @@ csched_acct(void)
/* Inform each CPU that its runq needs to be sorted */
csched_priv.runq_sort++;
out:
set_timer( &csched_priv.master_ticker, NOW() +
MILLISECS(CSCHED_MSECS_PER_TICK) * CSCHED_TICKS_PER_ACCT );
}
static void
@@ -966,18 +971,6 @@ csched_tick(void *_cpu)
if ( !is_idle_vcpu(current) )
csched_vcpu_acct(cpu);
/*
* Host-wide accounting duty
*
* Note: Currently, this is always done by the master boot CPU. Eventually,
* we could distribute or at the very least cycle the duty.
*/
if ( (csched_priv.master == cpu) &&
(spc->tick % CSCHED_TICKS_PER_ACCT) == 0 )
{
csched_acct();
}
/*
* Check if runq needs to be sorted
*
@@ -1310,10 +1303,35 @@ static __init int csched_start_tickers(void)
set_timer(&spc->ticker, NOW() + MILLISECS(CSCHED_MSECS_PER_TICK));
}
init_timer( &csched_priv.master_ticker, csched_acct, NULL,
csched_priv.master);
set_timer( &csched_priv.master_ticker, NOW() +
MILLISECS(CSCHED_MSECS_PER_TICK) * CSCHED_TICKS_PER_ACCT );
return 0;
}
__initcall(csched_start_tickers);
static void csched_tick_suspend(void)
{
struct csched_pcpu *spc;
spc = CSCHED_PCPU(smp_processor_id());
stop_timer(&spc->ticker);
}
static void csched_tick_resume(void)
{
struct csched_pcpu *spc;
uint64_t now = NOW();
spc = CSCHED_PCPU(smp_processor_id());
set_timer(&spc->ticker, now + MILLISECS(CSCHED_MSECS_PER_TICK)
- now % MILLISECS(CSCHED_MSECS_PER_TICK) );
}
struct scheduler sched_credit_def = {
.name = "SMP Credit Scheduler",
@@ -1337,4 +1355,7 @@ struct scheduler sched_credit_def = {
.dump_cpu_state = csched_dump_pcpu,
.dump_settings = csched_dump,
.init = csched_init,
.tick_suspend = csched_tick_suspend,
.tick_resume = csched_tick_resume,
};
+10
View File
@@ -964,6 +964,16 @@ void dump_runq(unsigned char key)
local_irq_restore(flags);
}
void sched_tick_suspend(void)
{
SCHED_OP(tick_suspend);
}
void sched_tick_resume(void)
{
SCHED_OP(tick_resume);
}
#ifdef CONFIG_COMPAT
#include "compat/schedule.c"
#endif
+3
View File
@@ -77,6 +77,9 @@ struct scheduler {
struct xen_domctl_scheduler_op *);
void (*dump_settings) (void);
void (*dump_cpu_state) (int);
void (*tick_suspend) (void);
void (*tick_resume) (void);
};
#endif /* __XEN_SCHED_IF_H__ */
+2
View File
@@ -428,6 +428,8 @@ int sched_init_domain(struct domain *d);
void sched_destroy_domain(struct domain *d);
long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
int sched_id(void);
void sched_tick_suspend(void);
void sched_tick_resume(void);
void vcpu_wake(struct vcpu *d);
void vcpu_sleep_nosync(struct vcpu *d);
void vcpu_sleep_sync(struct vcpu *d);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.