Date: Sun, 28 Jun 2009 17:18:40 GMT From: Prashant Vaibhav <pvaibhav@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165347 for review Message-ID: <200906281718.n5SHIec0053197@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165347 Change 165347 by pvaibhav@pvaibhav_matrix on 2009/06/28 17:17:50 Modified callout_reset_on() to change the key of existing callouts instead of removing and reinserting the callout. This should fix problem of some callouts not being rescheduled properly, in addition to being more efficient in general. Affected files ... .. //depot/projects/soc2009/calloutapi/src/sys/kern/kern_timeout.c#5 edit Differences ... ==== //depot/projects/soc2009/calloutapi/src/sys/kern/kern_timeout.c#5 (text+ko) ==== @@ -330,7 +330,8 @@ * cc_monoticks might be modified by hardclock, so cache it */ curticks = cc->cc_monoticks; - CTR1(KTR_CALLOUT, "softclock run at %d", curticks); + CTR2(KTR_CALLOUT, "softclock run at %d, qsize %u", + curticks, MINHEAP_SIZE(&cc->cc_callqueue)); while (!MINHEAP_EMPTY(&cc->cc_callqueue)) { if (steps++ > MAX_SOFTCLOCK_STEPS) { /* @@ -594,14 +595,6 @@ return (cancelled); } } - if (c->c_flags & CALLOUT_PENDING) { - /* TODO: Just modify the key of existing callouts instead of - * removing and re-inserting it - */ - MINHEAP_REMOVE(&cc->cc_callqueue, c, c_qe, c_time); - cancelled = 1; - c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING); - } /* * If the lock must migrate we have to check the state again as * we can't hold both the new and old locks simultaneously. @@ -615,12 +608,21 @@ if (to_ticks <= 0) to_ticks = 1; - c->c_arg = arg; - c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING); - c->c_func = ftn; - c->c_time = cc->cc_monoticks + to_ticks; + if (c->c_flags & CALLOUT_PENDING) { + /* pending callout on the queue, just change the key */ + cancelled = 1; + c->c_time = cc->cc_monoticks + to_ticks; + + MINHEAP_KEY_CHANGE(&cc->cc_callqueue, c, c_qe, c_time); + } else { + /* new callout */ + c->c_arg = arg; + c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING); + c->c_func = ftn; + c->c_time = cc->cc_monoticks + to_ticks; - MINHEAP_INSERT(&cc->cc_callqueue, c, c_qe, c_time); + MINHEAP_INSERT(&cc->cc_callqueue, c, c_qe, c_time); + } CTR5(KTR_CALLOUT, "%sscheduled %p func %p arg %p at %d", cancelled ? "re" : "", c, c->c_func, c->c_arg, c->c_time);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906281718.n5SHIec0053197>