|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 09/10] ring: Defer destruction until backend grant release
Some comments inline
> +static VOID
> +__BlkifRingFreePages(
> + _In_ PXENVBD_BLKIF_PAGES Pages
> + )
> +{
> + ULONG Index;
> +
> + for (Index = 0; Index < Pages->Count; ++Index)
> + ASSERT3P(Pages->Grants[Index], ==, NULL);
> +
This loop only matters on a checked build - it can be wrapped by
#if DBG / #endif
> + __FreePages(Pages->Mdl);
> + Pages->Mdl = NULL;
> + Pages->Count = 0;
> +
> + RtlZeroMemory(&Pages->ListEntry, sizeof(LIST_ENTRY));
> +
> + ASSERT(IsZeroMemory(Pages, sizeof(XENVBD_BLKIF_PAGES)));
> + __RingFree(Pages);
> +}
> +
> +_Check_return_
> +static BOOLEAN
> +__BlkifRingRevokePages(
> + _In_ PXENVBD_BLKIF_RING BlkifRing,
> + _Inout_ PXENVBD_BLKIF_PAGES Pages
> + )
> +{
> + PXENVBD_RING Ring = BlkifRing->Ring;
> + PXENVBD_GRANTER Granter =
> FrontendGetGranter(Ring->Frontend);
> + ULONG Index;
> +
> + for (Index = 0; Index < Pages->Count; ++Index) {
> + if (Pages->Grants[Index] == NULL)
> + continue;
> +
> + if (!NT_SUCCESS(GranterTryPut(Granter, Pages->Grants[Index])))
> + return FALSE;
> +
Should the loop flag the failure, and try other grants, so that the function
has released as many grants as possible, but reports if any fail?
> + Pages->Grants[Index] = NULL;
> + }
> +
> + return TRUE;
> +}
> +
> @@ -2615,9 +2865,32 @@ RingD0ToD3(
> _Inout_ PXENVBD_RING Ring
> )
> {
> - UNREFERENCED_PARAMETER(Ring);
> + ULONG Index;
>
> ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
> +
> + // Grants are only handed over to the reclaim thread at disconnect, so a
> + // ring still connected here would never be drained
> + for (Index = 0; Index < FrontendGetMaxQueues(Ring->Frontend); ++Index)
> + ASSERT(!Ring->Ring[Index]->Connected);
> +
Checked only loop, can be optimized with #if DBG / #endif
> + // Only return once the backend has released everything, so that no
> grant
> + // survives into D3. Freeing pages that backends may still access is
> worse
> + // than holding up D0->D3.
> + while (RingIsDeferring(Ring)) {
Owen
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |