From: Mike Rapoport <rppt@kernel.org>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/3] serial: core: replace get_zeroed_page() with kzalloc()
Date: Mon, 31 Aug 2026 11:28:49 +0300 [thread overview]
Message-ID: <apU7QSOV22VJL3ay@kernel.org> (raw)
In-Reply-To: <602bdc5f-e9fa-4ed5-a009-03af860d31a6@kernel.org>
On Mon, Aug 31, 2026 at 05:02:54AM +0200, Jiri Slaby wrote:
> On 30. 08. 26, 9:49, Mike Rapoport (Microsoft) wrote:
> > 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@redhat.com
> > Assisted-by: copilot:claude-opus
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> > ---
> > drivers/tty/serial/serial_core.c | 16 ++++++++--------
> > 1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > index 95774b0f1484..f12ce7d190fe 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 = container_of(port, struct uart_state, port);
> > struct uart_port *uport;
> > unsigned long flags;
> > - unsigned long page;
>
> 1:
>
> > + unsigned char *buf;
> > /*
> > * Initialise and allocate the transmit and temporary
> > * buffer.
> > */
> > - page = get_zeroed_page(GFP_KERNEL);
> > - if (!page)
> > + buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
> > + if (!buf)
> > return -ENOMEM;
> > uport = uart_port_ref_lock(state, &flags);
> > if (!state->port.xmit_buf) {
> > - state->port.xmit_buf = (unsigned char *)page;
> > + state->port.xmit_buf = buf;
>
> xmit_buf is u8 *. This uchar was omitted when I was changing the type back
> then. Could you use the right type at 1b now?
Sure, I also made this change in uart_free_xmit_buf().
> thanks,
> --
> js
> suse labs
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-08-31 8:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 7:49 [PATCH 0/3] tty: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-08-30 7:49 ` [PATCH 1/3] tty: port: replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-08-30 8:07 ` sashiko-bot
2026-08-30 7:49 ` [PATCH 2/3] serial: core: " Mike Rapoport (Microsoft)
2026-08-30 8:00 ` sashiko-bot
2026-08-30 8:44 ` Mike Rapoport
2026-08-31 3:02 ` Jiri Slaby
2026-08-31 8:28 ` Mike Rapoport [this message]
2026-08-30 7:49 ` [PATCH 3/3] tty: hvcs: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-08-30 8:05 ` sashiko-bot
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=apU7QSOV22VJL3ay@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.