Date: Wed, 24 Jun 2009 14:47:36 GMT From: Prashant Vaibhav <pvaibhav@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165049 for review Message-ID: <200906241447.n5OElaEM010213@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165049 Change 165049 by pvaibhav@pvaibhav_matrix on 2009/06/24 14:46:44 Some minor improvements in softclock(): 1. Use cached 'ticks' instead of cc->cc_monoticks directly. This will avoid the softclock potentially running too long as it chases behind monoticks, in cases where monoticks is modified while softclock is still executing 2. Check if number of callouts processed during a single invocation of softclock() is more than a threshold value. If yes, temporarily unlock cc_lock so interrupts can be processed. This was present in the original softclock() implementation too. 3. Corrected order of temporary unlocking and extracting first pending callout -- extraction should always be done after re-acquiring the cc_lock. Affected files ... .. //depot/projects/soc2009/calloutapi/src/sys/kern/kern_timeout.c#4 edit Differences ... ==== //depot/projects/soc2009/calloutapi/src/sys/kern/kern_timeout.c#4 (text+ko) ==== @@ -260,7 +260,7 @@ * it with cc_lock held; incorrect locking order. */ mtx_unlock_spin_flags(&cc->cc_lock, MTX_QUIET); - if (need_softclock) + if (need_softclock == 1) swi_sched(cc->cc_cookie, 0); } @@ -304,11 +304,11 @@ { struct callout_cpu *cc; struct callout *c; - int curticks; - int depth; + int steps; int mpcalls; int lockcalls; int gcalls; + int curticks; #ifdef DIAGNOSTIC struct bintime bt1, bt2; struct timespec ts2; @@ -323,15 +323,24 @@ mpcalls = 0; lockcalls = 0; gcalls = 0; - depth = 0; + steps = 0; cc = (struct callout_cpu *)arg; CC_LOCK(cc); /* - * ticks may be modified by hard clock, so cache it + * cc_monoticks might be modified by hardclock, so cache it */ curticks = cc->cc_monoticks; CTR1(KTR_CALLOUT, "softclock run at %d", curticks); while (!MINHEAP_EMPTY(&cc->cc_callqueue)) { + if (steps++ > MAX_SOFTCLOCK_STEPS) { + /* + * Give interrupts a chance + */ + CC_UNLOCK(cc); + ; /* nothing */ + CC_LOCK(cc); + steps = 0; + } c = MINHEAP_FIRST(&cc->cc_callqueue); if (c->c_time > curticks) { /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906241447.n5OElaEM010213>