|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 2/3] sync: Wait for interrupts to be disabled
Reviewed-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: 16 September 2026 1:35 PM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Tu Dinh
Subject: [PATCH v2 2/3] sync: Wait for interrupts to be disabled
Currently, SyncDisableInterrupts doesn't wait for _disable() to be
issued. So SuspendTrigger can issue a suspend before all CPUs have
actually reached a quiescent state.
In each worker, increment CompletionCount again after _disable(). Wait
for all sync workers to actually issue _disable() in
SyncDisableInterrupts by making sure that CompletionCount reaches 2x the
CPU count.
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
src/xenbus/sync.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c
index b416dbb..5111310 100644
--- a/src/xenbus/sync.c
+++ b/src/xenbus/sync.c
@@ -170,7 +170,7 @@ __SyncProcessorDisableInterrupts(
while (++Attempts <= 1000) {
KeMemoryBarrier();
- if (Context->CompletionCount == Context->ProcessorCount)
+ if (Context->CompletionCount >= Context->ProcessorCount)
break;
_mm_pause();
@@ -180,7 +180,7 @@ __SyncProcessorDisableInterrupts(
Old = Context->CompletionCount;
New = Old - 1;
- if (Old == Context->ProcessorCount)
+ if (Old >= Context->ProcessorCount)
break;
} while (InterlockedCompareExchange(&Context->CompletionCount, New, Old)
!= Old);
@@ -189,8 +189,10 @@ __SyncProcessorDisableInterrupts(
status = STATUS_UNSUCCESSFUL;
}
- if (NT_SUCCESS(status))
+ if (NT_SUCCESS(status)) {
_disable();
+ InterlockedIncrement(&Context->CompletionCount);
+ }
return status;
}
@@ -237,8 +239,8 @@ __SyncProcessorRunLate(
}
static FORCEINLINE VOID
-__SyncWait(
- VOID
+__SyncWaitTarget(
+ LONG Target
)
{
PSYNC_CONTEXT Context = &SyncContext;
@@ -246,13 +248,23 @@ __SyncWait(
for (;;) {
KeMemoryBarrier();
- if (Context->CompletionCount == Context->ProcessorCount)
+ if (Context->CompletionCount == Target)
break;
_mm_pause();
}
}
+static FORCEINLINE VOID
+__SyncWait(
+ VOID
+ )
+{
+ PSYNC_CONTEXT Context = &SyncContext;
+
+ __SyncWaitTarget(Context->ProcessorCount);
+}
+
_Use_decl_annotations_
VOID
SyncWorker(
@@ -418,8 +430,10 @@ SyncDisableInterrupts(
for (;;) {
status = __SyncProcessorDisableInterrupts(Irql);
_Analysis_assume_(NT_SUCCESS(status));
- if (NT_SUCCESS(status))
+ if (NT_SUCCESS(status)) {
+ __SyncWaitTarget(2 * Context->ProcessorCount);
return status;
+ }
LogPrintf(LOG_LEVEL_WARNING, "SYNC: RE-TRY\n");
}
--
2.55.0.windows.3
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |