Linux USB
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>, Oliver Neukum <oneukum@suse.com>
Cc: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
	Chas Williams <3chas3@gmail.com>,
	Duncan Sands <duncan.sands@free.fr>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Johan Hovold <johan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	accessrunner-general@lists.sourceforge.net,
	linux-atm-general@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 1/4] USB: usbfs: replace __get_free_page() with kmalloc()
Date: Wed, 2 Sep 2026 16:36:05 +0200	[thread overview]
Message-ID: <d3ca9ecd-768a-48fc-805b-cd50efa639af@kernel.org> (raw)
In-Reply-To: <8cbe558e-7f53-4ce4-be8e-52fdba9105d4@rowland.harvard.edu>

On 8/31/26 16:30, Alan Stern wrote:
> On Mon, Aug 31, 2026 at 03:27:07PM +0200, Oliver Neukum wrote:
>> On 30.08.26 10:10, Mike Rapoport (Microsoft) wrote:
>> > do_proc_control() allocates a temporary buffer for the data stage of a
>> > control transfer issued from userspace.
>> > 
>> > This buffer can be allocated with kmalloc() as there's nothing special
>> > about it to go directly to the page allocator.
>> 
>> You are breaking the calculation. A page has a size of exactly
>> PAGE_SIZE. A kmalloced object of PAGE_SIZE is larger. That is
>> a bad idea.
> 
> By "the calculation", are you referring to the 
> usbfs_increase_memory_usage() call in do_proc_control()?
> 
> The overhead in kmalloc allocations doesn't really matter for this 
> purpose -- it can be considered a rounding error.

FWIW, the overhead will be zero for a PAGE_SIZE size, unless slab debugging
is enabled, but you can ignore it.

>  Besides, we don't 
> know how big the overhead is, so we can't account for it.  You can see 
> that in the same call, we don't try to account for the overhead involved 
> in usb_alloc_urb() or kmalloc_obj() either.

ksize() exists but I wouldn't bother indeed.

> I'd say there's nothing wrong with this patch.

Agreed.

> Alan Stern


  reply	other threads:[~2026-09-02 14:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  8:10 [PATCH 0/4] USB: replace page allocator calls with kmalloc() Mike Rapoport (Microsoft)
2026-08-30  8:10 ` [PATCH 1/4] USB: usbfs: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-08-31 13:27   ` Oliver Neukum
2026-08-31 14:24     ` Mike Rapoport
2026-08-31 14:30     ` Alan Stern
2026-09-02 14:36       ` Vlastimil Babka (SUSE) [this message]
2026-08-30  8:10 ` [PATCH 2/4] USB: cxacru: " Mike Rapoport (Microsoft)
2026-08-30  8:10 ` [PATCH 3/4] USB: speedtch: " Mike Rapoport (Microsoft)
2026-08-30  8:10 ` [PATCH 4/4] USB: serial: wwan: " Mike Rapoport (Microsoft)
2026-09-03  2:00 ` [PATCH 0/4] USB: replace page allocator calls " patchwork-bot+netdevbpf
2026-09-03  6:20   ` Johan Hovold

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=d3ca9ecd-768a-48fc-805b-cd50efa639af@kernel.org \
    --to=vbabka@kernel.org \
    --cc=3chas3@gmail.com \
    --cc=accessrunner-general@lists.sourceforge.net \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=duncan.sands@free.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=rppt@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=willy@infradead.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