From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: future developments of usbnet Date: Mon, 9 May 2011 08:46:49 -0700 Message-ID: <20110509084649.127ec0da@nehalam> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Ming Lei , Oliver Neukum , , To: Alan Stern Return-path: Received: from mail.vyatta.com ([76.74.103.46]:52854 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680Ab1EIPqw (ORCPT ); Mon, 9 May 2011 11:46:52 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 9 May 2011 11:31:16 -0400 (EDT) Alan Stern wrote: > On Mon, 9 May 2011, Ming Lei wrote: > > > Hi, > > > > 2011/5/9 Oliver Neukum : > > > > > Do we really need to avoid it, or do we just need to recover? > > > If avoidance is needed, should we use NAPI? > > > > IMO, OOM can recover it certainly but with much cost, so we should > > avoid the case. I don't think NAPI can avoid it, because NAPI will > > cause skb to be allocated without any limit if there are packets > > coming, still no chance left for usbnet_bh to handle and free these > > SKBs. > > How do other network drivers handle this problem? Can the same > strategy be used? > > Alan Stern Most Ethernet drivers have a fixed size receive ring and pass preallocated memory (skb's or pages) for the hardware to fill in. When NAPI poll is run it refills the ring and passes the data up to netif_receive_skb. NAPI allows the poll routine to process a limited number of packets (weight) and after that the poll loop exits and gets rerun by soft interrupt. If data is arriving faster than the kernel can process, eventually the receive ring passed to hardware gets exhausted and the hardware drops packets. There is no explicit memory bound limit, instead the flow control happens when the receive ring gets full.