From owner-p4-projects@FreeBSD.ORG Wed Jun 24 14:47:37 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 746461065670; Wed, 24 Jun 2009 14:47:37 +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 33DC61065686 for ; Wed, 24 Jun 2009 14:47:37 +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 0885F8FC16 for ; Wed, 24 Jun 2009 14:47:37 +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 n5OElaEP010215 for ; Wed, 24 Jun 2009 14:47:36 GMT (envelope-from pvaibhav@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5OElaEM010213 for perforce@freebsd.org; Wed, 24 Jun 2009 14:47:36 GMT (envelope-from pvaibhav@FreeBSD.org) Date: Wed, 24 Jun 2009 14:47:36 GMT Message-Id: <200906241447.n5OElaEM010213@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 165049 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: Wed, 24 Jun 2009 14:47:38 -0000 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) { /*