[PATCH 2/5] s390/vmur: Replace __get_free_page() with kmalloc()
From: Mike Rapoport (Microsoft)
Date: Sun Nov 08 2026 - 03:49:45 EST
diag14_read() and verify_uri_device() allocate the buffers that receive
the spool file data returned by z/VM DIAGNOSE 0x14.
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@xxxxxxxxxx
Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
---
drivers/s390/char/vmur.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index a47a40fac8483..a13839d70eb20 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -529,7 +529,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
return rc;
len = min((size_t) PAGE_SIZE, count);
- buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
+ buf = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!buf)
return -ENOMEM;
@@ -556,7 +556,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
*offs += copied;
rc = copied;
fail:
- free_page((unsigned long) buf);
+ kfree(buf);
return rc;
}
@@ -621,7 +621,7 @@ static int verify_uri_device(struct urdev *urd)
}
/* open file on virtual reader */
- buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
+ buf = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!buf) {
rc = -ENOMEM;
goto fail_free_fcb;
@@ -641,7 +641,7 @@ static int verify_uri_device(struct urdev *urd)
rc = 0;
fail_free_buf:
- free_page((unsigned long) buf);
+ kfree(buf);
fail_free_fcb:
kfree(fcb);
return rc;
--
2.53.0