diff -r e122485df37b xen/common/sched_credit.c --- a/xen/common/sched_credit.c Thu Dec 01 16:50:05 2011 +0000 +++ b/xen/common/sched_credit.c Thu Dec 01 16:55:27 2011 +0000 @@ -1307,6 +1307,18 @@ csched_schedule( CSCHED_STAT_CRANK(schedule); CSCHED_VCPU_CHECK(current); + sd = &this_cpu(schedule_data); + sd->s_csnum++; + if ((now - sd->s_src_b) >= MILLISECS(SCHED_SRC_INTERVAL)) + { + if (sd->s_csnum >= SCHED_SRC_THRESHOLD) + sched_ratelimit_us = 1000; + else + sched_ratelimit_us = 0; + sd->s_src_b = now; + sd->s_csnum = 0; + } + runtime = now - current->runstate.state_entry_time; if ( runtime < 0 ) /* Does this ever happen? */ runtime = 0; diff -r e122485df37b xen/common/schedule.c --- a/xen/common/schedule.c Thu Dec 01 16:50:05 2011 +0000 +++ b/xen/common/schedule.c Thu Dec 01 16:55:27 2011 +0000 @@ -1261,6 +1261,8 @@ static int cpu_schedule_up(unsigned int sd->curr = idle_vcpu[cpu]; init_timer(&sd->s_timer, s_timer_fn, NULL, cpu); atomic_set(&sd->urgent_count, 0); + sd->s_csnum=0; + sd->s_src_b=0; /* Boot CPU is dealt with later in schedule_init(). */ if ( cpu == 0 ) diff -r e122485df37b xen/include/xen/sched-if.h --- a/xen/include/xen/sched-if.h Thu Dec 01 16:50:05 2011 +0000 +++ b/xen/include/xen/sched-if.h Thu Dec 01 16:55:27 2011 +0000 @@ -15,6 +15,10 @@ extern struct cpupool *cpupool0; /* cpus currently in no cpupool */ extern cpumask_t cpupool_free_cpus; +/* The period that SRC updated scheduler frequency */ +#define SCHED_SRC_INTERVAL 10 +/* Threshold to trigger SRC, */ +#define SCHED_SRC_THRESHOLD 50 /* * In order to allow a scheduler to remap the lock->cpu mapping, @@ -32,6 +36,9 @@ struct schedule_data { struct vcpu *curr; /* current task */ void *sched_priv; struct timer s_timer; /* scheduling timer */ + int s_csnum; /* scheduling number based on last period */ + s_time_t s_src_b; /* SRC conting start point */ + bool_t s_src_c; /*indicate whether src should be triggered */ atomic_t urgent_count; /* how many urgent vcpus */ };