CcPurgeCacheSection failure!

CcCoherencyFlushAndPurge wrapper fails when called over the VA range which is partially purged by the mapped page writer (MPW) to reduce memory pressure.

CcCoherencyFlushAndPurge internally calls:
* mmTrimSection: Invalidates PTEs.
* ccFlushCache: Flushes modified pages.
* ccPurgeCacheSection: Moves pages to the free list.

Details:

  1. FSD works on memory mapped files. Hence, it only handles paging I/O requests.
  2. CcCoherencyFlushAndPurge works fine as long as there is no intervention from MPW i.e. under zero memory pressure.
  3. Only CcPurgeCacheSection call within this wrapper fails. Other calls, MmTrimSection and CcFlushCache, always pass.
  4. We do exclusive locking on files for both MPW and CcCoherencyFlushAndPurge.

Observations:

  1. _CONTROL_AREA (data section) shows only ?one? mapped view and ?zero? system mapped view.
  2. No pending IRPs in the system when the failure occurs.
  3. PFN entries are getting unmapped by MmTrimSection before CcPurgeCacheSection is getting called.
  4. Memusage does not show any locked pages in the mapped area.

I am struggling with this issue for a long time. Any suggestions?

Thanks,
Prasad