mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NTOS:MM] Simplify refcounting when adding/deleting a page in a shared segment
CORE-17544
This commit is contained in:
parent
bec42b6530
commit
b3e9c89725
2 changed files with 11 additions and 5 deletions
13
ntoskrnl/cache/section/sptab.c
vendored
13
ntoskrnl/cache/section/sptab.c
vendored
|
@ -204,6 +204,16 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
|||
OldEntry,
|
||||
Entry);
|
||||
|
||||
/* Manage ref on segment */
|
||||
if (Entry && !OldEntry)
|
||||
{
|
||||
InterlockedIncrement64(Segment->ReferenceCount);
|
||||
}
|
||||
if (OldEntry && !Entry)
|
||||
{
|
||||
MmDereferenceSegment(Segment);
|
||||
}
|
||||
|
||||
if (Entry && !IS_SWAP_FROM_SSE(Entry))
|
||||
{
|
||||
/* We have a valid entry. See if we must do something */
|
||||
|
@ -223,7 +233,6 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
|||
* Add the Rmap and take a ref on the segment.
|
||||
*/
|
||||
MmSetSectionAssociation(PFN_FROM_SSE(Entry), Segment, Offset);
|
||||
InterlockedIncrement64(Segment->ReferenceCount);
|
||||
|
||||
if (Offset->QuadPart >= (Segment->LastPage << PAGE_SHIFT))
|
||||
Segment->LastPage = (Offset->QuadPart >> PAGE_SHIFT) + 1;
|
||||
|
@ -233,7 +242,6 @@ _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
|
|||
{
|
||||
/* We're switching to an invalid entry from a valid one */
|
||||
MmDeleteSectionAssociation(PFN_FROM_SSE(OldEntry));
|
||||
MmDereferenceSegment(Segment);
|
||||
|
||||
if (Offset->QuadPart == ((Segment->LastPage - 1ULL) << PAGE_SHIFT))
|
||||
{
|
||||
|
@ -363,6 +371,7 @@ MmGetSectionAssociation(PFN_NUMBER Page,
|
|||
Offset->QuadPart = PageTable->FileOffset.QuadPart +
|
||||
((ULONG64)RawOffset << PAGE_SHIFT);
|
||||
ASSERT(PFN_FROM_SSE(PageTable->PageEntries[RawOffset]) == Page);
|
||||
InterlockedIncrement64(Segment->ReferenceCount);
|
||||
}
|
||||
|
||||
return Segment;
|
||||
|
|
|
@ -300,7 +300,6 @@ WriteSegment:
|
|||
Released = MmCheckDirtySegment(Segment, &SegmentOffset, FALSE, TRUE);
|
||||
|
||||
MmUnlockSectionSegment(Segment);
|
||||
|
||||
MmDereferenceSegment(Segment);
|
||||
|
||||
if (Released)
|
||||
|
@ -475,8 +474,6 @@ MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset)
|
|||
MiReleasePfnLock(OldIrql);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InterlockedIncrement64(Result->Segment->ReferenceCount);
|
||||
MiReleasePfnLock(OldIrql);
|
||||
return Result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue