s390/sclp: replace page allocator calls with k[mz]alloc()
Subsystems (2)
v2 cover s390/sclp: replace page allocator calls with k[mz]alloc()
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/[email protected]/
[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/[email protected]
---
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.
PATCH v2 1/14 s390/sclp_vt220: Replace get_zeroed_page() with kzalloc()
__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().
--- drivers/s390/char/sclp_vt220.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_vt220.c +2 -2
@@ -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);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 01/14] s390/sclp_vt220: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
__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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 2/14 s390/sclp_config: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_config.c +2 -2
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 02/14] s390/sclp_config: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v2 3/14 s390/sclp_pci: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/s390/char/sclp_pci.c +4 -4
@@ -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:
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 03/14] s390/sclp_pci: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
do_pci_configure()andsclp_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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v2 4/14 s390/sclp_ctl: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_ctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_ctl.c +3 -2
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 04/14] s390/sclp_ctl: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH v2 5/14 s390/sclp_con: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_con.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_con.c +3 -2
@@ -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 ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 05/14] s390/sclp_con: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH v2 6/14 s390/sclp_tty: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_tty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_tty.c +3 -2
@@ -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);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 06/14] s390/sclp_tty: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH v2 7/14 s390/sclp: Replace __get_free_page() with kmalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/s390/char/sclp.c +5 -4
@@ -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;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 07/14] s390/sclp: Replace __get_free_page() with kmalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
__get_free_page()withkmalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH v2 8/14 s390/sclp_sdias: Replace __get_free_page() with kmalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_sdias.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_sdias.c +3 -2
@@ -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" );
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 08/14] s390/sclp_sdias: Replace __get_free_page() with kmalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
__get_free_page()withkmalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
PATCH v2 9/14 s390/sclp_sd: Replace __get_free_page() with kmalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_sd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/s390/char/sclp_sd.c +10 -10
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 09/14] s390/sclp_sd: Replace __get_free_page() with kmalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 19 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
__get_free_page()withkmalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
PATCH v2 10/14 s390/sclp_cmd: Replace page allocator calls with kzalloc()
In reply to Mike Rapoport (Microsoft)_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().
--- drivers/s390/char/sclp_cmd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/s390/char/sclp_cmd.c +7 -6
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines
_sclp_get_core_info(),do_chp_configure()andsclp_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 andkfree()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.
Quoted 8 lines
Keep a power of two size for the SCCB in
_sclp_get_core_info()so thatkmalloc()returns a page aligned buffer.Replace use of
__get_free_pages()andget_zeroed_page()withkzalloc()and free_page[s]() withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Re: [PATCH v2 10/14] s390/sclp_cmd: Replace page allocator calls with kzalloc()
In reply to Mike Rapoport (Microsoft)Quoted 20 lines · Mike Rapoport (Microsoft)
_sclp_get_core_info(),do_chp_configure()andsclp_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 andkfree()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 thatkmalloc()returns a page aligned buffer.
Quoted 8 lines
Replace use of
__get_free_pages()andget_zeroed_page()withkzalloc()and free_page[s]() withkfree().Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- drivers/s390/char/sclp_cmd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
PATCH v2 11/14 s390/sclp_cpi: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_cpi_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_cpi_sys.c +2 -2
@@ -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); }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 11/14] s390/sclp_cpi: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v2 12/14 s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_ftp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/s390/char/sclp_ftp.c +6 -8
@@ -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 ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 12/14] s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 17 lines
sclp_ftp_et7()allocates the SCCB used for an HMC file transfer request andsclp_ftp_startup()allocates the buffer for the SYSIB 2.2.2 stored bystsi()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 andkfree()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.
Quoted 8 lines
While on it, make the SYSIB 2.2.2 buffer a struct
sysinfo_2_2_2pointer to get rid of the casts.Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Re: [PATCH v2 12/14] s390/sclp_ftp: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)Quoted 20 lines · Mike Rapoport (Microsoft)
sclp_ftp_et7()allocates the SCCB used for an HMC file transfer request andsclp_ftp_startup()allocates the buffer for the SYSIB 2.2.2 stored bystsi()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 andkfree()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_2pointer to get rid of the casts.
Quoted 8 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().Signed-off-by Mike Rapoport (Microsoft) <[email protected]>--- drivers/s390/char/sclp_ftp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Thanks for the series. Will be picked up and routed via s390.
PATCH v2 13/14 s390/sclp_mem: Replace page allocator calls with k[mz]alloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_mem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/s390/char/sclp_mem.c +6 -6
@@ -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);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 13/14] s390/sclp_mem: Replace page allocator calls with k[mz]alloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
do_assign_storage(),sclp_attach_storage()andsclp_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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc(),__get_free_page()withkmalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
PATCH v2 14/14 s390/sclp_ap: Replace get_zeroed_page() with kzalloc()
In reply to Mike Rapoport (Microsoft)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().
--- drivers/s390/char/sclp_ap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/char/sclp_ap.c +2 -2
@@ -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; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 14/14] s390/sclp_ap: Replace get_zeroed_page() with kzalloc()
Sashiko has reviewed this patch and found no issues.
Quoted 16 lines
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 andkfree()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.
Quoted 6 lines
Replace use of
get_zeroed_page()withkzalloc()andfree_page()withkfree().
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
Quoted 42 lines · Mike Rapoport (Microsoft)
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()orkvmalloc()to allocate memory.kmalloc()guarantees alignment, physical contiguity and workingvirt_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_SIZEbuffer 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/[email protected]/
[2] https://lore.kernel.org/all/CA+55aFwp4iy4rtX2gE2WjBGFL=NxMVnoFeHqYa2j1dYOMMGqxg@mail.gmail.com/
...
Quoted 15 lines
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(-)
Quoted 3 lines
---
base-commit:6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260907-s390-sclp-ready-05ebba1ea5e9
Applied, thanks!
Quoted 3 lines
--
Sincerely yours,
Mike.