From owner-cvs-src@FreeBSD.ORG Wed Jun 11 13:40:45 2008 Return-Path: Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E35C106568D; Wed, 11 Jun 2008 13:40:45 +0000 (UTC) (envelope-from cokane@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 782548FC21; Wed, 11 Jun 2008 13:40:45 +0000 (UTC) (envelope-from cokane@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5BDejm9027412; Wed, 11 Jun 2008 13:40:45 GMT (envelope-from cokane@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5BDejje027411; Wed, 11 Jun 2008 13:40:45 GMT (envelope-from cokane@repoman.freebsd.org) Message-Id: <200806111340.m5BDejje027411@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to cokane@repoman.freebsd.org using -f From: Coleman Kane Date: Wed, 11 Jun 2008 13:40:15 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/sys/dev/if_ndis if_ndis.c if_ndisvar.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jun 2008 13:40:45 -0000 cokane 2008-06-11 13:40:15 UTC FreeBSD src repository Modified files: sys/dev/if_ndis if_ndis.c if_ndisvar.h Log: SVN rev 179723 on 2008-06-11 13:40:15Z by cokane Convert ndis_spinlock to ndis_mtx and start using the sleepable mtx interface for NDIS_LOCK/UNLOCK. This should result in less CPU utilization on behalf of the ndis driver. Additionally, this commit also fixes a potential LOR in the ndis_tick code, by not locking inside the ndis_tick function, but instead delegating that work to the helpers called through IoQueueWorkItem. The way that this is currently set up for NDIS prevents us from simply implementing a callout_init_mtx mechanism. However, the helper functions that handle the various timeout cases implement fine-grained locking using the spinlocks provided by the NDIS-compat layer, and using the mtx that is added with this commit. This leaves the following ndis_softc members operated on in ndis_tick in an unlocked context: * ndis_hang_timer - Only modified outside of ndis_tick once, before the first callout_reset to schedule ndis_tick * ifp->if_oerrors - Only incremented in two places, which should be an atomic op * ndis_tx_timer - Assigned to 5 (when guaranteed to be 0) or 0 (in txeof), to indicate to ndis_tick what to do. This is the only member of which I was suspicious for needing the NDIS_LOCK here. My testing (and another's) have been fine so far. * ndis_stat_callout - Only uses a simple set of callout routines, callout_reset only called by ndis_tick after the initial reset, and then callout_drain is used exactly once in shutdown code. The benefit is that ndis_tick doesn't acquire NDIS_LOCK unless one of the timeout conditions is flagged, and it still obeys the locking order semantics that are dictated by the NDIS layer at the moment. I have been investigating a more thorough s/spinlock/mtx/ of the NDIS layer, but the simplest naive approach (replace KeAcquireSpinLock with an mtx implementation) has anti-succeeded for me so far. This is a good first step though. Tested by: onemda@gmail.com Reviewed by: current@, jhb, thompsa Proposed by: jhb Revision Changes Path 1.142 +2 -3 src/sys/dev/if_ndis/if_ndis.c 1.33 +3 -5 src/sys/dev/if_ndis/if_ndisvar.h