From nobody Sat Sep 26 19:33:35 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 228E63D3339; Mon, 31 Aug 2026 08:27: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=1788164875; cv=none; b=a3TOaagXhCXqy+wu3hfD/SfabnGbRWrLP2nWMhNysesUKBHuiiQaOp8/aksQqwR6yQVqEA+JBkWDD4ddPD09/T79GRAM1AngX6KRyBvzdsyI50wKvHDbUFz5elHy4AnMx/zC5GLflgAxVaO4Zlt8i2EbiZJjKx+FutNTLI4lQK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788164875; c=relaxed/simple; bh=58GC55K4PTU0lG/TonzKg5LuLABgL12Qb9j4kXVrRNo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=agHTUsp54P2jTU/NrFTvivdVNzJ24D8I1zPY9NdwXYBBXAIsdX2P/QvQb1ZC0aHSIDycHaqfoqVJgtBAZavuHzbV7DfFpdxFjjpWJH95lDHjCCMmKPp4PiL9CANCZfkzyh8wxTI3dJ7IhnWK3N47hsOGiSXFxgQFYjbTmgofch0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PBOjheqg; 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="PBOjheqg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 396651F00A3D; Mon, 31 Aug 2026 08:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788164873; bh=Y4bH+/WtPEyRU+oBNZLJOMfju4/GbiOfv2EYcWlAxs4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=PBOjheqgZU2//8wt0aikBUBXJMoEdiXNgcruw0QaK+0mHSMz2A20L9Y+wS1TTqm2a cB8k9NDiAwOE3FQpU0Wtkxhy3pX5eP8uV5RGROxVtznX4ozJ+fAOLG5A4gsGTtqEKV 2UX8sigBGUWxIVY2UXRFD645QP2a5kYSEjZbVx+BMbo4LUxTUoPDxH2heA4H95HwVw TCUE9QXm/lvmvJMvNdEvR4thgz5vc19pAXHDblSxIDmsO3hr4ILc8mb/dhEX4njQst xfZu6qdT+dVUxHz88Xxdx6uh7GVre1GhlxHhvGcHq48YCNkqtgmkg4M8cHiIDZDg7j ujirBHwtexgYw== From: "Mike Rapoport (Microsoft)" Date: Mon, 31 Aug 2026 11:27:43 +0300 Subject: [PATCH v2 1/3] tty: port: replace get_zeroed_page() with kzalloc() 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: <20260831-tty-v2-1-88cd58c3c640@kernel.org> References: <20260831-tty-v2-0-88cd58c3c640@kernel.org> In-Reply-To: <20260831-tty-v2-0-88cd58c3c640@kernel.org> To: Greg Kroah-Hartman , Jiri Slaby Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org X-Mailer: b4 0.17-dev tty_port_alloc_xmit_buf() allocates the transmit buffer of a tty port. The buffer only backs the port's kfifo, the data being sent is copied in and out of it. 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_zeroed_page() with kzalloc() 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/tty/tty_port.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index 54359310e293c..44122921fc45b 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -240,13 +240,13 @@ EXPORT_SYMBOL_GPL(tty_port_unregister_device); =20 int tty_port_alloc_xmit_buf(struct tty_port *port) { - /* We may sleep in get_zeroed_page() */ + /* We may sleep in kzalloc() */ guard(mutex)(&port->buf_mutex); =20 if (port->xmit_buf) return 0; =20 - port->xmit_buf =3D (u8 *)get_zeroed_page(GFP_KERNEL); + port->xmit_buf =3D kzalloc(PAGE_SIZE, GFP_KERNEL); if (port->xmit_buf =3D=3D NULL) return -ENOMEM; =20 @@ -259,7 +259,7 @@ EXPORT_SYMBOL(tty_port_alloc_xmit_buf); void tty_port_free_xmit_buf(struct tty_port *port) { guard(mutex)(&port->buf_mutex); - free_page((unsigned long)port->xmit_buf); + kfree(port->xmit_buf); port->xmit_buf =3D NULL; INIT_KFIFO(port->xmit_fifo); } @@ -288,7 +288,7 @@ static void tty_port_destructor(struct kref *kref) /* check if last port ref was dropped before tty release */ if (WARN_ON(port->itty)) return; - free_page((unsigned long)port->xmit_buf); + kfree(port->xmit_buf); tty_port_destroy(port); if (port->ops && port->ops->destruct) port->ops->destruct(port); --=20 2.53.0 From nobody Sat Sep 26 19:33:35 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 098553D647F; Mon, 31 Aug 2026 08:27: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=1788164878; cv=none; b=dzvdX8bCYB0SXd0ty2wj8DDOklm2d/rOWexnzq+VJpVH3gFoWrN1+8WCxc52sOeNfFkmbyH6GFhDb+rdOmfZUkBdlUAv+xYSbIwZiFcg6v0vOf0Mo1jRtuLZG3FIXfHMZDhVIo65rkBpHq+ugWiGzc28uQUtueWebhGq+5hH/rE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788164878; c=relaxed/simple; bh=M/Ww/7Owke9QrmLMAXp6kRxBddA5yzLmCtCEaFY9sL0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P00iC4Gni5lEXTk5rNXwoAvtR2oUakf0J4uOHQlezu7izuddROwHljA+YZ8WgEPoogxVgPYLE7dv8jkgX/Ts5ZsTRDlKLeS7F8lwwjRUa1YpHHpYueIR4fyiluaS1p01obT2ruxm578Guk93ULiP9SpES7/YeByJGhu4abXG98I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cvmsrp/R; 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="cvmsrp/R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E8111F000E9; Mon, 31 Aug 2026 08:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788164876; bh=zXWRkm+Wfn8w+zGyJ3glKrxRz07Jsyoil0yx8XutPKA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=cvmsrp/RtsT8dP5IEl7OA8SYmLdkon9cbY+CdI3SnhrNz8UxoqcNjnhM5aotPogw4 x4c0BbG5Ah8Z8fMQNLKQiJxzhGHFydk2zAfy2XqnTxF6ygIl60OpHepenBw6uX3pmg voJMeFM1p2LkEqQReCFbLYObygRjiTAzotVUaTB9ltvG+XqcTuyedptECBFyTMNr7q Xq2w1mD+t7r6dqp6u4lYZFv5f17A0mkIhqLyu8LRSr03mCO4VD+9g0kP4cO4pyhIoN wMCcswUTo6dNqAMzYtlixVmfmnCwbtaZ56fFzT1x9MSGFbs1VQF8qI0ymt89kjktav LFx1T/R8nImZw== From: "Mike Rapoport (Microsoft)" Date: Mon, 31 Aug 2026 11:27:44 +0300 Subject: [PATCH v2 2/3] serial: core: replace get_zeroed_page() with kzalloc() 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: <20260831-tty-v2-2-88cd58c3c640@kernel.org> References: <20260831-tty-v2-0-88cd58c3c640@kernel.org> In-Reply-To: <20260831-tty-v2-0-88cd58c3c640@kernel.org> To: Greg Kroah-Hartman , Jiri Slaby Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org X-Mailer: b4 0.17-dev uart_alloc_xmit_buf() allocates the transmit buffer of a serial port. The buffer only backs the port's kfifo, the data being sent is copied in and out of it. 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. While on it, make the local variable holding the buffer a pointer to get rid of the casts. Replace use of get_zeroed_page() with kzalloc() 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/tty/serial/serial_core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_c= ore.c index 95774b0f1484b..a72fe14f76771 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -247,29 +247,29 @@ static int uart_alloc_xmit_buf(struct tty_port *port) struct uart_state *state =3D container_of(port, struct uart_state, port); struct uart_port *uport; unsigned long flags; - unsigned long page; + u8 *buf; =20 /* * Initialise and allocate the transmit and temporary * buffer. */ - page =3D get_zeroed_page(GFP_KERNEL); - if (!page) + buf =3D kzalloc(PAGE_SIZE, GFP_KERNEL); + if (!buf) return -ENOMEM; =20 uport =3D uart_port_ref_lock(state, &flags); if (!state->port.xmit_buf) { - state->port.xmit_buf =3D (unsigned char *)page; + state->port.xmit_buf =3D buf; kfifo_init(&state->port.xmit_fifo, state->port.xmit_buf, PAGE_SIZE); uart_port_unlock_deref(uport, flags); } else { uart_port_unlock_deref(uport, flags); /* - * Do not free() the page under the port lock, see + * Do not free() the buffer under the port lock, see * uart_free_xmit_buf(). */ - free_page(page); + kfree(buf); } =20 return 0; @@ -280,10 +280,10 @@ static void uart_free_xmit_buf(struct tty_port *port) struct uart_state *state =3D container_of(port, struct uart_state, port); struct uart_port *uport; unsigned long flags; - char *xmit_buf; + u8 *xmit_buf; =20 /* - * Do not free() the transmit buffer page under the port lock since + * Do not free() the transmit buffer under the port lock since * this can create various circular locking scenarios. For instance, * console driver may need to allocate/free a debug object, which * can end up in printk() recursion. @@ -294,7 +294,7 @@ static void uart_free_xmit_buf(struct tty_port *port) INIT_KFIFO(port->xmit_fifo); uart_port_unlock_deref(uport, flags); =20 - free_page((unsigned long)xmit_buf); + kfree(xmit_buf); } =20 /* --=20 2.53.0 From nobody Sat Sep 26 19:33:35 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 5FFCA3D8128; Mon, 31 Aug 2026 08:28: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=1788164881; cv=none; b=kYr9PymtU9mRc4BUo9yeXRnFWDRyK0V1Yw1LWVl6RSkFEQXrkW9OmVcRO4BO6orhecUJAiB8UUQS1214uydHzcsX9Mvc9TfFgDAZgclDScBOdm4r5pOw4KsNgJMiTRIcX25vtitDYzuLYFdNou4IVhcnH8rp0wXJD2ypGeVompc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788164881; c=relaxed/simple; bh=GhNGs9SmpwgkcZvRknuKw7cWrfrw0e3tPP7q7iR+4OU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A4vlPcuoFXNQEJ/QzNzGuLplX4Aed5LMHBAlJOGptJEFZE6Lcu+jZxq5ucfpb7o1ZaDtoyVzJBTnkaKj4mvfcrS5c2VVsYsMwhWu6j5CWlSMDK0A3HaA1zNK2lJVsJw+4QCgYh7KyoYb6kjV5+oCnJgM45xxYdrNvdiIBWfGUmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CFigFzSX; 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="CFigFzSX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64C251F00A3D; Mon, 31 Aug 2026 08:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788164880; bh=UDLOrEWk8s8P9NPs/hJ9ReKcQQKs4DBoKeRaLa6eCp4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CFigFzSXaYQh2+i8PwAo/W/QAkG/+QNSnIqgZ9uo6Z81XZPLznd8ZqutwbhR4DpQK 9kjtCiNQ3KnSwEBxI6ZijIBbLCjxEwXge/vi7LM/J0iLgdXtwg6rx+8Rc2FBmCOTyf aSAnFL3rVGi88PgnzHO4Tt4XG4Zo8LByhZUhUAqvNBaS3UH0/Br64p8EBAYfyS1ywi hykMJYf6b69ZxGswHh2qHgsLNdqp0XcZT/tBcEhyMw8BemGV26GLtUoMVrc1PVOwg6 IwcPobyIcnYYdgvmTsH6+qp22iSImRew9B4QAJqbH9ikBFYeSogG0srG6SPwZRu6JH ftcvtOvQ09eCw== From: "Mike Rapoport (Microsoft)" Date: Mon, 31 Aug 2026 11:27:45 +0300 Subject: [PATCH v2 3/3] tty: hvcs: 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: <20260831-tty-v2-3-88cd58c3c640@kernel.org> References: <20260831-tty-v2-0-88cd58c3c640@kernel.org> In-Reply-To: <20260831-tty-v2-0-88cd58c3c640@kernel.org> To: Greg Kroah-Hartman , Jiri Slaby Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Mike Rapoport , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org X-Mailer: b4 0.17-dev hvcs_initialize() allocates the buffer that receives the partner info returned by the H_VTERM_PARTNER_INFO hypercall. The buffer is passed to the hypervisor as a physical address and it must not cross a page boundary. kmalloc() guarantees that a power of two sized allocation is aligned to its size, so a PAGE_SIZE allocation is page aligned as well. 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/tty/hvc/hvcs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index d32b1e3c50bfd..b94d59fa36274 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c @@ -1470,7 +1470,7 @@ static int hvcs_initialize(void) goto register_fail; } =20 - hvcs_pi_buff =3D (unsigned long *) __get_free_page(GFP_KERNEL); + hvcs_pi_buff =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!hvcs_pi_buff) { rc =3D -ENOMEM; goto buff_alloc_fail; @@ -1486,7 +1486,7 @@ static int hvcs_initialize(void) return 0; =20 kthread_fail: - free_page((unsigned long)hvcs_pi_buff); + kfree(hvcs_pi_buff); buff_alloc_fail: tty_unregister_driver(hvcs_tty_driver); register_fail: @@ -1528,7 +1528,7 @@ static void __exit hvcs_module_exit(void) kthread_stop(hvcs_task); =20 spin_lock(&hvcs_pi_lock); - free_page((unsigned long)hvcs_pi_buff); + kfree(hvcs_pi_buff); hvcs_pi_buff =3D NULL; spin_unlock(&hvcs_pi_lock); =20 --=20 2.53.0