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

Re: [PATCH] Revert to KeMemoryBarrier() as poll loop barriers


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Fri, 5 Jun 2026 06:32:01 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MqjhhnjqyBc3yGD62fLiIRsATkXowkrlVly0EoTc9nw=; b=jhUhTSM1JSV3sOA2lsYpfa0DYYllNQ5wV7A2FGTgvjIxnJm7vyCU5kEI0iddG9HLnq0lGEKd3DGUDb2wAauUgqcn0QEywAwSmcHz9R/Etii/+PiOh5gYT4+yMP9E/zeX8LvhXwXtK7W74LMAMw/ad6pGo6U4/qI95Yi9bk+mYGc7rxFM0EYRIllhryf+3CdDnfaEe4fUESIxKpHq1g1IThu1S1Sec3mvHcmL1M5qNlC2UFVhhhLQNq10dPposA8qWVH2H3wdkbHNBACv7wpSHDuYnUQW60H9aSNxAM/FCYsl5gJlJ8vr2qL4+6S02TCAtm2n7yVULk7ejcD4wXjthA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jNEG2gomHrL/34+V2QYNTiNm8N8oCrlt5ugdRbHaQ361yJQKcbfSVVBqkOJ6mYpDOcMYLs3eKKf8SgCVEmtZnUhZrw/C8DAYwjRP87KqFzBXiVj8yypItlSw/oFjeAZnksXQCE17485xWQvENG6DLsxV58EA61ObFRBmqGbac6w5aq9vcCIyqiRlapkizNLlEdA98Qieo4mx7zPpAOlttSepAACV4S/cbFZGs1d9Z8dAzyRq570Nizx1aswcN3aU5pOvpsNzcoEbzp6SYxZD9Lv1Q2IwZG8Dhf+sRNHzRO0B8Hr3I9D1cIDdrMnW/BQ7NTkxQRtqzb+Hq+mZF3Ur6Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Fri, 05 Jun 2026 06:32:09 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHc8Z7zgLP9fWioQECneGG7FKeJt7YvhhYV
  • Thread-topic: [PATCH] Revert to KeMemoryBarrier() as poll loop barriers

Reveiwed-by: Owen Smith <owen.smith@xxxxxxxxxx>

________________________________________
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of Tu 
Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 01 June 2026 9:15 AM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Tu Dinh
Subject: [PATCH] Revert to KeMemoryBarrier() as poll loop barriers

312f9fa760bf ("ring: Weaken and delete unnecessary barriers") attempted
to replace barriers in BlkifRingPoll with their xen_mb/rmb/wmb
equivalents. Part of this involved replacing the full barrier at the end
of each poll loop with a "release barrier" consisting of xen_rmb +
xen_wmb.

This is fine on x86 since each store has release ordering. However, this
is incorrect in the Linux memory model, as rmb/wmb (and their smp_
equivalents) did not guarantee relative ordering of loads and subsequent
stores, unlike a release operation. Therefore, without specializing for
each architecture, a release barrier in this model would require a full
memory barrier (i.e. mb()).

Inconveniently, WDK doesn't provide a release barrier nor a release
store. I couldn't measure a performance difference from 312f9fa760bf in
my limited testing, so revert the change.

Fixes: 312f9fa760bf ("ring: Weaken and delete unnecessary barriers")
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenvbd/ring.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 10ca6ee..d05dfc3 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1228,7 +1228,7 @@ BlkifRingPoll(
         RING_IDX            rsp_prod;
         RING_IDX            rsp_cons;

-        xen_mb();
+        KeMemoryBarrier();

         rsp_prod = BlkifRing->Shared->rsp_prod;
         rsp_cons = BlkifRing->Front.rsp_cons;
@@ -1236,7 +1236,7 @@ BlkifRingPoll(
         if (rsp_cons == rsp_prod || Retry)
             break;

-        xen_rmb();
+        KeMemoryBarrier();

         while (rsp_cons != rsp_prod && !Retry) {
             blkif_response_t    *rsp;
@@ -1260,8 +1260,7 @@ BlkifRingPoll(
                 Retry = TRUE;
         }

-        xen_rmb();
-        xen_wmb();
+        KeMemoryBarrier();

         BlkifRing->Front.rsp_cons = rsp_cons;
         BlkifRing->Shared->rsp_event = rsp_cons + 1;
--
2.54.0.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

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