* [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc()
@ 2026-11-17 13:06 Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
` (13 more replies)
0 siblings, 14 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
This the next episode of conversion of page allocator calls to kmalloc
family :)
This series covers SCLP buffer allocations.
= tl;dr cover letter copied from the previous posts:
This is a (small) part of larger work of replacing page allocator calls
with kmalloc.
My initial intention a few month ago was to remove ugly casts [1], but then
willy pointed out that Linus objected to something like this [2] and it
looks like more than a decade old technical debt.
Largely, anything that doesn't need struct page (or a memdesc in the
future) should just use kmalloc() or kvmalloc() to allocate memory.
kmalloc() guarantees alignment, physical contiguity and working
virt_to_phys() and beside nicer API that returns void * on alloc and
doesn't require to know the allocation size on free, kmalloc() provides
better debugging capabilities than page allocator.
Another thing is that touching these allocation sites gives the reviewers
opportunity to see if a PAGE_SIZE buffer is actually needed or maybe
another size is appropriate.
For larger allocations that don't need physically contiguous memory
kvmalloc() can be a better option that __get_free_pages() because under
memory pressure it's is easier to allocate several order-0 pages than a
physically contiguous chunk with the same number of pages.
And last, but not least, removing needless calls to page allocator should
help with memdesc (aka project folio) conversion. There will be way less
places to audit to see if the user was actually using struct page.
The patches are deliberately kept small, so that every conversion can be
reviewed, and if needed reverted, on its own.
Also in git:
https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git gfp-to-kmalloc/s390-sclp
[1] https://lore.kernel.org/all/20251018093002.3660549-1-rppt@kernel.org/
[2] https://lore.kernel.org/all/CA+55aFwp4iy4rtX2gE2WjBGFL=NxMVnoFeHqYa2j1dYOMMGqxg@mail.gmail.com/
---
Changes in v2:
- sclp_cmd: allocate a power of two size for the CPU info SCCB and drop
the misleading paragraph from the commit message (Heiko, Alexander)
- sclp_ftp: use struct sysinfo_2_2_2 pointer to get rid of casts
(Heiko, Alexander, sashiko)
- add Reviewed-by tags
- Link to v1: https://patch.msgid.link/20261108-s390-sclp-ready-v1-0-3e7c90eb6676@kernel.org
---
Mike Rapoport (Microsoft) (14):
s390/sclp_vt220: Replace get_zeroed_page() with kzalloc()
s390/sclp_config: Replace get_zeroed_page() with kzalloc()
s390/sclp_pci: Replace get_zeroed_page() with kzalloc()
s390/sclp_ctl: Replace get_zeroed_page() with kzalloc()
s390/sclp_con: Replace get_zeroed_page() with kzalloc()
s390/sclp_tty: Replace get_zeroed_page() with kzalloc()
s390/sclp: Replace __get_free_page() with kmalloc()
s390/sclp_sdias: Replace __get_free_page() with kmalloc()
s390/sclp_sd: Replace __get_free_page() with kmalloc()
s390/sclp_cmd: Replace page allocator calls with kzalloc()
s390/sclp_cpi: Replace get_zeroed_page() with kzalloc()
s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
s390/sclp_mem: Replace page allocator calls with k[mz]alloc()
s390/sclp_ap: Replace get_zeroed_page() with kzalloc()
drivers/s390/char/sclp.c | 9 +++++----
drivers/s390/char/sclp_ap.c | 4 ++--
drivers/s390/char/sclp_cmd.c | 13 +++++++------
drivers/s390/char/sclp_con.c | 5 +++--
drivers/s390/char/sclp_config.c | 4 ++--
drivers/s390/char/sclp_cpi_sys.c | 4 ++--
drivers/s390/char/sclp_ctl.c | 5 +++--
drivers/s390/char/sclp_ftp.c | 14 ++++++--------
drivers/s390/char/sclp_mem.c | 12 ++++++------
drivers/s390/char/sclp_pci.c | 8 ++++----
drivers/s390/char/sclp_sd.c | 20 ++++++++++----------
drivers/s390/char/sclp_sdias.c | 5 +++--
drivers/s390/char/sclp_tty.c | 5 +++--
drivers/s390/char/sclp_vt220.c | 4 ++--
14 files changed, 58 insertions(+), 54 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260907-s390-sclp-ready-05ebba1ea5e9
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 02/14] s390/sclp_config: " Mike Rapoport (Microsoft)
` (12 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
__sclp_vt220_init() allocates the SCCBs that are used as the output
buffers of the VT220 console driver.
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_zeroed_page() with kzalloc() 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>
---
drivers/s390/char/sclp_vt220.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index b95af0974624..e79467c07d24 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -715,7 +715,7 @@ static void __init __sclp_vt220_free_pages(void)
list_for_each_safe(page, p, &sclp_vt220_empty) {
list_del(page);
- free_page((unsigned long) page);
+ kfree(page);
}
}
@@ -750,7 +750,7 @@ static int __init __sclp_vt220_init(int num_pages)
/* Allocate pages for output buffering */
rc = -ENOMEM;
for (i = 0; i < num_pages; i++) {
- page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ page = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!page)
goto out;
list_add_tail(page, &sclp_vt220_empty);
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 02/14] s390/sclp_config: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 03/14] s390/sclp_pci: " Mike Rapoport (Microsoft)
` (11 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_ofb_send_req() allocates the SCCB used to send an
"Open For Business" event notification to the SCLP.
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@redhat.com
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_config.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c
index 8c77e8c44fc2..16617a679366 100644
--- a/drivers/s390/char/sclp_config.c
+++ b/drivers/s390/char/sclp_config.c
@@ -93,7 +93,7 @@ static int sclp_ofb_send_req(char *ev_data, size_t len)
if (len > OFB_DATA_MAX)
return -EINVAL;
- sccb = (struct sclp_ofb_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
/* Setup SCCB for Control-Program Identification */
@@ -119,7 +119,7 @@ static int sclp_ofb_send_req(char *ev_data, size_t len)
rc = -EIO;
}
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 03/14] s390/sclp_pci: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 02/14] s390/sclp_config: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 04/14] s390/sclp_ctl: " Mike Rapoport (Microsoft)
` (10 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
do_pci_configure() and sclp_pci_report() allocate the SCCBs used to
(de)configure a PCI function and to report PCI errors to the SCLP.
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_zeroed_page() with kzalloc() 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>
---
drivers/s390/char/sclp_pci.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/char/sclp_pci.c b/drivers/s390/char/sclp_pci.c
index b79ef7006e46..9e3d4b101535 100644
--- a/drivers/s390/char/sclp_pci.c
+++ b/drivers/s390/char/sclp_pci.c
@@ -44,7 +44,7 @@ static int do_pci_configure(sclp_cmdw_t cmd, u32 fid)
if (!SCLP_HAS_PCI_RECONFIG)
return -EOPNOTSUPP;
- sccb = (struct pci_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
@@ -65,7 +65,7 @@ static int do_pci_configure(sclp_cmdw_t cmd, u32 fid)
break;
}
out:
- free_page((unsigned long) sccb);
+ kfree(sccb);
return rc;
}
@@ -134,7 +134,7 @@ int sclp_pci_report(struct zpci_report_error_header *report, u32 fh, u32 fid)
goto out_unregister;
}
- sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb) {
ret = -ENOMEM;
goto out_unregister;
@@ -177,7 +177,7 @@ int sclp_pci_report(struct zpci_report_error_header *report, u32 fh, u32 fid)
}
out_free_req:
- free_page((unsigned long) sccb);
+ kfree(sccb);
out_unregister:
sclp_unregister(&sclp_pci_event);
out_unlock:
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 04/14] s390/sclp_ctl: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (2 preceding siblings ...)
2026-11-17 13:06 ` [PATCH v2 03/14] s390/sclp_pci: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 05/14] s390/sclp_con: " Mike Rapoport (Microsoft)
` (9 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_ctl_ioctl_sccb() allocates the SCCB that carries a user supplied
SCLP command.
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@redhat.com
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_ctl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_ctl.c b/drivers/s390/char/sclp_ctl.c
index e23a97359286..84aefff3be98 100644
--- a/drivers/s390/char/sclp_ctl.c
+++ b/drivers/s390/char/sclp_ctl.c
@@ -8,6 +8,7 @@
*/
#include <linux/uaccess.h>
+#include <linux/slab.h>
#include <linux/miscdevice.h>
#include <linux/gfp.h>
#include <linux/init.h>
@@ -59,7 +60,7 @@ static int sclp_ctl_ioctl_sccb(void __user *user_area)
return -EFAULT;
if (!sclp_ctl_cmdw_supported(ctl_sccb.cmdw))
return -EOPNOTSUPP;
- sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
copied = PAGE_SIZE -
@@ -79,7 +80,7 @@ static int sclp_ctl_ioctl_sccb(void __user *user_area)
if (copy_to_user(u64_to_uptr(ctl_sccb.sccb), sccb, sccb->length))
rc = -EFAULT;
out_free:
- free_page((unsigned long) sccb);
+ kfree(sccb);
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 05/14] s390/sclp_con: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (3 preceding siblings ...)
2026-11-17 13:06 ` [PATCH v2 04/14] s390/sclp_ctl: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 06/14] s390/sclp_tty: " Mike Rapoport (Microsoft)
` (8 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_console_init() allocates the SCCBs that are used as the output
buffers of the SCLP line mode console.
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_zeroed_page() with kzalloc() 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>
---
drivers/s390/char/sclp_con.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_con.c b/drivers/s390/char/sclp_con.c
index d8544c485808..9d096d7b5968 100644
--- a/drivers/s390/char/sclp_con.c
+++ b/drivers/s390/char/sclp_con.c
@@ -8,6 +8,7 @@
*/
#include <linux/kmod.h>
+#include <linux/slab.h>
#include <linux/console.h>
#include <linux/init.h>
#include <linux/panic_notifier.h>
@@ -272,7 +273,7 @@ static void __init __sclp_console_free_pages(void)
list_for_each_safe(page, p, &sclp_con_pages) {
list_del(page);
- free_page((unsigned long)page);
+ kfree(page);
}
}
@@ -294,7 +295,7 @@ sclp_console_init(void)
return rc;
/* Allocate pages for output buffering */
for (i = 0; i < sclp_console_pages; i++) {
- page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ page = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!page) {
__sclp_console_free_pages();
return -ENOMEM;
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 06/14] s390/sclp_tty: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (4 preceding siblings ...)
2026-11-17 13:06 ` [PATCH v2 05/14] s390/sclp_con: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 07/14] s390/sclp: Replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
` (7 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_tty_init() allocates the SCCBs that are used as the output buffers
of the SCLP line mode terminal.
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_zeroed_page() with kzalloc() 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>
---
drivers/s390/char/sclp_tty.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 0a92d08830e7..e36739bd2732 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -9,6 +9,7 @@
*/
#include <linux/kmod.h>
+#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
@@ -497,7 +498,7 @@ static void __init __sclp_tty_free_pages(void)
list_for_each_safe(page, p, &sclp_tty_pages) {
list_del(page);
- free_page((unsigned long)page);
+ kfree(page);
}
}
@@ -525,7 +526,7 @@ sclp_tty_init(void)
}
/* Allocate pages for output buffering */
for (i = 0; i < MAX_KMEM_PAGES; i++) {
- page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ page = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (page == NULL) {
__sclp_tty_free_pages();
tty_driver_kref_put(driver);
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 07/14] s390/sclp: Replace __get_free_page() with kmalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (5 preceding siblings ...)
2026-11-17 13:06 ` [PATCH v2 06/14] s390/sclp_tty: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:06 ` Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 08/14] s390/sclp_sdias: " Mike Rapoport (Microsoft)
` (6 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:06 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_init() allocates the SCCBs used for reading SCLP events and for
the SCLP init mask request.
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@redhat.com
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/char/sclp.c b/drivers/s390/char/sclp.c
index 98e334724a62..bfbac6dfa053 100644
--- a/drivers/s390/char/sclp.c
+++ b/drivers/s390/char/sclp.c
@@ -20,6 +20,7 @@
#include <linux/jiffies.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/slab.h>
#include <asm/types.h>
#include <asm/irq.h>
#include <asm/debug.h>
@@ -1268,8 +1269,8 @@ int sclp_init(void)
if (sclp_init_state != sclp_init_state_uninitialized)
goto fail_unlock;
sclp_init_state = sclp_init_state_initializing;
- sclp_read_sccb = (void *) __get_free_page(GFP_ATOMIC | GFP_DMA);
- sclp_init_sccb = (void *) __get_free_page(GFP_ATOMIC | GFP_DMA);
+ sclp_read_sccb = kmalloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
+ sclp_init_sccb = kmalloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
BUG_ON(!sclp_read_sccb || !sclp_init_sccb);
/* Set up variables */
list_add(&sclp_state_change_event.list, &sclp_reg_list);
@@ -1302,8 +1303,8 @@ int sclp_init(void)
fail_init_state_uninitialized:
list_del(&sclp_state_change_event.list);
sclp_init_state = sclp_init_state_uninitialized;
- free_page((unsigned long) sclp_read_sccb);
- free_page((unsigned long) sclp_init_sccb);
+ kfree(sclp_read_sccb);
+ kfree(sclp_init_sccb);
fail_unlock:
spin_unlock_irqrestore(&sclp_lock, flags);
return rc;
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 08/14] s390/sclp_sdias: Replace __get_free_page() with kmalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (6 preceding siblings ...)
2026-11-17 13:06 ` [PATCH v2 07/14] s390/sclp: Replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 09/14] s390/sclp_sd: " Mike Rapoport (Microsoft)
` (5 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_sdias_init() allocates the SCCB used for the SCLP store dump
information 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>
---
drivers/s390/char/sclp_sdias.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_sdias.c b/drivers/s390/char/sclp_sdias.c
index ab8f1b758a1a..a1a17a9e4a91 100644
--- a/drivers/s390/char/sclp_sdias.c
+++ b/drivers/s390/char/sclp_sdias.c
@@ -10,6 +10,7 @@
#include <linux/completion.h>
#include <linux/sched.h>
+#include <linux/slab.h>
#include <asm/sclp.h>
#include <asm/debug.h>
#include <asm/ipl.h>
@@ -258,7 +259,7 @@ int __init sclp_sdias_init(void)
{
if (!is_ipl_type_dump())
return 0;
- sclp_sdias_sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
+ sclp_sdias_sccb = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
BUG_ON(!sclp_sdias_sccb);
sdias_dbf = debug_register("dump_sdias", 4, 1, 4 * sizeof(long));
debug_register_view(sdias_dbf, &debug_sprintf_view);
@@ -268,7 +269,7 @@ int __init sclp_sdias_init(void)
if (sclp_sdias_init_async() == 0)
goto out;
TRACE("init failed\n");
- free_page((unsigned long) sclp_sdias_sccb);
+ kfree(sclp_sdias_sccb);
return -ENODEV;
out:
TRACE("init done\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 09/14] s390/sclp_sd: Replace __get_free_page() with kmalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (7 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 08/14] s390/sclp_sdias: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc() Mike Rapoport (Microsoft)
` (4 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_sd_store_data() allocates the SCCB used for the SCLP store data
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.
While on it, pass the SCCB to sclp_sd_sync() as a typed pointer instead
of an unsigned long.
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>
---
drivers/s390/char/sclp_sd.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/s390/char/sclp_sd.c b/drivers/s390/char/sclp_sd.c
index c62b2eacdc13..cc0b4481e2be 100644
--- a/drivers/s390/char/sclp_sd.c
+++ b/drivers/s390/char/sclp_sd.c
@@ -173,7 +173,7 @@ static struct sclp_register sclp_sd_register = {
/**
* sclp_sd_sync() - Perform Store Data request synchronously
- * @page: Address of work page - must be below 2GB
+ * @sccb: Address of work SCCB - must be below 2GB
* @eq: Input EQ value
* @di: Input DI value
* @sat: Input SAT value
@@ -186,10 +186,9 @@ static struct sclp_register sclp_sd_register = {
* Return %0 on success and store resulting DSIZE and ESIZE values in
* @dsize_ptr and @esize_ptr (if provided). Return non-zero on error.
*/
-static int sclp_sd_sync(unsigned long page, u8 eq, u8 di, u64 sat, u64 sa,
+static int sclp_sd_sync(struct sclp_sd_sccb *sccb, u8 eq, u8 di, u64 sat, u64 sa,
u32 *dsize_ptr, u32 *esize_ptr)
{
- struct sclp_sd_sccb *sccb = (void *) page;
struct sclp_sd_listener listener;
struct sclp_sd_evbuf *evbuf;
int rc;
@@ -291,17 +290,18 @@ static int sclp_sd_sync(unsigned long page, u8 eq, u8 di, u64 sat, u64 sa,
*/
static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di)
{
+ struct sclp_sd_sccb *sccb;
u32 dsize = 0, esize = 0;
- unsigned long page, asce = 0;
+ unsigned long asce = 0;
void *data = NULL;
int rc;
- page = __get_free_page(GFP_KERNEL | GFP_DMA);
- if (!page)
+ sccb = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
+ if (!sccb)
return -ENOMEM;
/* Get size */
- rc = sclp_sd_sync(page, SD_EQ_SIZE, di, 0, 0, &dsize, &esize);
+ rc = sclp_sd_sync(sccb, SD_EQ_SIZE, di, 0, 0, &dsize, &esize);
if (rc)
goto out;
if (dsize == 0)
@@ -323,12 +323,12 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di)
}
/* Get data */
- rc = sclp_sd_sync(page, SD_EQ_STORE_DATA, di, asce, (u64) data, &dsize,
+ rc = sclp_sd_sync(sccb, SD_EQ_STORE_DATA, di, asce, (u64) data, &dsize,
&esize);
if (rc) {
/* Cancel running request if interrupted or timed out */
if (rc == -ERESTARTSYS || rc == -ETIME) {
- if (sclp_sd_sync(page, SD_EQ_HALT, di, 0, 0, NULL, NULL)) {
+ if (sclp_sd_sync(sccb, SD_EQ_HALT, di, 0, 0, NULL, NULL)) {
pr_warn("Could not stop Store Data request - leaking at least %zu bytes\n",
(size_t)dsize * PAGE_SIZE);
data = NULL;
@@ -346,7 +346,7 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di)
out:
base_asce_free(asce);
- free_page(page);
+ kfree(sccb);
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (8 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 09/14] s390/sclp_sd: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 15:33 ` Heiko Carstens
2026-11-17 13:07 ` [PATCH v2 11/14] s390/sclp_cpi: Replace get_zeroed_page() " Mike Rapoport (Microsoft)
` (3 subsequent siblings)
13 siblings, 1 reply; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
_sclp_get_core_info(), do_chp_configure() and sclp_chp_read_info()
allocate the SCCBs used to read the CPU information, to configure a
channel path and to read the channel path information.
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.
Keep a power of two size for the SCCB in _sclp_get_core_info() so that
kmalloc() returns a page aligned buffer.
Replace use of __get_free_pages() and get_zeroed_page() with kzalloc()
and free_page[s]() with kfree().
Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_cmd.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index 1dc93d945be6..9f70f67049e4 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -102,7 +102,8 @@ int _sclp_get_core_info(struct sclp_core_info *info)
return -EOPNOTSUPP;
length = test_facility(140) ? EXT_SCCB_READ_CPU : PAGE_SIZE;
- sccb = (void *)__get_free_pages(GFP_KERNEL | GFP_DMA | __GFP_ZERO, get_order(length));
+ /* the SCCB must be page aligned, hence power of two size */
+ sccb = kzalloc(PAGE_SIZE << get_order(length), GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = length;
@@ -119,7 +120,7 @@ int _sclp_get_core_info(struct sclp_core_info *info)
}
sclp_fill_core_info(info, sccb);
out:
- free_pages((unsigned long)sccb, get_order(length));
+ kfree(sccb);
return rc;
}
@@ -173,7 +174,7 @@ static int do_chp_configure(sclp_cmdw_t cmd)
if (!SCLP_HAS_CHP_RECONFIG)
return -EOPNOTSUPP;
- sccb = (struct chp_cfg_sccb *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = sizeof(*sccb);
@@ -193,7 +194,7 @@ static int do_chp_configure(sclp_cmdw_t cmd)
break;
}
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
@@ -236,7 +237,7 @@ int sclp_chp_read_info(struct sclp_chp_info *info)
if (!SCLP_HAS_CHP_INFO)
return -EOPNOTSUPP;
- sccb = (struct chp_info_sccb *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = sizeof(*sccb);
@@ -253,6 +254,6 @@ int sclp_chp_read_info(struct sclp_chp_info *info)
memcpy(info->standby, sccb->standby, SCLP_CHP_INFO_MASK_SIZE);
memcpy(info->configured, sccb->configured, SCLP_CHP_INFO_MASK_SIZE);
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 11/14] s390/sclp_cpi: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (9 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc() Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 12/14] s390/sclp_ftp: " Mike Rapoport (Microsoft)
` (2 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
cpi_prepare_req() allocates the SCCB used to send the control program
identification to the SCLP.
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@redhat.com
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_cpi_sys.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_cpi_sys.c b/drivers/s390/char/sclp_cpi_sys.c
index b80f73fa1e01..8bca2cdb34c1 100644
--- a/drivers/s390/char/sclp_cpi_sys.c
+++ b/drivers/s390/char/sclp_cpi_sys.c
@@ -84,7 +84,7 @@ static struct sclp_req *cpi_prepare_req(void)
req = kzalloc_obj(struct sclp_req);
if (!req)
return ERR_PTR(-ENOMEM);
- sccb = (struct cpi_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb) {
kfree(req);
return ERR_PTR(-ENOMEM);
@@ -118,7 +118,7 @@ static struct sclp_req *cpi_prepare_req(void)
static void cpi_free_req(struct sclp_req *req)
{
- free_page((unsigned long) req->sccb);
+ kfree(req->sccb);
kfree(req);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 12/14] s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (10 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 11/14] s390/sclp_cpi: Replace get_zeroed_page() " Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 15:34 ` Heiko Carstens
2026-11-17 13:07 ` [PATCH v2 13/14] s390/sclp_mem: Replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 14/14] s390/sclp_ap: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
13 siblings, 1 reply; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
sclp_ftp_et7() allocates the SCCB used for an HMC file transfer request
and sclp_ftp_startup() allocates the buffer for the SYSIB 2.2.2 stored
by stsi() in the debug code.
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.
While on it, make the SYSIB 2.2.2 buffer a struct sysinfo_2_2_2 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
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_ftp.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/s390/char/sclp_ftp.c b/drivers/s390/char/sclp_ftp.c
index 853492d53953..904a53ecb6ed 100644
--- a/drivers/s390/char/sclp_ftp.c
+++ b/drivers/s390/char/sclp_ftp.c
@@ -93,7 +93,7 @@ static int sclp_ftp_et7(const struct hmcdrv_ftp_cmdspec *ftp)
int rc;
req = kzalloc_obj(*req);
- sccb = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!req || !sccb) {
rc = -ENOMEM;
goto out_free;
@@ -155,7 +155,7 @@ static int sclp_ftp_et7(const struct hmcdrv_ftp_cmdspec *ftp)
}
out_free:
- free_page((unsigned long) sccb);
+ kfree(sccb);
kfree(req);
return rc;
}
@@ -241,7 +241,7 @@ static struct sclp_register sclp_ftp_event = {
int sclp_ftp_startup(void)
{
#ifdef DEBUG
- unsigned long info;
+ struct sysinfo_2_2_2 *info222;
#endif
int rc;
@@ -250,11 +250,9 @@ int sclp_ftp_startup(void)
return rc;
#ifdef DEBUG
- info = get_zeroed_page(GFP_KERNEL);
-
- if (info != 0) {
- struct sysinfo_2_2_2 *info222 = (struct sysinfo_2_2_2 *)info;
+ info222 = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ if (info222) {
if (!stsi(info222, 2, 2, 2)) { /* get SYSIB 2.2.2 */
info222->name[sizeof(info222->name) - 1] = '\0';
EBCASC_500(info222->name, sizeof(info222->name) - 1);
@@ -262,7 +260,7 @@ int sclp_ftp_startup(void)
info222->lpar_number, info222->name);
}
- free_page(info);
+ kfree(info222);
}
#endif /* DEBUG */
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 13/14] s390/sclp_mem: Replace page allocator calls with k[mz]alloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (11 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 12/14] s390/sclp_ftp: " Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 14/14] s390/sclp_ap: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
do_assign_storage(), sclp_attach_storage() and sclp_setup_memory()
allocate the SCCBs used to assign, attach and query standby memory.
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_zeroed_page() with kzalloc(), __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>
---
drivers/s390/char/sclp_mem.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/s390/char/sclp_mem.c b/drivers/s390/char/sclp_mem.c
index 6df1926d4c62..c28460598d38 100644
--- a/drivers/s390/char/sclp_mem.c
+++ b/drivers/s390/char/sclp_mem.c
@@ -84,7 +84,7 @@ static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
struct assign_storage_sccb *sccb;
int rc;
- sccb = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = PAGE_SIZE;
@@ -103,7 +103,7 @@ static int do_assign_storage(sclp_cmdw_t cmd, u16 rn)
break;
}
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
@@ -130,7 +130,7 @@ static int sclp_attach_storage(u8 id)
struct attach_storage_sccb *sccb;
int rc, i;
- sccb = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
sccb->header.length = PAGE_SIZE;
@@ -152,7 +152,7 @@ static int sclp_attach_storage(u8 id)
break;
}
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
@@ -487,7 +487,7 @@ static int __init sclp_setup_memory(void)
if ((sclp.facilities & 0xe00000000000UL) != 0xe00000000000UL)
return 0;
rc = -ENOMEM;
- sccb = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+ sccb = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
goto out;
assigned = 0;
@@ -530,7 +530,7 @@ static int __init sclp_setup_memory(void)
insert_increment(0, 1, 0);
rc = sclp_init_mem();
out:
- free_page((unsigned long)sccb);
+ kfree(sccb);
return rc;
}
__initcall(sclp_setup_memory);
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 14/14] s390/sclp_ap: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
` (12 preceding siblings ...)
2026-11-17 13:07 ` [PATCH v2 13/14] s390/sclp_mem: Replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
@ 2026-11-17 13:07 ` Mike Rapoport (Microsoft)
13 siblings, 0 replies; 17+ messages in thread
From: Mike Rapoport (Microsoft) @ 2026-11-17 13:07 UTC (permalink / raw)
To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Cc: Christian Borntraeger, David Hildenbrand, Mike Rapoport,
Sven Schnelle, Vlastimil Babka, linux-s390, linux-kernel,
linux-mm
do_ap_configure() allocates the SCCB used to configure and deconfigure
AP adapters.
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@redhat.com
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
drivers/s390/char/sclp_ap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/char/sclp_ap.c b/drivers/s390/char/sclp_ap.c
index 18bb018b4e0c..15dff5dc0cac 100644
--- a/drivers/s390/char/sclp_ap.c
+++ b/drivers/s390/char/sclp_ap.c
@@ -26,7 +26,7 @@ static int do_ap_configure(sclp_cmdw_t cmd, u32 apid)
if (!SCLP_HAS_AP_RECONFIG)
return -EOPNOTSUPP;
- sccb = (struct ap_cfg_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ sccb = kzalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
if (!sccb)
return -ENOMEM;
@@ -45,7 +45,7 @@ static int do_ap_configure(sclp_cmdw_t cmd, u32 apid)
break;
}
out:
- free_page((unsigned long) sccb);
+ kfree(sccb);
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc()
2026-11-17 13:07 ` [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc() Mike Rapoport (Microsoft)
@ 2026-11-17 15:33 ` Heiko Carstens
0 siblings, 0 replies; 17+ messages in thread
From: Heiko Carstens @ 2026-11-17 15:33 UTC (permalink / raw)
To: Mike Rapoport (Microsoft)
Cc: Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
David Hildenbrand, Sven Schnelle, Vlastimil Babka, linux-s390,
linux-kernel, linux-mm
On Tue, Nov 17, 2026 at 03:07:02PM +0200, Mike Rapoport (Microsoft) wrote:
> _sclp_get_core_info(), do_chp_configure() and sclp_chp_read_info()
> allocate the SCCBs used to read the CPU information, to configure a
> channel path and to read the channel path information.
>
> 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.
>
> Keep a power of two size for the SCCB in _sclp_get_core_info() so that
> kmalloc() returns a page aligned buffer.
>
> Replace use of __get_free_pages() and get_zeroed_page() with kzalloc()
> and free_page[s]() with kfree().
>
> Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> drivers/s390/char/sclp_cmd.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 12/14] s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
2026-11-17 13:07 ` [PATCH v2 12/14] s390/sclp_ftp: " Mike Rapoport (Microsoft)
@ 2026-11-17 15:34 ` Heiko Carstens
0 siblings, 0 replies; 17+ messages in thread
From: Heiko Carstens @ 2026-11-17 15:34 UTC (permalink / raw)
To: Mike Rapoport (Microsoft)
Cc: Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
David Hildenbrand, Sven Schnelle, Vlastimil Babka, linux-s390,
linux-kernel, linux-mm
On Tue, Nov 17, 2026 at 03:07:04PM +0200, Mike Rapoport (Microsoft) wrote:
> sclp_ftp_et7() allocates the SCCB used for an HMC file transfer request
> and sclp_ftp_startup() allocates the buffer for the SYSIB 2.2.2 stored
> by stsi() in the debug code.
>
> 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.
>
> While on it, make the SYSIB 2.2.2 buffer a struct sysinfo_2_2_2 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
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> drivers/s390/char/sclp_ftp.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Thanks for the series. Will be picked up and routed via s390.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-11-17 15:34 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 13:06 [PATCH v2 00/14] s390/sclp: replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 02/14] s390/sclp_config: " Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 03/14] s390/sclp_pci: " Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 04/14] s390/sclp_ctl: " Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 05/14] s390/sclp_con: " Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 06/14] s390/sclp_tty: " Mike Rapoport (Microsoft)
2026-11-17 13:06 ` [PATCH v2 07/14] s390/sclp: Replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 08/14] s390/sclp_sdias: " Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 09/14] s390/sclp_sd: " Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc() Mike Rapoport (Microsoft)
2026-11-17 15:33 ` Heiko Carstens
2026-11-17 13:07 ` [PATCH v2 11/14] s390/sclp_cpi: Replace get_zeroed_page() " Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 12/14] s390/sclp_ftp: " Mike Rapoport (Microsoft)
2026-11-17 15:34 ` Heiko Carstens
2026-11-17 13:07 ` [PATCH v2 13/14] s390/sclp_mem: Replace page allocator calls with k[mz]alloc() Mike Rapoport (Microsoft)
2026-11-17 13:07 ` [PATCH v2 14/14] s390/sclp_ap: Replace get_zeroed_page() with kzalloc() Mike Rapoport (Microsoft)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox