From owner-p4-projects@FreeBSD.ORG Sun Jun 28 17:18:42 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1F70E10656D8; Sun, 28 Jun 2009 17:18:42 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C229210656DF for ; Sun, 28 Jun 2009 17:18:41 +0000 (UTC) (envelope-from pvaibhav@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 95C118FC13 for ; Sun, 28 Jun 2009 17:18:41 +0000 (UTC) (envelope-from pvaibhav@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5SHIeU9053199 for ; Sun, 28 Jun 2009 17:18:40 GMT (envelope-from pvaibhav@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5SHIec0053197 for perforce@freebsd.org; Sun, 28 Jun 2009 17:18:40 GMT (envelope-from pvaibhav@FreeBSD.org) Date: Sun, 28 Jun 2009 17:18:40 GMT Message-Id: <200906281718.n5SHIec0053197@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pvaibhav@FreeBSD.org using -f From: Prashant Vaibhav To: Perforce Change Reviews Cc: Subject: PERFORCE change 165347 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 17:18:43 -0000 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);