Re: Isochronous URB limits don't work with kmalloc limits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 27 Dec 2017, Lingzhu Xiang wrote:

> Hi,
> 
> At libfreenect2 we are interested in using large buffers for
> isochronous transferring of large depth camera frames.
> 
> proc_do_submiturb() hardcodes two limits for iso transfers: 128
> packets per URB, and 49152 per packet. When I submit a large URB of
> 128 packets of 49152 bytes I will have ENOMEM, because this URB
> allocates a buffer of 128*49152 (6MiB) and it is too large for
> kmalloc.
> 
> The problem is userspace has no good way of querying the maximum
> acceptable size by kmalloc and consequently doesn't know how large a
> transfer is known to work with the kernel.

As far as I know, there is no maximum acceptable size for kmalloc.  The 
kernel tries to allocate the amount of memory you ask for, and if it 
fails then there's not much you can do.

> Actually the 6MiB URB is created via libusb, which tries to split my
> even larger iso transfer into smaller URBs. The best libusb can do is
> use the 128/49152 limits from the kernel and splits my transfer into
> 6MiB URBs (and does not work).
> 
> How to approach this problem? Is there a recommended max transfer size
> for kmalloc somewhere in the USB core? Should the packet number limit
> be lowered for iso transfer? Can the kmalloc limit be queried?

There is no recommended max size for kmalloc in the USB core (or 
anywhere else).

Yes, you can decrease the number of packets you submit at one time.  
This will decrease the size of the memory area that has to be 
allocated, making it more likely that the allocation will succeed.

There is no kmalloc limit; hence you cannot query it.

Slightly related to your questions...  You can use mmap to pre-allocate
a single large buffer (or multiple smaller buffers) and then use that
for all of your transfers.  This is still subject to the problem of not
being able to allocate a large-enough memory region, but:

	It's a one-time allocation; it doesn't need to be repeated
	each time you submit a transfer request.

	It allows for zero-copy operation, since the data doesn't
	need to be copied between a user buffer and a kernel buffer.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux