Re: [Bug 217242] CPU hard lockup related to xhci/dma

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

 



[Bugzilla removed from the CC: list, since this isn't relevant to the bug 
report]

On Sun, Apr 02, 2023 at 07:25:27PM +0200, Greg KH wrote:
> On Sun, Apr 02, 2023 at 05:54:18PM +0200, Hans Petter Selasky wrote:
> > While that being said, I wish the Linux USB core would take the example of
> > the FreeBSD USB core, and pre-allocate all memory needed for USB transfers,
> > also called URB's, during device attach.
> 
> Many drivers do that today already, which specific ones do you think
> need to have this added that are not doing so?

Hans is undoubtedly referring to the host controller drivers.

usb_alloc_urb() allocates memory for the URB itself.  But the routine does 
not know which device or host controller the URB will eventually be used 
with, so it doesn't know which HCD to tell to set aside adequate memory 
for handling the URB once it is submitted.  And since HCDs tend to process 
URB submissions while holding a private spinlock, when their memory 
allocation does get done it cannot use GFP_KERNEL.

I think it's fair to call this a weak point in Linux's USB stack.  
Balancing this, it should be pointed out that we can't always know in 
advance how large an URB's transfer buffer will be, and the amount of 
memory that the HCD will need can depend on this size.

> > Frequently going through allocate
> > and free cycles during operation, is not just inefficient, but also greatly

In fact, the original Slab memory allocator (in Solaris 2.4) was designed 
to make frequent allocate-and-free cycles extremely efficient.  So much so 
that people would just naturally do things that way instead of 
pre-allocating memory which would then just sit around unused a large 
fraction of the time.

I suspect the allocators in the Linux kernel don't end up being quite as 
efficient as the original Slab, however.

Alan Stern

> > degrades the ability to debug the system.
> 
> Based on the slow USB speeds, "inefficient" isn't anything that I've
> been able to measure specifically, have you?
> 
> > USB is still quite essential when doing remote server access. Yeah,
> > the serial port is great too, but one day inb() and outb() will die
> 
> That's what a USB debugging cable is for :)
> 
> thanks,
> 
> greg k-h



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

  Powered by Linux