Integrate september's speed improvements, which now work.
Remove the flush hack when unpinning cache segments.

svn path=/trunk/; revision=55839
This commit is contained in:
Art Yerkes 2012-02-24 11:33:23 +00:00
parent e81ed04aa0
commit b10383d1ff
4 changed files with 26 additions and 27 deletions

View file

@ -130,6 +130,14 @@ VOID CcpDereferenceCache(ULONG Start, BOOLEAN Immediate)
DPRINT("Firing work item for %x\n", Bcb->BaseAddress);
if (Dirty) {
CcpUnlock();
Bcb->RefCount++;
MiFlushMappedSection(ToUnmap, &BaseOffset, &MappedSize, Dirty);
Bcb->RefCount--;
CcpLock();
}
if (Immediate)
{
PROS_SECTION_OBJECT ToDeref = Bcb->SectionObject;
@ -143,8 +151,6 @@ VOID CcpDereferenceCache(ULONG Start, BOOLEAN Immediate)
RemoveEntryList(&Bcb->ThisFileList);
CcpUnlock();
if (Dirty)
MiFlushMappedSection(ToUnmap, &BaseOffset, &MappedSize, Dirty);
MmUnmapCacheViewInSystemSpace(ToUnmap);
ObDereferenceObject(ToDeref);
CcpLock();
@ -763,7 +769,6 @@ CcUnpinData(IN PVOID Bcb)
CcpUnlock();
if (!Released) {
MiFlushMappedSection(RealBcb->BaseAddress, &RealBcb->FileOffset, &RealBcb->Map->FileSizes.FileSize, RealBcb->Dirty);
CcpLock();
CcpUnpinData(RealBcb, TRUE);
CcpUnlock();

View file

@ -259,6 +259,7 @@ _MiFlushMappedSection
if (NT_SUCCESS(Status)) {
MmLockAddressSpace(AddressSpace);
MmSetCleanAllRmaps(Page);
MmSetPageProtect(MmGetAddressSpaceOwner(AddressSpace), (PVOID)PageAddress, PAGE_READONLY);
MmLockSectionSegment(Segment);
Entry = MmGetPageEntrySectionSegment(Segment, &FileOffset);
if (Entry && !IS_SWAP_FROM_SSE(Entry) && PFN_FROM_SSE(Entry) == Page)
@ -663,6 +664,11 @@ MmFreeCacheSectionPage
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
if (Page != 0 && PFN_FROM_SSE(Entry) == Page && Dirty)
{
DPRINT("Freeing section page %x:%x -> %x\n", Segment, Offset.LowPart, Entry);
MmSetPageEntrySectionSegment(Segment, &Offset, DIRTY_SSE(Entry));
}
if (Page)
{
DPRINT("Removing page %x:%x -> %x\n", Segment, Offset.LowPart, Entry);
@ -671,12 +677,7 @@ MmFreeCacheSectionPage
MmDeleteVirtualMapping(Process, Address, FALSE, NULL, NULL);
MmReleasePageMemoryConsumer(MC_CACHE, Page);
}
if (Page != 0 && PFN_FROM_SSE(Entry) == Page && Dirty)
{
DPRINT("Freeing section page %x:%x -> %x\n", Segment, Offset.LowPart, Entry);
MmSetPageEntrySectionSegment(Segment, &Offset, DIRTY_SSE(Entry));
}
else if (SwapEntry != 0)
if (SwapEntry != 0)
{
MmFreeSwapPage(SwapEntry);
}

View file

@ -296,6 +296,7 @@ MiCowCacheSectionPage
MmSetPageEntrySectionSegment(Segment, &Offset, DIRTY_SSE(Entry));
}
MmSetPageProtect(Process, PAddress, PAGE_READWRITE);
MmSetDirtyPage(Process, PAddress);
MmUnlockSectionSegment(Segment);
DPRINT("Done\n");
return STATUS_SUCCESS;

View file

@ -184,11 +184,12 @@ MmPageOutCacheSection
(PMMSUPPORT AddressSpace,
MEMORY_AREA* MemoryArea,
PVOID Address,
BOOLEAN Dirty,
PMM_REQUIRED_RESOURCES Required)
{
NTSTATUS Status = STATUS_SUCCESS;
ULONG Entry;
BOOLEAN Dirty = FALSE;
PFN_NUMBER OurPage;
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
LARGE_INTEGER TotalOffset;
PMM_SECTION_SEGMENT Segment;
@ -202,25 +203,17 @@ MmPageOutCacheSection
MmLockSectionSegment(Segment);
ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
Dirty = MmIsDirtyPageRmap(Required->Page[0]);
Entry = MmGetPageEntrySectionSegment(Segment, &TotalOffset);
if (Dirty)
{
PFN_NUMBER OurPage;
if (Dirty) {
DPRINT("Dirty page: %p:%p segment %p offset %08x%08x\n", Process, Address, Segment, TotalOffset.HighPart, TotalOffset.LowPart);
MmSetPageEntrySectionSegment(Segment, &TotalOffset, DIRTY_SSE(Entry));
MmDeleteRmap(Required->Page[0], Process, Address);
MmDeleteVirtualMapping(Process, Address, FALSE, &Dirty, &OurPage);
ASSERT(OurPage == Required->Page[0]);
} else {
/* Just unmap if the page wasn't dirty */
PFN_NUMBER OurPage;
MmDeleteRmap(Required->Page[0], Process, Address);
MmDeleteVirtualMapping(Process, Address, FALSE, &Dirty, &OurPage);
DPRINT("OurPage %x ThePage %x\n", OurPage, Required->Page[0]);
ASSERT(OurPage == Required->Page[0]);
}
MmDeleteRmap(Required->Page[0], Process, Address);
MmDeleteVirtualMapping(Process, Address, FALSE, NULL, &OurPage);
ASSERT(OurPage == Required->Page[0]);
if (NT_SUCCESS(Status))
{
MmDereferencePage(Required->Page[0]);
@ -368,7 +361,7 @@ MmpPageOutPhysicalAddress(PFN_NUMBER Page)
DPRINT("%x:%x, page %x %x\n", Process, Address, Page, Resources.Page[0]);
Status = MmPageOutCacheSection
(AddressSpace, MemoryArea, Address, &Resources);
(AddressSpace, MemoryArea, Address, Dirty, &Resources);
DPRINT("%x\n", Status);
ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
@ -398,7 +391,6 @@ MmpPageOutPhysicalAddress(PFN_NUMBER Page)
MmLockAddressSpace(AddressSpace);
}
while (Status == STATUS_MM_RESTART_OPERATION);
Dirty |= Resources.State & 1; // Accumulate dirty
MmUnlockAddressSpace(AddressSpace);