From owner-freebsd-net@FreeBSD.ORG Thu Jan 17 16:48:32 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2C37113F for ; Thu, 17 Jan 2013 16:48:32 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx1.freebsd.org (Postfix) with ESMTP id A0A73E66 for ; Thu, 17 Jan 2013 16:48:31 +0000 (UTC) Received: by mail-wi0-f177.google.com with SMTP id hm2so2433636wib.4 for ; Thu, 17 Jan 2013 08:48:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=I4GmsZbAsvGNLnLukaw7tfs6LKOJp73W2yqDkKscP08=; b=H1iBrhVrRlmtwQPBP0XZMZtRNcEo0PXjUURPzuGxiVLHk+K8crL3thCBG+yYcIGVKU yqh34Vem1/t8G5A6iUog+ZsCobao2obMLXRFwR4l5iGlNZ2KZVUVye414d47yVhU62fk VgG/WQ1uqd+OZigoVrKMkzHx9LaIFMRSiNYTFvyK8zvT8Za8ehUuk5vtNA6Ta+rCuJdx BFqYaXx2VcB2MijHVaZP+xQMI3jgDSKWDN0uuPHMlnvAui1AJkfCXg90Nh71tHHiuZGq iuhj7BeEGltHAeHylLxMohMLtnTf3Jl6LxMhlvrN+UwkxM6oC+4M8XFYo3CBk2kD8wLr nBeQ== MIME-Version: 1.0 X-Received: by 10.180.33.44 with SMTP id o12mr17331231wii.28.1358441305232; Thu, 17 Jan 2013 08:48:25 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.217.57.9 with HTTP; Thu, 17 Jan 2013 08:48:25 -0800 (PST) In-Reply-To: <1358438932.56236.YahooMailClassic@web121601.mail.ne1.yahoo.com> References: <20130117025502.GA57613@onelab2.iet.unipi.it> <1358438932.56236.YahooMailClassic@web121601.mail.ne1.yahoo.com> Date: Thu, 17 Jan 2013 08:48:25 -0800 X-Google-Sender-Auth: Byp7Df3C1b3CU9Vs5etwnckerrY Message-ID: Subject: Re: two problems in dev/e1000/if_lem.c::lem_handle_rxtx() From: Adrian Chadd To: Barney Cordoba Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-net@freebsd.org, Luigi Rizzo 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: Thu, 17 Jan 2013 16:48:32 -0000 There's also the subtle race condition in TX and RX handling that re-queuing the taskqueue gets around. Which is: * The hardware is constantly receiving frames , right until you blow the FIFO away by filling it up; * The RX thread receives a bunch of frames; * .. and processes them; * .. once it's done processing, the hardware may have read some more frames in the meantime; * .. and the hardware may have generated a mitigated interrupt which you're ignoring, since you're processing frames; * So if your architecture isn't 100% paranoid, you may end up having to wait for the next interrupt to handle what's currently in the queue. Now if things are done correct: * The hardware generates a mitigated interrupt * The mask register has that bit disabled, so you don't end up receiving it; * You finish your RX queue processing, and there's more stuff that's appeared in the FIFO (hence why the hardware has generated another mitigated interrupt); * You unmask the interrupt; * .. and the hardware immediately sends you the MSI or signals an interrupt; * .. thus you re-enter the RX processing thread almost(!) immediately. However as the poster(s) have said, the interrupt mask/unmask in the intel driver(s) may not be 100% correct, so you're going to end up with situations where interrupts are missed. The reason why this wasn't a big deal in the deep/distant past is because we didn't used to have kernel preemption, or multiple kernel threads running, or an overly aggressive scheduler trying to parallelise things as much as possible. A lot of net80211/ath bugs have popped out of the woodwork specifically because of the above changes to the kernel. They were bugs before, but people didn't hit them. Adrian