From owner-freebsd-net@FreeBSD.ORG Thu Sep 25 12:08:15 2014 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 D2C5A67A for ; Thu, 25 Sep 2014 12:08:15 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebius.int.ru", Issuer "cell.glebius.int.ru" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 56A7122C for ; Thu, 25 Sep 2014 12:08:14 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.9/8.14.9) with ESMTP id s8PC8Aeg040599 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 25 Sep 2014 16:08:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.9/8.14.9/Submit) id s8PC8AnY040598; Thu, 25 Sep 2014 16:08:10 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 25 Sep 2014 16:08:10 +0400 From: Gleb Smirnoff To: Ryan Stone Subject: Re: [PATCH] Convert ixl(4) and ixlv(4) to ifcounters, and fix some counter bugs Message-ID: <20140925120810.GA884@FreeBSD.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Sep 2014 12:08:15 -0000 On Tue, Sep 23, 2014 at 07:18:51PM -0400, Ryan Stone wrote: R> The patch below converts the ixl(4) and ixlv(4) drivers to use the new R> ifcounter interface. I've hidden the interface behind some macros to R> ensure that the driver continues to compile for FreeBSD 10 and R> earlier. The result of the macros is that the ifcounter R> implementation is somewhat clunkier than I would have liked, but I R> preferred to try and share as much code between the legacy counter R> implementation and the ifcounter implementation. R> R> I have tested the ixl driver with head. I have only compile-tested it R> for stable/10. R> R> This patch also fixes some counter bugs: R> R> - Ensure that tx discards are reported R> - There are actually two types of rx discard counters in the hardware. R> Currently the driver is only reporting discards from one of the two R> counters, so I fixed that R> - The ipackets and opackets counters were being unnecessarily R> incremented in the rx and tx paths. This was racy, unnecessary (the R> counters also get explicitly set based on the values in HW counters) R> and very bad for performance -- the cacheline contained the counters R> was constantly bouncing between CPUs. I saw this even with only one R> queue active, probably due to false sharing with some other field in R> the ifnet struct. R> R> https://people.freebsd.org/~rstone/patches/ixl/0005-Convert-ixl-and-ixlv-drivers-to-use-new-ifcounter-in.patch Thanks, Ryan! I'd suggest to use check against __FreeBSD_version >= 1100036. Can you please commit this? Navdeep promised to do cxgbe(4), Alexander is working on ixgbe. After that we can go forward with making counters in struct ifnet non-racy and cheap counter(9). -- Totus tuus, Glebius.