[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 0/2] xenbus: Batch foreign page mappings


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Rafał Wojdyła <omeg@xxxxxxxxxxxxxxxxxxxxxx>
  • Date: Tue, 10 Nov 2026 18:31:40 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=fm3 header.d=invisiblethingslab.com header.i="@invisiblethingslab.com" header.h="Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=fm3 header.d=messagingengine.com header.i="@messagingengine.com" header.h="Content-Transfer-Encoding:Content-Type:Date:Feedback-ID:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To:X-ME-Proxy:X-ME-Sender"
  • Delivery-date: Tue, 10 Nov 2026 17:31:47 +0000
  • Dkim2-signature: i=1; m=1; t=1794331903; d=invisiblethingslab.com; mf=PG9tZWdAaW52aXNpYmxldGhpbmdzbGFiLmNvbT4=; rt=PHdpbi1wdi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZz4=; s=fm3:rsa-sha256:Ql6U05nvTVDHV90LeSYUZ0gZgay9+hrz4f04w+tqc7aMeTk tXmmeFO39OO08y3ycnO6OeME9PIG090uxgISBJSU4psBZ8Yx91jc9iOgLCWm7Gdp 8BX+KkqXPGTXiVZZEqUeCIHZyvFritOG9vOTgN4D8pehlVPR7fYBaGJDyBpHKoa2 YiYMH1SW51sjmWzXhFbRrRsZK9TNLt7Vb0LdXs9OyxTDSV/U7seiWYawJt5gaXj1 2dvk3cRtunt87MbWDFDwknEvid/CKZyvFeAa58SEi0t1KwXLvTRit5SG+VCrgyoL IkJoeuQNiq3qhsA5L+cqkyw1KxuWcPQZJq7KjWQ==;
  • Feedback-id: i409c4082:Fastmail
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Message-instance: m=1; h=sha256:bkcWsBd51d5MHrExc9gAF+XZNQ3oUFKsIFsxRm9B/f8=:sQO6Z40pSoKyr3CiZVFSOfHzmLnQ5qsrShuh8HesmBQ=;

On 10.11.2026 18:19, Tu Dinh wrote:
On 10/11/2026 17:58, Rafał Wojdyła wrote:
This series changes the foreign page map APIs to use batched hypercalls
when possible. One batch is limited to 256 pages.

A new xenbus gnttab interface version is added, with changed behavior:
* Per-page status reported.
* Callers are responsible for managing page lifecycle.
* No automatic rollback on page-level failures.

The new mapping lifecycle is:
* Create the mapping with GNTTAB_CREATE_MAPPING.
* Map foreign pages with (potentially multiple calls of)
    GNTTAB_MAP_FOREIGN_PAGES_V2.
* Obtain the region address using GNTTAB_GET_MAPPING_ADDRESS after
    all pages are populated.
* Unmap all the pages using GNTTAB_UNMAP_FOREIGN_PAGES_V2.
* Destroy the mapping using GNTTAB_DESTROY_MAPPING.

Partially failed map batches can be retried with the unsuccessful pages.
Partially failed unmap batches can be retried unchanged (already unmapped
pages are treated as success).

Legacy (v4) interface is preserved functionally unchanged.

A companion xeniface series contains changes to the user-space IOCTLs
and internal bookkeeping, as well as simplified wrappers for one-shot
map calls.

All hypercall-level failures are fatal because they signify either
a corrupted runtime environment or unknown memory state (see
GrantTableMapForeignPages() in xen/grant_table.c).

I'm aware that there is a separate patch adding a v5 interface, we can
either apply one after another or merge the changes since they touch
separate parts of the gnttab interface.
I hope we can add a GNTTAB v6 for this because we've had to ship GNTTAB
v5 on our side to fix the disk corruption issue.

That shouldn't be a problem, this is still not deployed on our side (went through a lot of testing though). I measured 2x vchan speedups with 32-page batches and 5x speedups with 256+ pages.

I also noticed that this could be improved by providing a single-page fallback on unmap if pool allocation fails, I'll send a v2.

I've iterated a lot on the xeniface part but I'll send what I have now. I'll be on vacation for two weeks and it's quite a bit of code, so there will be some time for review. My main point of uncertainty is what to do if repeated unmap retries still fail. I'm partial to treating that as a fatal failure because we can't really do much there: we could quarantine the memory, but the peer would still have pending pages, and we can't just defer infinitely.

--

Rafał Wojdyła
Invisible Things Lab



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.