]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/con3270: Replace __get_free_page() with kmalloc()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sun, 31 May 2026 14:08:22 +0000 (17:08 +0300)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 3 Jun 2026 13:32:44 +0000 (15:32 +0200)
con3270_alloc_view() allocates a staging buffer used to assemble
3270 datastream content before it is copied into channel program
requests.

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
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/char/con3270.c

index 644d3679748d43d1862a66802a4a296fd31e4392..c39da2ec22b43d5134f6215151702b8bbed1e22c 100644 (file)
@@ -880,7 +880,7 @@ static void tty3270_free_view(struct tty3270 *tp)
        raw3270_request_free(tp->kreset);
        raw3270_request_free(tp->read);
        raw3270_request_free(tp->write);
-       free_page((unsigned long)tp->converted_line);
+       kfree(tp->converted_line);
        tty_port_destroy(&tp->port);
        kfree(tp);
 }
@@ -1063,7 +1063,7 @@ static void tty3270_free(struct raw3270_view *view)
 
        timer_delete_sync(&tp->timer);
        tty3270_free_screen(tp->screen, tp->allocated_lines);
-       free_page((unsigned long)tp->converted_line);
+       kfree(tp->converted_line);
        kfree(tp->input);
        kfree(tp->prompt);
        tty3270_free_view(tp);
@@ -1121,7 +1121,7 @@ tty3270_create_view(int index, struct tty3270 **newtp)
                goto out_put_view;
        }
 
-       tp->converted_line = (void *)__get_free_page(GFP_KERNEL);
+       tp->converted_line = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!tp->converted_line) {
                rc = -ENOMEM;
                goto out_free_screen;
@@ -1167,7 +1167,7 @@ out_free_prompt:
 out_free_input:
        kfree(tp->input);
 out_free_converted_line:
-       free_page((unsigned long)tp->converted_line);
+       kfree(tp->converted_line);
 out_free_screen:
        tty3270_free_screen(tp->screen, tp->view.rows);
 out_put_view: