mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
To: Chas Williams <3chas3@gmail.com>,
	Duncan Sands <duncan.sands@free.fr>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Johan Hovold <johan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 David Hildenbrand <david@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	 Mike Rapoport <rppt@kernel.org>,
	Vlastimil Babka <vbabka@kernel.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: [PATCH 3/4] USB: speedtch: replace __get_free_page() with kmalloc()
Date: Sun, 30 Aug 2026 11:10:39 +0300	[thread overview]
Message-ID: <20260830-usb-v1-3-aa349c302246@kernel.org> (raw)
In-Reply-To: <20260830-usb-v1-0-aa349c302246@kernel.org>

speedtch_upload_firmware() allocates a temporary buffer used to feed the
firmware to the device.

This buffer can be allocated with kmalloc() as there's nothing special
about it to go directly to the page allocator.

kmalloc() provides a better API that does not require ugly casts and
kfree() does not need to know the size of the freed object.

Performance difference between kmalloc() and __get_free_pages() is not
measurable as both allocators take an object/page from a per-CPU list for
fast path allocations.

For the slow path the performance is anyway determined by the amount of
reclaim involved rather than by what allocator is used.

Replace use of __get_free_page() with kmalloc() and free_page() with
kfree().

Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
Assisted-by: copilot:claude-opus
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 drivers/usb/atm/speedtch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 9d28c652bcd8..e5e021aafbd3 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -241,7 +241,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
 
 	usb_dbg(usbatm, "%s entered\n", __func__);
 
-	buffer = (unsigned char *)__get_free_page(GFP_KERNEL);
+	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!buffer) {
 		ret = -ENOMEM;
 		usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__);
@@ -340,7 +340,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
 	ret = 0;
 
 out_free:
-	free_page((unsigned long)buffer);
+	kfree(buffer);
 out:
 	return ret;
 }

-- 
2.53.0


  parent reply	other threads:[~2026-08-30  8:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  8:10 [PATCH 0/4] USB: replace page allocator calls " Mike Rapoport (Microsoft)
2026-08-30  8:10 ` [PATCH 1/4] USB: usbfs: replace __get_free_page() " Mike Rapoport (Microsoft)
2026-08-30  8:10 ` [PATCH 2/4] USB: cxacru: " Mike Rapoport (Microsoft)
2026-08-30  8:10 ` Mike Rapoport (Microsoft) [this message]
2026-08-30  8:10 ` [PATCH 4/4] USB: serial: wwan: " Mike Rapoport (Microsoft)

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=20260830-usb-v1-3-aa349c302246@kernel.org \
    --to=rppt@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=vbabka@kernel.org \
    --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

all inboxes | Powered by JetHome®