mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Fengnan Chang <changfengnan@bytedance.com>
Cc: linux-nvme@lists.infradead.org, Keith Busch <kbusch@kernel.org>,
	Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>,
	Bart Van Assche <bvanassche@acm.org>,
	Thomas Gleixner <tglx@kernel.org>, Jun Zeng <jun1.zeng@intel.com>,
	Gang Cao <gang.cao@intel.com>, Jun I Jin <jun.i.jin@intel.com>,
	Liang A Fang <liang.a.fang@intel.com>,
	Yong Hu <yong.hu@intel.com>,
	linux-kernel@vger.kernel.org, Guzebing <guzebing@bytedance.com>
Subject: Re: [RFC PATCH] nvme-pci: adaptively poll completions on busy queues
Date: Fri, 7 Aug 2026 00:18:16 +0300	[thread overview]
Message-ID: <anT6GLUy_o12Fiz4@ashevche-desk.local> (raw)
In-Reply-To: <20260723120556.58670-1-changfengnan@bytedance.com>

On Thu, Jul 23, 2026 at 08:05:56PM +0800, Fengnan Chang wrote:
> In high-IOPS scenarios, relying on interrupts to handle I/O operations
> can limit performance. This issue becomes particularly pronounced in
> multi-disk environments, where performance is constrained by the CPU’s
> interrupt-handling capacity.
> 
> Each Solidigm SB5PH27X038T device used for testing can deliver about 3.2M
> 4 KiB random-read IOPS.  Four devices therefore have about 12.8M IOPS of
> aggregate capability, but interrupt-driven completion topped out at 7.81M
> IOPS, or about 61% of that capability.
> 
> Add optional adaptive polling for busy interrupt-driven I/O queues.  After
> an interrupt drains the CQ, use the ring distance between last_sq_tail and
> cq_head as an approximate host-side inflight count.  If the count reaches
> a per-controller high watermark, let the threaded handler keep draining
> completions instead of returning to interrupt-driven completion right away.
> 
> The thread always checks for pending CQEs first.  When the CQ is empty, it
> compares the inflight count with a per-controller low watermark and sleeps
> for a configurable interval before checking again.  It returns to
> interrupt-driven completion after three consecutive empty-CQ checks below
> the low watermark or when the loop limit is reached.
> 
> The mode is disabled by default. It can be enabled at module load time.
> The high and low watermarks, empty-CQ interval, and loop limit are
> available through sysfs.  The defaults are 32 commands, 3 commands,
> 30 us, and 1000 iterations.
> 
> Tested with the default settings and 4 KiB random reads on four Solidigm
> SB5PH27X038T devices.  With adaptive polling off and on:
> 
>   - t/io_uring, depth 1024 and four workers per device:
>     7.810M and 12.780M aggregate IOPS (+63.64%).
>   - fio/libaio, iodepth 1024, numjobs 4 and completion batches of 32:
>     7.699M and 12.785M aggregate IOPS (+66.05%).
> 
> In a paired libaio and io_uring boundary sweep, QD8, QD16, QD32, and
> QD16/numjobs=4 changed by -0.15% to +0.48%.  QD64 improved by 28.61% to
> 59.75%.

...

> +What:		/sys/class/nvme/nvmeX/adaptive_poll_inflight_high
> +Date:		July 2026

Can't be July for v7.3. See crystal ball predictor for the dates (rc1 or release).

> +KernelVersion:	7.3

...

> +static void nvme_adaptive_unmask_irq(struct nvme_queue *nvmeq, int irq)
> +{
> +	struct nvme_dev *dev = nvmeq->dev;
> +	struct pci_dev *pdev = to_pci_dev(dev->dev);
> +
> +	clear_bit(NVMEQ_ADAPTIVE_POLLING, &nvmeq->flags);


> +	if (pdev->msi_enabled) {

Wondering if MSI-X also should be considered here.
With that in mind, can we use pci_dev_msi_enabled()?

> +		writel(BIT(nvmeq->cq_vector), dev->bar + NVME_REG_INTMC);
> +		readl(dev->bar + NVME_REG_INTMS);
> +	} else {
> +		enable_irq(irq);
> +	}
> +}

...

> +static ssize_t adaptive_poll_interval_us_store(struct device *dev,
> +					       struct device_attribute *attr,
> +					       const char *buf, size_t count)
> +{
> +	struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
> +	unsigned int value;
> +	int ret;
> +
> +	ret = kstrtouint(buf, 10, &value);
> +	if (ret)
> +		return ret;
> +	if (!value)
> +		return -EINVAL;

ERANGE? EDOM?

Ditto for other similar cases.

> +	WRITE_ONCE(ndev->adaptive_poll_interval_us, value);
> +	return count;
> +}

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2026-08-06 21:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 12:05 Fengnan Chang
2026-07-23 12:14 ` changfengnan
2026-07-23 14:46 ` Keith Busch
2026-07-28  2:24 ` changfengnan
2026-07-28  4:44   ` Christoph Hellwig
2026-07-28  6:19     ` changfengnan
2026-08-06  3:12       ` changfengnan
2026-08-06 21:18 ` Andy Shevchenko [this message]
2026-08-07  2:18   ` changfengnan

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=anT6GLUy_o12Fiz4@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=changfengnan@bytedance.com \
    --cc=gang.cao@intel.com \
    --cc=guzebing@bytedance.com \
    --cc=hch@lst.de \
    --cc=jun.i.jin@intel.com \
    --cc=jun1.zeng@intel.com \
    --cc=kbusch@kernel.org \
    --cc=liang.a.fang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=tglx@kernel.org \
    --cc=yong.hu@intel.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

all inboxes | Powered by JetHome®