[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] Avoid unnecessary check for non-NULL Processor->Interrupt in EvtchnRelease()
From: Paul Durrant <pdurrant@xxxxxxxxxx> If EvtchnIsProcessorEnabled() is TRUE then Processor->Interrupt should be valid. Hence use an ASSERTion instead. Also replicate the check of EvtchnIsProcessorEnabled() in the error path in EvtchnAcquire(). While we're at it, let's also use EvtchnIsProcessorEnabled() in EvtchnInterruptEnable() and EvtchnInterruptDisable(). Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx> --- src/xenbus/evtchn.c | 64 +++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c index 9f7026db8dde..123f4a3a75e5 100644 --- a/src/xenbus/evtchn.c +++ b/src/xenbus/evtchn.c @@ -1271,6 +1271,22 @@ EvtchnAbiRelease( RtlZeroMemory(&Context->EvtchnAbi, sizeof (XENBUS_EVTCHN_ABI)); } +static BOOLEAN +EvtchnIsProcessorEnabled( + IN PXENBUS_EVTCHN_CONTEXT Context, + IN ULONG Cpu + ) +{ + if (!XENBUS_SHARED_INFO(UpcallSupported, + &Context->SharedInfoInterface, + Cpu)) + return FALSE; + + return XENBUS_EVTCHN_ABI(IsProcessorEnabled, + &Context->EvtchnAbi, + Cpu); +} + static VOID EvtchnInterruptEnable( IN PXENBUS_EVTCHN_CONTEXT Context @@ -1297,15 +1313,15 @@ EvtchnInterruptEnable( Processor = &Context->Processor[Cpu]; - if (Processor->Interrupt == NULL) - continue; - - status = SystemProcessorVcpuId(Cpu, &vcpu_id); - if (!NT_SUCCESS(status)) + if (!EvtchnIsProcessorEnabled(Context, Cpu)) continue; + ASSERT(Processor->Interrupt != NULL); Vector = FdoGetInterruptVector(Context->Fdo, Processor->Interrupt); + status = SystemProcessorVcpuId(Cpu, &vcpu_id); + ASSERT(NT_SUCCESS(status)); + status = HvmSetEvtchnUpcallVector(vcpu_id, Vector); if (!NT_SUCCESS(status)) { if (status != STATUS_NOT_IMPLEMENTED ) @@ -1368,9 +1384,10 @@ EvtchnInterruptDisable( if (!Processor->UpcallEnabled) continue; + ASSERT(EvtchnIsProcessorEnabled(Context, Cpu)); + status = SystemProcessorVcpuId(Cpu, &vcpu_id); - if (!NT_SUCCESS(status)) - continue; + ASSERT(NT_SUCCESS(status)); (VOID) HvmSetEvtchnUpcallVector(vcpu_id, 0); Processor->UpcallEnabled = FALSE; @@ -1517,22 +1534,6 @@ EvtchnDebugCallback( } } -static BOOLEAN -EvtchnIsProcessorEnabled( - IN PXENBUS_EVTCHN_CONTEXT Context, - IN ULONG Cpu - ) -{ - if (!XENBUS_SHARED_INFO(UpcallSupported, - &Context->SharedInfoInterface, - Cpu)) - return FALSE; - - return XENBUS_EVTCHN_ABI(IsProcessorEnabled, - &Context->EvtchnAbi, - Cpu); -} - static NTSTATUS EvtchnAcquire( IN PINTERFACE Interface @@ -1657,16 +1658,18 @@ fail9: for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) { PXENBUS_EVTCHN_PROCESSOR Processor; + if (!EvtchnIsProcessorEnabled(Context, Cpu)) + continue; + ASSERT(Context->Processor != NULL); Processor = &Context->Processor[Cpu]; RtlZeroMemory(&Processor->Dpc, sizeof (KDPC)); RtlZeroMemory(&Processor->PendingList, sizeof (LIST_ENTRY)); - if (Processor->Interrupt != NULL) { - FdoFreeInterrupt(Fdo, Processor->Interrupt); - Processor->Interrupt = NULL; - } + ASSERT(Processor->Interrupt != NULL); + FdoFreeInterrupt(Fdo, Processor->Interrupt); + Processor->Interrupt = NULL; Processor->Cpu = 0; Processor->Context = NULL; @@ -1765,10 +1768,9 @@ EvtchnRelease( RtlZeroMemory(&Processor->Dpc, sizeof (KDPC)); RtlZeroMemory(&Processor->PendingList, sizeof (LIST_ENTRY)); - if (Processor->Interrupt != NULL) { - FdoFreeInterrupt(Fdo, Processor->Interrupt); - Processor->Interrupt = NULL; - } + ASSERT(Processor->Interrupt != NULL); + FdoFreeInterrupt(Fdo, Processor->Interrupt); + Processor->Interrupt = NULL; Processor->Cpu = 0; Processor->Context = NULL; -- 2.25.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |