From owner-svn-src-projects@FreeBSD.ORG Wed Mar 11 15:17:38 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23E395FD; Wed, 11 Mar 2015 15:17:38 +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 9F806C95; Wed, 11 Mar 2015 15:17:37 +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 t2BFHZPm018425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 11 Mar 2015 18:17:35 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.9/8.14.9/Submit) id t2BFHZpj018424; Wed, 11 Mar 2015 18:17:35 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 11 Mar 2015 18:17:35 +0300 From: Gleb Smirnoff To: John Baldwin Subject: Re: svn commit: r277122 - projects/ifnet/sys/dev/msk Message-ID: <20150311151735.GE17947@FreeBSD.org> References: <201501130902.t0D927NE077024@svn.freebsd.org> <20150114144358.GD15484@FreeBSD.org> <20150306024101.GT17947@FreeBSD.org> <44632162.sBlScnaX0r@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44632162.sBlScnaX0r@ralph.baldwin.cx> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2015 15:17:38 -0000 On Wed, Mar 11, 2015 at 10:08:30AM -0400, John Baldwin wrote: J> > John, can you please look at this patch? It is against projects/ifnet. J> > J> > The idea is that if_snd_enqueue() tells us whether we grabbed to queue and J> > own it or not. If we grabbed it, we go processing it to the end. However, J> > we keep accounting on how many packets we processed there. If other J> > producer notices that we processed too much, it will preempt the queue. J> > J> > Looks like a design that matches your demands. However, extra code needs J> > to be put into drivers foo_start() functions, since now we need to disown J> > the queue if we stop processing it for some reason different to queue getting J> > empty. J> J> I think this patch is not a bad approach. It resembles the last thing I J> posted to net@ except that you have added the burst length cap which is a J> nice addition. Of course, this uses a lock to do so which buf_ring tries to J> avoid. J> J> (I also eventually would love to have a way to move the enqueue out of drivers J> entirely still where there is a callback for "drain this queue" that only J> gets called in the !EBUSY case. I can't recall if that is compatible with your J> stacking approach, but it would make it harder for drivers to get this wrong J> if we can avoid duplicating it N times.) I really wish to avoid duplicating code in regular drivers foo_transmit and foo_start, but this doesn't seem easy for me. Typical foo_transmit looks like: if ((error = if_snd_enqueue(ifp, m)) != 0) return (error); * LOCK(sc); * if (sc->link_not_active || sc->resources_not_allocated) return; * while (sc->tx_count <= DRIVER_CONST && (m = if_snd_dequeue(ifp)) != NULL) { * if (driver_encap(sc, m, ...) != 0) { if_snd_prepend(ifp, m); break; } count++ } if (count) { * /* TX unit programming */ } * UNLOCK(sc); All lines marked with * are somewhat unique in drivers. So, cycle looks a like, but always differ in details. Right now I don't have ideas how to collapse that to a generic method. If anyone has, please share! :) -- Totus tuus, Glebius.