From: sashiko-bot@kernel.org
To: "Ping Li" <leeonion.muyu@gmail.com>,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com
Cc: tudor.ambarus@linaro.org, kyungmin.park@samsung.com,
linux-mtd@lists.infradead.org
Subject: Re: [PATCH v4 1/4] mtd: core: add per-device bounce buffer allocation helper
Date: Fri, 04 Dec 2026 09:39:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-249529@kernel.org> (raw)
In-Reply-To: <20261204091640.444442-2-leeonion.muyu@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] mtd: mtd_alloc_buf() uses arch-dependent KMALLOC_MAX_SIZE for
vmalloc cap
- [Low] mtd: missing Return: section colon in mtd_alloc_buf() kernel-doc
- [Low] mtd: mtd_alloc_buf() skips mtd_kmalloc_up_to() on !CONFIG_MMU
kernels
--
commit efcdd59002b1c9f468f5f039f8a5c7ecd370e313
Author: Ping Li <leeonion.muyu@gmail.com>
mtd: core: add per-device bounce buffer allocation helper
This commit adds mtd->allows_vmalloc_bufs along with mtd_alloc_buf() and
mtd_free_buf() so drivers that can handle vmalloc'd buffers can opt into
kvmalloc() instead of mtd_kmalloc_up_to(). Partitions inherit the flag
from their parent.
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index b170c3144ca8f..a96eb69407758 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -2566,6 +2566,51 @@ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size)
> }
> EXPORT_SYMBOL_GPL(mtd_kmalloc_up_to);
>
> +/**
> + * mtd_alloc_buf - allocate a bounce buffer for an MTD device
[ ... ]
> + * Returns a pointer to the allocated buffer on success; otherwise, NULL.
> + */
[Severity: Low]
Should "Returns" be "Return:" with a colon? Without the colon,
scripts/kernel-doc -Wall (W=2 builds) does not recognize the return
section and warns that mtd_alloc_buf() has no return value description.
> +void *mtd_alloc_buf(const struct mtd_info *mtd, size_t *size)
> +{
> + if (!mtd->allows_vmalloc_bufs)
> + return mtd_kmalloc_up_to(mtd, size);
> +
> + *size = min_t(size_t, *size, KMALLOC_MAX_SIZE);
> + return kvmalloc(*size, GFP_KERNEL | __GFP_NORETRY);
> +}
[Severity: Low]
Should mtd_alloc_buf() also fall back to mtd_kmalloc_up_to() when
!IS_ENABLED(CONFIG_MMU)?
On !CONFIG_MMU kernels, __vmalloc_node_range_noprof() delegates to
kmalloc_noprof() with no non-contiguous fallback. For transfers larger
than PAGE_ALLOC_COSTLY_ORDER, __alloc_pages_slowpath() strips
__GFP_DIRECT_RECLAIM when __GFP_NORETRY is set.
As a result, kvmalloc() fails immediately under physical fragmentation
without reclaim, compaction, or shrinking, regressing transfers that
mtd_kmalloc_up_to() would have served by halving the buffer size.
[Severity: Medium]
Is KMALLOC_MAX_SIZE a safe upper bound for non-shrinking vmalloc bounce
buffers?
KMALLOC_MAX_SIZE scales with page size and ARCH_FORCE_MAX_ORDER: it is
4 MiB on 4K arm64, 32 MiB on ARM64_16K_PAGES, and 512 MiB on
ARM64_64K_PAGES. Unlike mtd_kmalloc_up_to(), mtd_alloc_buf() does not
halve the size on failure.
On an ARM64_64K_PAGES board with modest RAM (such as a 384 MiB R-Car D3
Draak with a 64 MiB RPC-IF HyperFlash), a large read or write can
request tens of MiB in a single unswappable vmalloc buffer, driving
heavy reclaim or failing with -ENOMEM where a 4K kernel succeeds.
Clamping *size to a fixed ceiling (or mtd->erasesize, as
mtdchar_write_ioctl() does) would keep bounce buffer sizes predictable
across page sizes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091640.444442-1-leeonion.muyu@gmail.com?part=1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-12-04 9:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:16 [PATCH v4 0/4] mtdchar: per-device bounce buffer policy Ping Li
2026-12-04 9:16 ` Ping Li
2026-12-04 9:16 ` [PATCH v4 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
2026-12-04 9:16 ` Ping Li
2026-12-04 9:39 ` sashiko-bot [this message]
2026-12-04 9:16 ` [PATCH v4 2/4] mtd: mtdchar: clamp bounce buffer size to the remaining transfer Ping Li
2026-12-04 9:16 ` Ping Li
2026-12-04 9:25 ` sashiko-bot
2026-12-04 9:16 ` [PATCH v4 3/4] mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers Ping Li
2026-12-04 9:16 ` Ping Li
2026-12-04 9:39 ` sashiko-bot
2026-12-04 9:16 ` [PATCH v4 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd " Ping Li
2026-12-04 9:16 ` Ping Li
2026-12-04 9:57 ` sashiko-bot
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=sashiko-outbox-249529@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=leeonion.muyu@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
/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.