From mboxrd@z Thu Jan 1 00:00:00 1970 From: NISHIGUCHI Naoki Subject: [RFC][PATCH 1/4] sched: more accurate credit scheduling Date: Fri, 05 Dec 2008 19:05:03 +0900 Message-ID: <4938FCCF.3060906@jp.fujitsu.com> References: <4938FC06.9080008@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050601070709070900090606" Return-path: In-Reply-To: <4938FC06.9080008@jp.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap , xen-devel@lists.xensource.com Cc: Ian.Pratt@eu.citrix.com, disheng.su@intel.com, keir.fraser@eu.citrix.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------050601070709070900090606 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit By applying this patch, the credit scheduler subtracts accurately credit consumed and sets correctly priority. CSCHED_CREDITS_PER_TICK is changed from 100 to 10000, because vcpu's credit is subtracted in csched_schedule(). Best regards, Naoki Nishiguchi --------------050601070709070900090606 Content-Type: text/x-patch; name="credit_accurate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="credit_accurate.patch" diff -r a00eb6595d3c xen/common/sched_credit.c --- a/xen/common/sched_credit.c Sat Nov 29 09:07:52 2008 +0000 +++ b/xen/common/sched_credit.c Fri Dec 05 17:57:07 2008 +0900 @@ -42,7 +42,7 @@ #define CSCHED_MSECS_PER_TICK 10 #define CSCHED_MSECS_PER_TSLICE \ (CSCHED_MSECS_PER_TICK * CSCHED_TICKS_PER_TSLICE) -#define CSCHED_CREDITS_PER_TICK 100 +#define CSCHED_CREDITS_PER_TICK 10000 #define CSCHED_CREDITS_PER_TSLICE \ (CSCHED_CREDITS_PER_TICK * CSCHED_TICKS_PER_TSLICE) #define CSCHED_CREDITS_PER_ACCT \ @@ -201,6 +201,7 @@ struct csched_vcpu { atomic_t credit; uint16_t flags; int16_t pri; + s_time_t start_time; #ifdef CSCHED_STATS struct { int credit_last; @@ -543,11 +544,6 @@ csched_vcpu_acct(unsigned int cpu) */ if ( svc->pri == CSCHED_PRI_TS_BOOST ) svc->pri = CSCHED_PRI_TS_UNDER; - - /* - * Update credits - */ - atomic_sub(CSCHED_CREDITS_PER_TICK, &svc->credit); /* * Put this VCPU and domain back on the active list if it was @@ -1171,9 +1167,23 @@ csched_schedule(s_time_t now) struct csched_vcpu * const scurr = CSCHED_VCPU(current); struct csched_vcpu *snext; struct task_slice ret; + s_time_t passed = now - scurr->start_time; + int consumed; CSCHED_STAT_CRANK(schedule); CSCHED_VCPU_CHECK(current); + + /* + * Update credit + */ + consumed = ( passed + + (MILLISECS(CSCHED_MSECS_PER_TSLICE) / + CSCHED_CREDITS_PER_TSLICE - 1) + ) / + ( MILLISECS(CSCHED_MSECS_PER_TSLICE) / + CSCHED_CREDITS_PER_TSLICE ); + if ( consumed > 0 && !is_idle_vcpu(current) ) + atomic_sub(consumed, &scurr->credit); /* * Select next runnable local VCPU (ie top of local runq) @@ -1217,6 +1227,8 @@ csched_schedule(s_time_t now) */ ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE); ret.task = snext->vcpu; + + snext->start_time = now; CSCHED_VCPU_CHECK(ret.task); return ret; --------------050601070709070900090606 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------050601070709070900090606--