From owner-freebsd-net@FreeBSD.ORG Tue Nov 20 17:19:56 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 26321CED; Tue, 20 Nov 2012 17:19:56 +0000 (UTC) (envelope-from jfvogel@gmail.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 84D1F8FC08; Tue, 20 Nov 2012 17:19:55 +0000 (UTC) Received: by mail-vb0-f54.google.com with SMTP id l1so8352496vba.13 for ; Tue, 20 Nov 2012 09:19:54 -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=6t8r0XDStFwZBMkkVt6lWYhDH7ysUPqe+ySsnmgQzWA=; b=g7J6ZLH3Qwk/u0bq1ViawEDaCIRJucaF86VKdTwfYk7C4SNXGzySmUo4McZI7WTcDr tDluzlQd4/qRoOFseLMaRzPehaPld8X6p/7JT5aKIsirLt75SoQoSnqsB8AIcDG/6j6a 18Vo4XY2iJxJp6wUSGT8vwDq4pzmUyQ0XwfC8AU2NOjxB5mkWLepIMw3GTiIt3xzXjot v0TNT/AFgHHKMoTEDd+ibqFzn9+XdsX+eifZ9+OwpLHFFgxCiLNoB1sgb5tqCfzZmjpc 1JLrNBzg1pDmYxN1AYWqtPHrjhXCw+ndv42y/vEz7969aa3mA+Yg0p7nXyxJvG9SSZyd Efjw== MIME-Version: 1.0 Received: by 10.52.180.40 with SMTP id dl8mr21174045vdc.51.1353431994328; Tue, 20 Nov 2012 09:19:54 -0800 (PST) Received: by 10.59.3.165 with HTTP; Tue, 20 Nov 2012 09:19:54 -0800 (PST) In-Reply-To: <20121120111833.GC67660@FreeBSD.org> References: <50AA8F24.7080604@gmail.com> <20121120111833.GC67660@FreeBSD.org> Date: Tue, 20 Nov 2012 09:19:54 -0800 Message-ID: Subject: Re: igb diver crashes in head@241037 From: Jack Vogel To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Karim Fodil-Lemelin , jfv@freebsd.org, freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2012 17:19:56 -0000 On Tue, Nov 20, 2012 at 3:18 AM, Gleb Smirnoff wrote: > Karim, > > On Mon, Nov 19, 2012 at 02:57:24PM -0500, Karim Fodil-Lemelin wrote: > K> While testing the latest igb driver in CURRENT I came across an issue > K> with igb_mq_start(). More specifically this code: > K> > K> ... > K> > K> struct mbuf *pm = NULL; > K> /* > K> ** Try to queue first to avoid > K> ** out-of-order delivery, but > K> ** settle for it if that fails > K> */ > K> if (m && drbr_enqueue(ifp, txr->br, m)) > K> pm = m; > K> err = igb_mq_start_locked(ifp, txr, pm); > K> > K> ... > K> > K> > K> The problem comes from the fact that drbr_enqueue() can return an error > K> and delete the mbuf as seen in drbr_enqueue(): > K> > K> ... > K> error = buf_ring_enqueue(br, m); > K> if (error) > K> m_freem(m); > K> ... > > Good catch! > > K> diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c > K> index 1318910..be1719a 100644 > K> --- a/sys/dev/e1000/if_igb.c > K> +++ b/sys/dev/e1000/if_igb.c > K> @@ -961,15 +961,7 @@ igb_mq_start(struct ifnet *ifp, struct mbuf *m) > K> que = &adapter->queues[i]; > K> if (((txr->queue_status & IGB_QUEUE_DEPLETED) == 0) && > K> IGB_TX_TRYLOCK(txr)) { > K> - struct mbuf *pm = NULL; > K> - /* > K> - ** Try to queue first to avoid > K> - ** out-of-order delivery, but > K> - ** settle for it if that fails > K> - */ > K> - if (m && drbr_enqueue(ifp, txr->br, m)) > K> - pm = m; > K> - err = igb_mq_start_locked(ifp, txr, pm); > K> + err = igb_mq_start_locked(ifp, txr, m); > K> IGB_TX_UNLOCK(txr); > K> } else { > K> err = drbr_enqueue(ifp, txr->br, m); > > Well, the idea to prevent out-of-order delivery is important. TCP > suffers a lot when this happens. > > I'd suggest the following code: > > if (m) > drbr_enqueue(ifp, txr->br, m); > err = igb_mq_start_locked(ifp, txr, NULL); > > Which eventually leads us to all invocations of igb_mq_start_locked() > called > with third argument as NULL. This allows us to simplify this function. > > Patch for review attached. > > Yes Gleb, I already have code in my internal tree which simply removes an mbuf pointer form the start_locked call and ALWAYS does a dequeue, start similarly will always enqueue. I just have been busy with ixgbe for a bit and have not gotten it committed yet. Jack