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 3/4] mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers
Date: Fri, 04 Dec 2026 09:39:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-249530@kernel.org> (raw)
In-Reply-To: <20261204091640.444442-4-leeonion.muyu@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mtd: mtdchar: mtd_alloc_buf() drops low-memory backoff and
warns on failure
- [Medium] mtd: mtdchar: mtd_alloc_buf() caps bounce buffer at
KMALLOC_MAX_SIZE
--
commit 9a4e811d7951c8dffd66c630d36a3b204c649eaf
Author: Ping Li <leeonion.muyu@gmail.com>
mtd: mtdchar: use mtd_alloc_buf() for the read/write bounce buffers
This commit switches mtdchar_read() and mtdchar_write() from
mtd_kmalloc_up_to()/kfree() to mtd_alloc_buf()/mtd_free_buf() and updates
the comment above mtdchar_read().
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 2b6e70864bfbb..047540e24b01c 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
[ ... ]
> @@ -149,7 +149,7 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
> return 0;
>
> size = count;
> - kbuf = mtd_kmalloc_up_to(mtd, &size);
> + kbuf = mtd_alloc_buf(mtd, &size);
> if (!kbuf)
> return -ENOMEM;
[Severity: Medium]
Can switching mtdchar_read() and mtdchar_write() to mtd_alloc_buf()
regress read() and write() under memory pressure for drivers with
allows_vmalloc_bufs set?
Unlike mtd_kmalloc_up_to(), mtd_alloc_buf() makes a single
kvmalloc(*size, GFP_KERNEL | __GFP_NORETRY) call without size backoff.
In memalloc_apply_gfp_scope(), __GFP_NORETRY disables reclaim for vmalloc
page tables, causing -ENOMEM even under moderate memory pressure.
Because mtd_alloc_buf() omits __GFP_NOWARN, those failures also emit
warn_alloc() stack traces to dmesg from ordinary userspace I/O. Falling
back to smaller chunks with __GFP_NOWARN on large attempts would keep
low-memory transfers working cleanly.
[Severity: Medium]
Is KMALLOC_MAX_SIZE an appropriate upper bound for the bounce buffer
allocated here and in mtdchar_write()?
mtd_alloc_buf() clamps *size to KMALLOC_MAX_SIZE, which scales with page
size and ARCH_FORCE_MAX_ORDER: on arm64 with 16 KiB or 64 KiB pages, it
reaches 32 MiB or 512 MiB.
A full-device or full-partition read()/write() on a 64 MiB flash then
requests 32 MiB to 64 MiB of vmalloc memory in one shot, increasing vmap
overhead and __GFP_NORETRY allocation failures. A fixed ceiling (such as
mtd->erasesize, as in mtdchar_read_ioctl()) would avoid this scaling.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091640.444442-1-leeonion.muyu@gmail.com?part=3
______________________________________________________
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: 9+ 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 ` [PATCH v4 1/4] mtd: core: add per-device bounce buffer allocation helper Ping Li
2026-12-04 9:39 ` sashiko-bot
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: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:39 ` sashiko-bot [this message]
2026-12-04 9:16 ` [PATCH v4 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd " 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-249530@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox