]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/dasd: Replace get_zeroed_page() with kzalloc()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sun, 31 May 2026 14:08:23 +0000 (17:08 +0300)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 3 Jun 2026 13:32:44 +0000 (15:32 +0200)
DASD driver uses get_zeroed_page() to allocate pages for the Extended Error
Reporting software ring buffer and for a scratch buffer for formatting
sense dump diagnostic text.

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

index 14e58c336baab5fd276df0a0ac05bf2120404d34..74fe73b5738abcc93e5ebd2e9d7fc075a475ee33 100644 (file)
@@ -5569,7 +5569,7 @@ static void dasd_eckd_dump_sense_ccw(struct dasd_device *device,
 
        dev = &device->cdev->dev;
 
-       page = (char *) get_zeroed_page(GFP_ATOMIC);
+       page = kzalloc(PAGE_SIZE, GFP_ATOMIC);
        if (page == NULL) {
                DBF_DEV_EVENT(DBF_WARNING, device, "%s",
                              "No memory to dump sense data\n");
@@ -5644,7 +5644,7 @@ static void dasd_eckd_dump_sense_ccw(struct dasd_device *device,
                }
                dasd_eckd_dump_ccw_range(device, from, last, page + len);
        }
-       free_page((unsigned long) page);
+       kfree(page);
 }
 
 
@@ -5659,7 +5659,7 @@ static void dasd_eckd_dump_sense_tcw(struct dasd_device *device,
        struct tsb *tsb;
        u8 *sense, *rcq;
 
-       page = (char *) get_zeroed_page(GFP_ATOMIC);
+       page = kzalloc(PAGE_SIZE, GFP_ATOMIC);
        if (page == NULL) {
                DBF_DEV_EVENT(DBF_WARNING, device, " %s",
                            "No memory to dump sense data");
@@ -5759,7 +5759,7 @@ static void dasd_eckd_dump_sense_tcw(struct dasd_device *device,
                sprintf(page + len, "SORRY - NO TSB DATA AVAILABLE\n");
        }
        dev_err(&device->cdev->dev, "%s", page);
-       free_page((unsigned long) page);
+       kfree(page);
 }
 
 static void dasd_eckd_dump_sense(struct dasd_device *device,
index 78d66e2711cd5c234883f38ad4a908c75279d07c..e96d1805b7bbd435091069c582bd7b0acb722e2b 100644 (file)
@@ -211,7 +211,7 @@ static void dasd_eer_free_buffer_pages(char **buf, int no_pages)
        int i;
 
        for (i = 0; i < no_pages; i++)
-               free_page((unsigned long) buf[i]);
+               kfree(buf[i]);
 }
 
 /*
@@ -222,7 +222,7 @@ static int dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
        int i;
 
        for (i = 0; i < no_pages; i++) {
-               buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
+               buf[i] = kzalloc(PAGE_SIZE, GFP_KERNEL);
                if (!buf[i]) {
                        dasd_eer_free_buffer_pages(buf, i);
                        return -ENOMEM;