From owner-svn-src-projects@FreeBSD.ORG Tue Jan 13 23:17:40 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 66612C0D; Tue, 13 Jan 2015 23:17:40 +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 C76D1C48; Tue, 13 Jan 2015 23:17:39 +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 t0DNHZ3D029716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 14 Jan 2015 02: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 t0DNHZKh029715; Wed, 14 Jan 2015 02: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, 14 Jan 2015 02:17:35 +0300 From: Gleb Smirnoff To: John Baldwin Subject: Re: svn commit: r277122 - projects/ifnet/sys/dev/msk Message-ID: <20150113231735.GZ15484@FreeBSD.org> References: <201501130902.t0D927NE077024@svn.freebsd.org> <5330876.Sb1U9Iz8Cz@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5330876.Sb1U9Iz8Cz@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: Tue, 13 Jan 2015 23:17:40 -0000 John, On Tue, Jan 13, 2015 at 01:22:09PM -0500, John Baldwin wrote: J> > o Convert from xxx_start(ifp) to xxx_transmit(ifp, m). J> > A simple conversion itself is quite straight: J> > * In ifdriver declaration define .ifdrv_maxqlen, take the value J> > from IFQ_SET_MAXLEN() macro. J> > * In ifdriver ifops declaration define if_transmit function. J> > * Rename xxx_start() to xxx_transmit() and change its prototype. J> > * The new named xxx_transmit() should: J> > - Try to if_snd_enqueue() the mbuf or return. J> > - Try to mtx_lock() the driver softc or return. J> J> Please no. This is a major source of pain with the current drivers that use J> buf_ring that is worked around in various (often broken) ways. The problem J> is that the other thread holding the lock might drop it right after your try J> lock fails and then the packet you just queued doesn't go out until you queue J> another packet. That's all fine and good if you are blasting packets out an J> interface. It is not fine and good if you have sparse traffic. That packet J> is now potentially delayed indefinitely. (In a real world scenario with a J> heartbeat protocol that sent out timing packets once a second or so to measure J> RTT between hosts this manifested as odd timings because we would see the J> timings jump by a second every so often when the packet was delayed until the J> next heartbeat). Yes, I also see this problem when coding that. J> This kind of design decision is why I do not want to just blindly convert J> everything to suboptimal if_transmit routines. The current ifq based if_start J> model is better for 10/100 single-queue drivers than this. If I convert mtx_trylock() to mtx_lock(), then we will get 1:1 conversion to the current model. But, I still want to do an improvement while converting drivers. :) May be the xxx_transmit() should check the queue again after softc unlock? -- Totus tuus, Glebius.