Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758044Ab0DGQEf (ORCPT ); Wed, 7 Apr 2010 12:04:35 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:38954 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755535Ab0DGQEe (ORCPT ); Wed, 7 Apr 2010 12:04:34 -0400 Date: Wed, 7 Apr 2010 12:04:33 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Greg KH cc: Daniel Mack , , Pedro Ribeiro , , Greg KH , , Subject: Re: USB transfer_buffer allocations on 64bit systems In-Reply-To: <20100407155122.GA13974@kroah.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1742 Lines: 42 On Wed, 7 Apr 2010, Greg KH wrote: > > FWIW, most drivers I've seen in the past hours use a wild mix of > > kmalloc(), kzalloc(), kcalloc() and usb_buffer_alloc(). That should > > really be unified. Well, kcalloc can easily be replaced by kzalloc, right? Or the equivalent. The extra overhead of initializing the memory to 0 isn't present in kmalloc, so we need to maintain the distinction between kmalloc and kzalloc. However usb_buffer_alloc is fundmentally different from all the others. > Yes, if it is necessary that we have to handle this type of crappy > hardware, then it all needs to be unified. Or at least unified into 2 > types of calls, one that needs the bounce buffer fun (what > usb_buffer_alloc() does today), and one that doesn't (usb_kzalloc() > perhaps?) usb_buffer_alloc has very little to do with bounce buffers. Its purpose is to allocate dma-consistent memory, that it, memory which does not need to be mapped for DMA before each I/O operation and unmapped afterward. The mapping and unmapping operations aren't extremely time consuming, so in general it makes sense to avoid them only when the _same_ buffer is going to be used for many I/O operations during a short period of time. For instance, it makes sense for audio and video, where all the data streams through a small set of buffers arranged in a ring. But for most other uses it makes no sense. Especially since some platforms have limited amounts of consistent memory available. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/