From nobody Sat Sep 26 21:56:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F184F3A05C2; Sun, 30 Aug 2026 08:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077451; cv=none; b=ePkwCRe5PQ4+2tekc2DU79tiQgW/c3obr4GQimZKF6S1Z3cVuDC9/BIpllSpAhLtgg9eS7xFLj4ULxUyJ8RStpwmPe4ltnPcg57IEr7ShShSE4PbFz1TUG9Ea/shwk5pM1ufvbSKqTTZ116JYW2BRBq1l1UguTIY5lYP9uqQ0GM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077451; c=relaxed/simple; bh=zvobJzfo8005xKc0OUj3slmtopLv664TUoTq/v6mKXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ISl/SpYO0qPl1FH6lhh32d1pAOodt+NhipQySzRxnQrQPMtXEDE5ZglR2Ka7Ti0p8EeZ4qgzkJqWDsJAxvIDgZckiel4Klwz89Jqy7uNNagv0f2XCyZd8eYZxCOJvIYuCHi9WL9I49Q0oh0R9s4CkyxRw6bbOK/XQVpGrUUksPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c9AxY/NF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c9AxY/NF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73B971F00A3D; Sun, 30 Aug 2026 08:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788077449; bh=456eTZH5re1mOwITP+CRrgyuiPJU5C7OnY/8nFx1ZDY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=c9AxY/NFrk6YmMBtpXsB16Y8Vbd1+0AaacjabFZF0pnRDfVFy5Hmi2G6IDmZ9ghe1 qI7dOUiPZ4DEYk+Jroe6RyVwkh/zPP/sbJTzoC3zJuHiUCLnPW6U+1uFYfP9pTLQ73 izAsxvlg1XaJBB/3ahyXgXqogbE9+Y9fkZfDEw7pjb7f7/DG5uUZrWbVYNoTRPbsgC meTIUd7SUJXTdoBOr99jIZfPUG4n4BgzjvQjTtwK5co9DnDlHg1kQrkmnhaBRJ6IBc vFKoEf/sQnNy2S0/Vb1xiFjoJykWxEYA/7pdejplhy2d3sLlgYiF/CBdIyzmMb0khh yAHkcVEJZYFMw== From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:37 +0300 Subject: [PATCH 1/4] USB: usbfs: replace __get_free_page() with kmalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-usb-v1-1-aa349c302246@kernel.org> References: <20260830-usb-v1-0-aa349c302246@kernel.org> In-Reply-To: <20260830-usb-v1-0-aa349c302246@kernel.org> To: Chas Williams <3chas3@gmail.com>, Duncan Sands , Greg Kroah-Hartman , Johan Hovold Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , 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 X-Mailer: b4 0.17-dev 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. 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@redh= at.com Assisted-by: copilot:claude-opus Signed-off-by: Mike Rapoport (Microsoft) --- drivers/usb/core/devio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 101cb9425480..9a7cc7cdf00b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1190,7 +1190,7 @@ static int do_proc_control(struct usb_dev_state *ps, return ret; =20 ret =3D -ENOMEM; - tbuf =3D (unsigned char *)__get_free_page(GFP_KERNEL); + tbuf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!tbuf) goto done; urb =3D usb_alloc_urb(0, GFP_NOIO); @@ -1265,7 +1265,7 @@ static int do_proc_control(struct usb_dev_state *ps, done: kfree(dr); usb_free_urb(urb); - free_page((unsigned long) tbuf); + kfree(tbuf); usbfs_decrease_memory_usage(PAGE_SIZE + sizeof(struct urb) + sizeof(struct usb_ctrlrequest)); return ret; --=20 2.53.0 From nobody Sat Sep 26 21:56:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7381D39EB5B; Sun, 30 Aug 2026 08:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077454; cv=none; b=V9uv+Vahrzg2a+p7R5E1Rkw+epbO236Z/LlQsW0VL7HIZSG6/sG31q3lu6z2Ob6gtNz1DaPbXxIEeGnpYyk/AnWEVuj4FEYHcj+C2236+8zn5OyXo9pc9IKYny2sunkGUAz57S991+CQNW09jTC+2iFZ6kFPaorLhsMpyr0t21g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077454; c=relaxed/simple; bh=TODqA+9vMbMUCTXUsV2+Vje1sot+/vIZvxDEvSzzoxU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NYdVQDO6ZwjHOtOoj0x+NSaymeu0CseCFCTYBlW87U3nNnfbLxTsrVe6cma3rJwBZWKLRBUnnAUebNwtHY4jly+GQPR6cjInuWuctmkuVbstodA64W9j5O/VTCObyWsmg7leVI4haxOJfMkBbLNeMyhHzWUcAwURkG6WsGBEijM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XoUjINXM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XoUjINXM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D921F000E9; Sun, 30 Aug 2026 08:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788077453; bh=F0ab/FRyl7xwjV92cpw9DkLnKNb13jgD1FH/6y8ErV4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=XoUjINXM1Y4uac2VQ5A3L22S2Gg3pNsrrS2hFECFKPp3OzSpF4FX4Y1BIxnhRO+vG R+V7nVfJB9UZ9GZanBQZNEpqRnktgaXbb+SX+uwrY4+p8tAqOlVX0N3XRFzc0BiV+q HsD2riN4MVuw1fkt0VSmb8AQXGHJ+4/HLFB0KxqkiQhoMjJqm+ZbFQme7ieCYbADx7 +j6LQLKllK8zKsroDeAsT6iPmxOYelfZ7z3omirYLGaBFU4o7NAvGiCBSc9/VV9lPq FLftTs4vMlF3P6ufiC8VAjl0zqzx2aFqTvUsHH152ezS4xIvC/Kcux/mIOlobgLypK 6b5ATDQZF93OA== From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:38 +0300 Subject: [PATCH 2/4] USB: cxacru: replace __get_free_page() with kmalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-usb-v1-2-aa349c302246@kernel.org> References: <20260830-usb-v1-0-aa349c302246@kernel.org> In-Reply-To: <20260830-usb-v1-0-aa349c302246@kernel.org> To: Chas Williams <3chas3@gmail.com>, Duncan Sands , Greg Kroah-Hartman , Johan Hovold Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , 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 X-Mailer: b4 0.17-dev cxacru_fw() allocates a temporary buffer used to feed the firmware to the device and cxacru_bind() allocates the transfer buffers for the command URBs. These buffers can be allocated with kmalloc() as there's nothing special about them 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@redh= at.com Assisted-by: copilot:claude-opus Signed-off-by: Mike Rapoport (Microsoft) --- drivers/usb/atm/cxacru.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 636f7886fc26..75d87c31e81f 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -942,7 +942,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum c= xacru_fw_request fw, int offd, offb; const int stride =3D CMD_PACKET_SIZE - 8; =20 - buf =3D (u8 *) __get_free_page(GFP_KERNEL); + buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; =20 @@ -978,7 +978,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum c= xacru_fw_request fw, ret =3D 0; =20 cleanup: - free_page((unsigned long) buf); + kfree(buf); return ret; } =20 @@ -1146,13 +1146,13 @@ static int cxacru_bind(struct usbatm_data *usbatm_i= nstance, =20 mutex_init(&instance->adsl_state_serialize); =20 - instance->rcv_buf =3D (u8 *) __get_free_page(GFP_KERNEL); + instance->rcv_buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!instance->rcv_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n"); ret =3D -ENOMEM; goto fail; } - instance->snd_buf =3D (u8 *) __get_free_page(GFP_KERNEL); + instance->snd_buf =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!instance->snd_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n"); ret =3D -ENOMEM; @@ -1220,8 +1220,8 @@ static int cxacru_bind(struct usbatm_data *usbatm_ins= tance, return 0; =20 fail: - free_page((unsigned long) instance->snd_buf); - free_page((unsigned long) instance->rcv_buf); + kfree(instance->snd_buf); + kfree(instance->rcv_buf); usb_free_urb(instance->snd_urb); usb_free_urb(instance->rcv_urb); kfree(instance); @@ -1254,8 +1254,8 @@ static void cxacru_unbind(struct usbatm_data *usbatm_= instance, usb_free_urb(instance->snd_urb); usb_free_urb(instance->rcv_urb); =20 - free_page((unsigned long) instance->snd_buf); - free_page((unsigned long) instance->rcv_buf); + kfree(instance->snd_buf); + kfree(instance->rcv_buf); =20 kfree(instance); =20 --=20 2.53.0 From nobody Sat Sep 26 21:56:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8676639E9DE; Sun, 30 Aug 2026 08:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077460; cv=none; b=pNE2t9HZD19vM181lrTq3ta1yniePUrTVNv5tuVxKS6nkhvyOeE86j2PzEIAkHTYVDFwZwCSt7AW1Aiw678vKuMkWnpkTzahGdzl5p+mPJuQGLHNojwu8sPk+gA0BkX1AL2OecjYOoeWIevP5uY6VtTQcvFBZKQgN4E0yEX/fmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077460; c=relaxed/simple; bh=51Iq21KEmwY2b/eHw0eax2G6n4JFK+f/r+vLOJ246mw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g9s91N11+REVsEzxmdMqNcPOecg3cJxJEBXLtYD2h56CKthtzUEEQ+K2y/UTtIgW2j0VY+ikub+CzTtNmRmHgljlDU4Lcb8TfoKaxavgQpcLq1oqJKTMNryLl/b8BhwB0nPJ9/9RDdNCX5iF0PXO4J7KjuGOsXIivFntJT2q0nY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lIROzJlE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lIROzJlE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1F3E1F00A3D; Sun, 30 Aug 2026 08:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788077457; bh=nOm9eBZiZjf8UMoAxzpiMIxa0Bir8gKmGDsW4008HnU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=lIROzJlEfhe9fXXQpOEPInD3L5t2aTRzsfV9UdXXzCDPi7W2cE8UBPf37fFvWjYQk rCrWVvOSWFf1MGY+NG2XsmSU2+4zrmFZy5rS0+NKX3id4dcLkaRlhkC0G6NVYc5IrR X3kCd0YHNLYFzhlJ4Hbny1wOWbDi/TPHNbWoaaJ/8RArHJbyjT24E2QQ+KMa3ItzQK QdVfGyePaxH3c/pt9RxT2iVoXIFkX9DF0GQLhVvrRLgRPgoCwX9N0V1oPug2oha87a l5r92IFro7ZgEnUErpB3y45+eNIVtSfjOB/WNOuWl1by5KYRgXIYnwtgQvqHnl29YQ +ovxDN+LpS1gA== From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:39 +0300 Subject: [PATCH 3/4] USB: speedtch: replace __get_free_page() with kmalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-usb-v1-3-aa349c302246@kernel.org> References: <20260830-usb-v1-0-aa349c302246@kernel.org> In-Reply-To: <20260830-usb-v1-0-aa349c302246@kernel.org> To: Chas Williams <3chas3@gmail.com>, Duncan Sands , Greg Kroah-Hartman , Johan Hovold Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , 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 X-Mailer: b4 0.17-dev 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@redh= at.com Assisted-by: copilot:claude-opus Signed-off-by: Mike Rapoport (Microsoft) --- 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_ins= tance_data *instance, =20 usb_dbg(usbatm, "%s entered\n", __func__); =20 - buffer =3D (unsigned char *)__get_free_page(GFP_KERNEL); + buffer =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buffer) { ret =3D -ENOMEM; usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__); @@ -340,7 +340,7 @@ static int speedtch_upload_firmware(struct speedtch_ins= tance_data *instance, ret =3D 0; =20 out_free: - free_page((unsigned long)buffer); + kfree(buffer); out: return ret; } --=20 2.53.0 From nobody Sat Sep 26 21:56:43 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECD5439EF39; Sun, 30 Aug 2026 08:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077462; cv=none; b=F4veIyFg95dpASS7sWPpGvHv/yHgBLVE2iM67NvQOfQ1heBlZLnzH7KjJ9kShido9j4D6Ya/mMuUJxcecNdzMOq5Prlx1mA6sPEoe8IZGqsLzzwnNiZ2iH7MMlHAMftup6Hp3JiktRDVn9LnGuf5N9g4r44r1WVZR2i8StFb/nY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788077462; c=relaxed/simple; bh=hp8Mv9znBXG0owYcEsdy0ONGYwkVYXiBqvsLRzebEfw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TngBwlCmKfXta5XEmrWK5mVfFEomrxr6k1Ahge4pdJL2CZl9Kiz167TIM7sfoS6SNWFXHUM7ZSadNC/7+VfqoZhkYDLR0eLSoK4yZjXc0SUeAxQpN6UkCWDUZoJ3muCGy4oz5gvbIfdGQdMXh2ybBZyhScymAOOq8m6hE8Rjvvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gQvyf6PN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gQvyf6PN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8694B1F000E9; Sun, 30 Aug 2026 08:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788077460; bh=8L0DQGDXoOlsLX4qSHAjD9TzK8pF9McDUOUSa7CuY7A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=gQvyf6PN3R9q93P8546a/NefC9aYrfJGhZBZdpjV6Fe3KOAasOetNmw2TYaKTIaWd ti9JZzWYYUJf25XhXJF7aw0PJbG9VTxfr9PXW1aPVAuYV6OCwdRidp5UtsJBXocH7b pwkLM2eskU8MTxCy51CulWv6QW3cQOT8/GPPLXzGp3P9LspNcN5B5u6tJjV6v4Ohl8 9+AKGZNxMpWbcTaP7/ArMhsnOsBzCs83PzOlR/o2TTMC44Y85jBGh5cpjIdkpH5S// VpoNO+wsaqsn7AI+FJrQBIynEb9zdVELyRUKuEX9qJX1WsSKvPI8vgK61eeT2K36So 3LLd3zSMFkfOg== From: "Mike Rapoport (Microsoft)" Date: Sun, 30 Aug 2026 11:10:40 +0300 Subject: [PATCH 4/4] USB: serial: wwan: replace __get_free_page() with kmalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-usb-v1-4-aa349c302246@kernel.org> References: <20260830-usb-v1-0-aa349c302246@kernel.org> In-Reply-To: <20260830-usb-v1-0-aa349c302246@kernel.org> To: Chas Williams <3chas3@gmail.com>, Duncan Sands , Greg Kroah-Hartman , Johan Hovold Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , 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 X-Mailer: b4 0.17-dev usb_wwan_port_probe() allocates the transfer buffers for the read URBs. These buffers can be allocated with kmalloc() as there's nothing special about them 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. While on it, allocate IN_BUFLEN bytes rather than a full page. IN_BUFLEN is the transfer_buffer_length of the read URBs, the page allocator was only used because IN_BUFLEN happens to equal PAGE_SIZE on x86. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Assisted-by: copilot:claude-opus Signed-off-by: Mike Rapoport (Microsoft) --- drivers/usb/serial/usb_wwan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index a183cc4515ed..a3929d3a3ec1 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -455,7 +455,7 @@ int usb_wwan_port_probe(struct usb_serial_port *port) init_usb_anchor(&portdata->delayed); =20 for (i =3D 0; i < N_IN_URB; i++) { - buffer =3D (u8 *)__get_free_page(GFP_KERNEL); + buffer =3D kmalloc(IN_BUFLEN, GFP_KERNEL); if (!buffer) goto bail_out_error; portdata->in_buffer[i] =3D buffer; @@ -492,7 +492,7 @@ int usb_wwan_port_probe(struct usb_serial_port *port) bail_out_error: for (i =3D 0; i < N_IN_URB; i++) { usb_free_urb(portdata->in_urbs[i]); - free_page((unsigned long)portdata->in_buffer[i]); + kfree(portdata->in_buffer[i]); } kfree(portdata); =20 @@ -510,7 +510,7 @@ void usb_wwan_port_remove(struct usb_serial_port *port) =20 for (i =3D 0; i < N_IN_URB; i++) { usb_free_urb(portdata->in_urbs[i]); - free_page((unsigned long)portdata->in_buffer[i]); + kfree(portdata->in_buffer[i]); } for (i =3D 0; i < N_OUT_URB; i++) { usb_free_urb(portdata->out_urbs[i]); --=20 2.53.0