Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anlai Lu" <agicy@qq.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>,
	virtualization@lists.linux.dev
Subject: Re: [PATCH v2 6/6] iommu/virtio: batch the mapping replay on domain attach
Date: Sun, 04 Oct 2026 13:08:34 +0000	[thread overview]
Message-ID: <20261004130834.70BB81F00893@smtp.kernel.org> (raw)
In-Reply-To: <tencent_7A12897B7DF3E958E903DD2A4557A8F6BC05@qq.com>

> viommu_replay_mappings() sent every mapping of a domain to the device
> with a synchronous request, holding mappings_lock - and with it
> interrupts - across the whole walk, so the IRQ-off window grew with the
> number of mappings: 233 ms for 8192 4K mappings, 29 s for a million.
> 
> Queue them instead and wait once. One mapping per mappings_lock section,
> so that a full virtqueue - the only wait in there - bounds a single lock
> hold rather than the whole walk; the walk is a single pass, because the
> endpoint was published before it (a mapping inserted while it runs is
> queued by map_pages() itself) and a mapping removed meanwhile has its
> UNMAP queued in the section that removed it. The requests carry the
> device's errno back - the first error it reported - so a rejected replay
> fails the attach with the device's own status, and a device that goes
> away fails it with -ENODEV rather than reporting a replay that never
> happened; a duplicate MAP, which a replay can legitimately produce, is
> answered S_INVAL - the spec says a duplicate MAP SHOULD be rejected and
> MUST NOT change the existing mapping - and is not treated as a rejection.
> A rejected MAP on the map path is still ignored, as before.
> 
> Measured, N=8192 4K mappings: max IRQ-off window 233.7 ms -> 1.4-2.5 ms,
> and no longer growing with N (1.4-2.5 ms from N=64 to 32768, against
> 3.6/45/233 ms on the unpatched driver); attach ioctl 218.9/249.0 ->
> 50.3/48.8 ms (48-67 ms across runs); viommu_send_req_sync() calls 8193 ->
> 1; the device receives exactly the same MAPs (8244).
> 
> Signed-off-by: Anlai Lu <agicy@qq.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_D757B544955DDC509B5DC7161F425620BA08@qq.com?part=6


      reply	other threads:[~2026-10-04 13:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 12:59 [PATCH v2 0/6] iommu/virtio: batch the mapping replay Anlai Lu
2026-10-04 13:01 ` [PATCH v2 1/6] iommu/virtio: publish the endpoint before replaying it Anlai Lu
2026-10-04 13:09   ` sashiko-bot
2026-10-04 13:01 ` [PATCH v2 2/6] iommu/virtio: queue an UNMAP for every removed mapping Anlai Lu
2026-10-04 13:15   ` sashiko-bot
2026-10-04 13:01 ` [PATCH v2 3/6] iommu/virtio: allocate the UNMAP request with the mapping Anlai Lu
2026-10-04 13:09   ` sashiko-bot
2026-10-04 13:01 ` [PATCH v2 4/6] iommu/virtio: stop queueing and draining once the device is removed Anlai Lu
2026-10-04 13:11   ` sashiko-bot
2026-10-04 13:01 ` [PATCH v2 5/6] iommu/virtio: read the endpoint count under the lock in the iotlb paths Anlai Lu
2026-10-04 13:08   ` sashiko-bot
2026-10-04 13:01 ` [PATCH v2 6/6] iommu/virtio: batch the mapping replay on domain attach Anlai Lu
2026-10-04 13:08   ` 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=20261004130834.70BB81F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agicy@qq.com \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@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