From: sashiko-bot@kernel.org
To: "Liao Xuan" <liaoxuan@open-hieco.net>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-pci: Fix performance regression with completion batching for Hygon processors
Date: Tue, 03 Nov 2026 06:38:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-194649@kernel.org> (raw)
In-Reply-To: <20261103063249.3212198-1-liaoxuan@open-hieco.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] nvme-pci: write to __ro_after_init use_comp_batch in nvme_probe()
--
commit f5d6be55aa6c877692b8138ca3509c22f309ca86
Author: Liao Xuan <liaoxuan@open-hieco.net>
nvme-pci: Fix performance regression with completion batching for Hygon processors
This commit introduces a use_comp_batch flag in drivers/nvme/host/pci.c to
disable IRQ completion batching in nvme_irq() when running on Hygon x86
processors.
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 019a1e3cc0a2d..635755a886523 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -278,6 +278,15 @@ static bool noacpi;
> module_param(noacpi, bool, 0444);
> MODULE_PARM_DESC(noacpi, "disable acpi bios quirks");
>
> +static bool use_comp_batch __ro_after_init = true;
> +static void nvme_setup_comp_batch(void)
> +{
> +#ifdef CONFIG_X86
> + if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
> + use_comp_batch = false;
> +#endif
> +}
> +
> struct nvme_dev;
> struct nvme_queue;
>
[ ... ]
> @@ -4014,6 +4026,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>
> dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
>
> + nvme_setup_comp_batch();
[Severity: High]
Can calling nvme_setup_comp_batch() from nvme_probe() cause a page fault by
writing to read-only memory?
In drivers/nvme/host/pci.c, use_comp_batch is annotated with __ro_after_init,
which places it in the .data..ro_after_init section that becomes read-only
after kernel or module init finishes.
However, nvme_probe() can be invoked after init has completed, such as during
PCIe hotplug, SR-IOV VF creation, PCI bus rescan, sysfs driver bind, or
asynchronous probing (since nvme_driver sets PROBE_PREFER_ASYNCHRONOUS). When
that happens on a Hygon CPU, nvme_probe() -> nvme_setup_comp_batch() writes
to use_comp_batch after .data..ro_after_init has been marked read-only. In
addition, concurrent nvme_probe() calls can write to use_comp_batch while
already active controllers read it in nvme_irq().
Since boot_cpu_data.x86_vendor is a system-wide property, should
nvme_setup_comp_batch() be marked __init and called once from nvme_init()
before pci_register_driver(&nvme_driver) instead of inside nvme_probe()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103063249.3212198-1-liaoxuan@open-hieco.net?part=1
prev parent reply other threads:[~2026-11-03 6:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 6:32 [PATCH] nvme-pci: Fix performance regression with completion batching for Hygon processors Liao Xuan
2026-11-03 6:38 ` 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-194649@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=liaoxuan@open-hieco.net \
--cc=linux-nvme@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox