All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 3/4] scsi: ipr: use kmalloc() to allocate IPR dump buffer memory
Date: Tue, 30 Jun 2026 11:28:59 +0000	[thread overview]
Message-ID: <20260630112901.0DD1E1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260630-b4-scsi-v1-3-494fb37ebe7b@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Switching from __get_free_page() to kmalloc() for bulk PAGE_SIZE allocations worsens memory fragmentation resilience and increases the likelihood of allocation failure.

Pre-existing issues:
- [High] Unnecessary use of GFP_ATOMIC in a fully sleepable context drains atomic memory reserves and causes large allocations to fail.
--

commit 031dbb9ad5b7614bab879909db8f301be9752516
Author: Mike Rapoport (Microsoft) <rppt@kernel.org>

scsi: ipr: use kmalloc() to allocate IPR dump buffer memory

This commit replaces __get_free_page() and free_page() with kmalloc() and
kfree() for allocating the IPR dump buffer. The goal is to provide a cleaner
API without requiring casts or tracking the allocation size during free.

Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com

> diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
> index d207e5e81afe0..5a212bfdeec2b 100644
> --- a/drivers/scsi/ipr.c
> +++ b/drivers/scsi/ipr.c
> @@ -2893,7 +2893,7 @@ static int ipr_sdt_copy(struct ipr_ioa_cfg *ioa_cfg,
>  	       (ioa_dump->hdr.len + bytes_copied) < max_dump_size) {
>  		if (ioa_dump->page_offset >= PAGE_SIZE ||
>  		    ioa_dump->page_offset == 0) {
> -			page = (__be32 *)__get_free_page(GFP_ATOMIC);
> +			page = kmalloc(PAGE_SIZE, GFP_ATOMIC);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
This is a pre-existing issue, but does this allocation actually need to use
GFP_ATOMIC?

Looking at ipr_sdt_copy(), the allocation happens in a loop that explicitly
yields the CPU by calling schedule() at the end of each iteration. No spinlocks
are held across the allocation (host_lock is acquired later). Since the context
appears to be fully sleepable, using GFP_ATOMIC to allocate up to 80MB of memory
unnecessarily drains emergency reserves, potentially starving actual atomic
contexts like interrupt handlers.

[Severity: High]
Does switching to kmalloc() for PAGE_SIZE chunks increase the likelihood of
allocation failures under memory fragmentation?

If memory debugging options like KASAN or SLUB debugging are enabled, the SLUB
allocator inflates the requested PAGE_SIZE with metadata. This pushes the
allocation into a larger size class (e.g., kmalloc-8k), requiring higher-order
page allocations (order-1 or more) from the page allocator. Since the
allocation still uses GFP_ATOMIC, which cannot sleep or wait for direct reclaim,
requesting order-1+ pages is far more likely to fail under memory fragmentation
compared to the original order-0 requests.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630-b4-scsi-v1-0-494fb37ebe7b@kernel.org?part=3

  reply	other threads:[~2026-06-30 11:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 10:54 [PATCH 0/4] scsi: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-06-30 10:54 ` [PATCH 1/4] scsi: target: file: use kmalloc() to allocate temporary protection buffer Mike Rapoport (Microsoft)
2026-07-01  6:58   ` Hannes Reinecke
2026-06-30 10:54 ` [PATCH 2/4] scsi: proc: use kmalloc() in proc writers Mike Rapoport (Microsoft)
2026-06-30 11:19   ` sashiko-bot
2026-07-01  6:58   ` Hannes Reinecke
2026-07-01 10:52   ` John Garry
2026-07-01 13:50     ` Mike Rapoport
2026-06-30 10:54 ` [PATCH 3/4] scsi: ipr: use kmalloc() to allocate IPR dump buffer memory Mike Rapoport (Microsoft)
2026-06-30 11:28   ` sashiko-bot [this message]
2026-07-01  7:03   ` Hannes Reinecke
2026-07-01  9:52     ` Mike Rapoport
2026-07-01 21:03       ` Brian King
2026-07-02  6:55         ` Mike Rapoport
2026-07-02 19:56           ` Brian King
2026-07-02 22:04             ` Wen Xiong
2026-07-03  7:49           ` Mike Rapoport
2026-07-03  8:35             ` Hannes Reinecke
2026-07-07 13:17             ` Brian King
2026-06-30 10:54 ` [PATCH 4/4] scsi: sym53c8xx_2: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-06-30 11:37   ` sashiko-bot
2026-07-01  7:04   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260630112901.0DD1E1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.