All of lore.kernel.org
 help / color / mirror / Atom feed
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 4/4] mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers
Date: Fri, 04 Dec 2026 09:57:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-249551@kernel.org> (raw)
In-Reply-To: <20261204091640.444442-5-leeonion.muyu@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mtd: rpc-if: allows_vmalloc_bufs drops size fallback and adds
  __GFP_NORETRY
--

commit 3478fa469db25de80edd29b0bbcd17ad07a31745
Author: Ping Li <leeonion.muyu@gmail.com>

mtd: hyperbus: rpc-if: accept vmalloc'd bounce buffers

This commit adds an allows_vmalloc_bufs flag to struct hyperbus_device,
copies it to the MTD device before registration, and enables it for the
Renesas RPC-IF HyperBus driver.

> diff --git a/drivers/mtd/hyperbus/rpc-if.c b/drivers/mtd/hyperbus/rpc-if.c
> index 9eacc9ec7382d..dc172709d1267 100644
> --- a/drivers/mtd/hyperbus/rpc-if.c
> +++ b/drivers/mtd/hyperbus/rpc-if.c
> @@ -142,6 +142,7 @@ static int rpcif_hb_probe(struct platform_device *pdev)
>  	hyperbus->ctlr.dev = dev;
>  	hyperbus->ctlr.ops = &rpcif_hb_ops;
>  	hyperbus->hbdev.ctlr = &hyperbus->ctlr;
> +	hyperbus->hbdev.allows_vmalloc_bufs = true;
>  	hyperbus->hbdev.np = of_get_next_child(pdev->dev.parent->of_node, NULL);
>  	error = hyperbus_register_device(&hyperbus->hbdev);
>  	if (error)

[Severity: Medium]
Can enabling allows_vmalloc_bufs cause rpc-if read() and write() calls on
/dev/mtdX to regress to -ENOMEM under memory pressure?

Previously, mtdchar_read() and mtdchar_write() allocated bounce buffers via
mtd_kmalloc_up_to(), which halved requests under fragmentation and used plain
GFP_KERNEL for the final allocation and all requests of PAGE_SIZE or less.
With allows_vmalloc_bufs set, mtd_alloc_buf() skips that fallback:

drivers/mtd/mtdcore.c:mtd_alloc_buf() {
	...
	*size = min_t(size_t, *size, KMALLOC_MAX_SIZE);
	return kvmalloc(*size, GFP_KERNEL | __GFP_NORETRY);
}

For transfers of PAGE_SIZE or less, __kvmalloc_node_noprof() keeps
__GFP_NORETRY intact and returns NULL without attempting vmalloc.
__alloc_pages_slowpath() then gives up after a single direct reclaim pass, so
small transfers get no vmalloc benefit but can fail where GFP_KERNEL retried.

For larger transfers, __GFP_NORETRY makes vmalloc's
memalloc_apply_gfp_scope() apply memalloc_noreclaim_save() to page-table
allocations, so they can fail under moderate memory pressure.  Without
chunked fallback, large rpc-if transfers can now return -ENOMEM.

Should mtd_alloc_buf() drop __GFP_NORETRY for PAGE_SIZE or smaller requests,
or fall back to mtd_kmalloc_up_to() when vmalloc fails?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091640.444442-1-leeonion.muyu@gmail.com?part=4

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2026-12-04  9:57 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
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 [this message]

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-249551@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.