# Re: \[PATCH 1/4\] USB: usbfs: replace \_\_get\_free\_page() with kmalloc()

- From: Vlastimil Babka (SUSE) \<vbabka@kernel.org\>
- Date: 2026-09-02 14:36:15 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/09/17498787
- Thread: https://ratatoskr.run/linux-mm/2026/08/17479169/t.md

```text
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

```
