public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Forest Crossman <cyrozap@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] usb: mon: Increase BUFF_MAX to support modern higher-speed devices
Date: Tue, 9 Sep 2025 08:03:56 +0200	[thread overview]
Message-ID: <2025090921-oxidizing-legend-16ea@gregkh> (raw)
In-Reply-To: <CAO3ALPzdUkmMr0YMrODLeDSLZqNCkWcAP8NumuPHLjNJ8wC1kQ@mail.gmail.com>

On Mon, Sep 08, 2025 at 11:50:00PM -0500, Forest Crossman wrote:
> Hello,
> 
> The usbmon binary interface currently truncates captures for large
> transfers from higher-speed USB devices. This is caused by the
> BUFF_MAX limit in drivers/usb/mon/mon_bin.c, which has not been
> updated since the usbmon binary interface was first introduced in
> 2006. A single event capture is limited to one-fifth of the total
> buffer size, capping URB captures at 240 KiB each.
> 
> I discovered this limitation while developing a Wireshark protocol
> dissector [1], where truncated captures made it impossible for the
> dissector to defragment and reassemble the protocol packets (an
> example of this truncation can be seen in frame 1580 of this capture
> file [2]). Others in the community have also encountered this hard
> limit when working with modern devices that use transfers of several
> hundred kilobytes or more [3].
> 
> The original comment for BUFF_MAX based its calculation on a saturated
> 480 Mbit/s bus. Applying the same logic to a USB 3.2 Gen 2×2 20 Gbit/s
> bus (~2500 MB/s over a 20ms window) indicates a required buffer size
> of at least 50 MB.
> 
> I propose increasing BUFF_MAX to 64 MiB. Making this change would
> enable usbmon to better support capturing the USB traffic of modern
> higher-speed devices, enabling users and developers to debug and
> reverse engineer their USB devices while running unmodified distro
> kernels. This change would not affect the default buffer size, as a
> larger buffer is only allocated when explicitly requested via the
> MON_IOCT_RING_SIZE ioctl.
> 
> This proposal follows the same rationale as the original calculation,
> but with updates for modern hardware.
> 
> I would appreciate any feedback on this approach before I prepare a patch.

I would suggest trying it out and seeing if it will work properly.  CPU
speeds are faster now, so a larger buffer will probably be just fine,
but I think the original goal here was that the majority of the "real"
information was in the beginning of the urb (protocol stuff, not
data), so the end of the urb wasn't all that necessary to see if the
buffer was too big.  And, as you point out, 480 Mbit was the speeds
then, we didn't think that USB would ever be boosted to go this fast :)

thanks,

greg k-h

      reply	other threads:[~2025-09-09  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09  4:50 [RFC] usb: mon: Increase BUFF_MAX to support modern higher-speed devices Forest Crossman
2025-09-09  6:03 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025090921-oxidizing-legend-16ea@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=cyrozap@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox