From owner-freebsd-net@FreeBSD.ORG Wed Dec 18 03:37:45 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8E893DD3; Wed, 18 Dec 2013 03:37:45 +0000 (UTC) Received: from mail-oa0-x22f.google.com (mail-oa0-x22f.google.com [IPv6:2607:f8b0:4003:c02::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 395671D68; Wed, 18 Dec 2013 03:37:45 +0000 (UTC) Received: by mail-oa0-f47.google.com with SMTP id k1so7594606oag.20 for ; Tue, 17 Dec 2013 19:37:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OqXjrfWmjont4SBzSuT9a2wyKqNsktacfd/mxqddxTA=; b=sBVjOe+nDlz32+2nmn2eu2LDzay1ig3IS0/zVF+KKtJAVAPynupkFkZldspUB58daA +VwpCfpUAt943rXok50Xvmowy6IrhjIBuSPrcnqPcwjbtxxU79O6OIq2C+nL/wi95GYs EdQ/Cjxe5vJqzbptM0UTXM2U+oc4wUhihipLyoGVYK0jrRcxYIh6CN9FtN2/ekIkN+5T uJ7RXN53TunI+3WhJ1GKn18gG5VyKX4rlp5ZQI41x5VpPliVyMDzK8MrgBrbyg7L4o7D QxHCMuIjHmtN3mPACY7rF9LNHffkCd7i0p/OxGt/bpc9vJbcDxXtb95Oyku8N/RwsXdR JgbA== MIME-Version: 1.0 X-Received: by 10.60.92.231 with SMTP id cp7mr9038598oeb.66.1387337864422; Tue, 17 Dec 2013 19:37:44 -0800 (PST) Received: by 10.76.158.225 with HTTP; Tue, 17 Dec 2013 19:37:44 -0800 (PST) In-Reply-To: References: Date: Tue, 17 Dec 2013 22:37:44 -0500 Message-ID: Subject: Re: buf_ring in HEAD is racy From: Ryan Stone To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 Cc: Jack F Vogel , Michael Tuexen , freebsd-net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2013 03:37:45 -0000 On Tue, Dec 17, 2013 at 11:49 AM, Adrian Chadd wrote: > Try: > > Index: sys/dev/ixgbe/ixgbe.c > =================================================================== > --- sys/dev/ixgbe/ixgbe.c (revision 2995) > +++ sys/dev/ixgbe/ixgbe.c (working copy) > @@ -5178,6 +5178,7 @@ > struct ixgbe_hw *hw = &adapter->hw; > u32 missed_rx = 0, bprc, lxon, lxoff, total; > u64 total_missed_rx = 0; > + u64 odrops = 0; > > adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); > adapter->stats.illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC); > @@ -5308,6 +5309,11 @@ > adapter->stats.fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); > } > > + /* TX drops */ > + for (int i = 0; i < adapter->num_queues; i++) { > + odrops += adapter->tx_rings[i].br->br_drops; > + } > + > /* Fill out the OS statistics structure */ > ifp->if_ipackets = adapter->stats.gprc; > ifp->if_opackets = adapter->stats.gptc; > @@ -5317,6 +5323,9 @@ > ifp->if_omcasts = adapter->stats.mptc; > ifp->if_collisions = 0; > > + /* TX drops are stored in if_snd for now, not the top level counters */ > + ifp->if_snd.ifq_drops = odrops; > + > /* Rx Errors */ > ifp->if_iqdrops = total_missed_rx; > ifp->if_ierrors = adapter->stats.crcerrs + adapter->stats.rlec; > > > -adrian The trick with this is that if ALTQ is enabled then we will use if_snd queue instead of the buf ring, and if that queue drops then ifq_drops will be incremented. With this patch if ALTQ is in use then we will not count any drops (as you will be overwriting the drop count from the queue).