https://git.reactos.org/?p=reactos.git;a=commitdiff;h=82dd1afe33dda96e2dd52…
commit 82dd1afe33dda96e2dd52e249335ef563009575e
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Apr 26 18:18:23 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Jun 9 11:27:18 2021 +0200
[NTOS:MM] Remove some dead code from legacy Mm
---
ntoskrnl/include/internal/mm.h | 2 +-
ntoskrnl/mm/ARM3/procsup.c | 8 ++++-
ntoskrnl/mm/balance.c | 33 -------------------
ntoskrnl/mm/marea.c | 72 ------------------------------------------
4 files changed, 8 insertions(+), 107 deletions(-)
diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h
index c3391191a17..a68359da713 100644
--- a/ntoskrnl/include/internal/mm.h
+++ b/ntoskrnl/include/internal/mm.h
@@ -744,7 +744,7 @@ VOID
NTAPI
MmCleanProcessAddressSpace(IN PEPROCESS Process);
-NTSTATUS
+VOID
NTAPI
MmDeleteProcessAddressSpace(IN PEPROCESS Process);
diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c
index c7abed0c794..2fc8dccae54 100644
--- a/ntoskrnl/mm/ARM3/procsup.c
+++ b/ntoskrnl/mm/ARM3/procsup.c
@@ -1326,12 +1326,18 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process)
VOID
NTAPI
-MmDeleteProcessAddressSpace2(IN PEPROCESS Process)
+MmDeleteProcessAddressSpace(IN PEPROCESS Process)
{
PMMPFN Pfn1, Pfn2;
KIRQL OldIrql;
PFN_NUMBER PageFrameIndex;
+#ifndef _M_AMD64
+ OldIrql = MiAcquireExpansionLock();
+ RemoveEntryList(&Process->MmProcessLinks);
+ MiReleaseExpansionLock(OldIrql);
+#endif
+
//ASSERT(Process->CommitCharge == 0);
/* Remove us from the list */
diff --git a/ntoskrnl/mm/balance.c b/ntoskrnl/mm/balance.c
index 93b05138df3..e6f1313b03f 100644
--- a/ntoskrnl/mm/balance.c
+++ b/ntoskrnl/mm/balance.c
@@ -254,13 +254,6 @@ MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages)
return STATUS_SUCCESS;
}
-static BOOLEAN
-MiIsBalancerThread(VOID)
-{
- return (MiBalancerThreadHandle != NULL) &&
- (PsGetCurrentThreadId() == MiBalancerThreadId.UniqueThread);
-}
-
VOID
NTAPI
MmRebalanceMemoryConsumers(VOID)
@@ -320,32 +313,6 @@ MiBalancerThread(PVOID Unused)
{
ULONG InitialTarget = 0;
-#if (_MI_PAGING_LEVELS == 2)
- if (!MiIsBalancerThread())
- {
- /* Clean up the unused PDEs */
- ULONG_PTR Address;
- PEPROCESS Process = PsGetCurrentProcess();
-
- /* Acquire PFN lock */
- KIRQL OldIrql = MiAcquirePfnLock();
- PMMPDE pointerPde;
- for (Address = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS;
- Address < (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
- Address += PTE_PER_PAGE * PAGE_SIZE)
- {
- if (MiQueryPageTableReferences((PVOID)Address) == 0)
- {
- pointerPde = MiAddressToPde(Address);
- if (pointerPde->u.Hard.Valid)
- MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process,
NULL);
- ASSERT(pointerPde->u.Hard.Valid == 0);
- }
- }
- /* Release lock */
- MiReleasePfnLock(OldIrql);
- }
-#endif
do
{
ULONG OldTarget = InitialTarget;
diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c
index 1942dd76b27..78d07c75cd6 100644
--- a/ntoskrnl/mm/marea.c
+++ b/ntoskrnl/mm/marea.c
@@ -547,76 +547,4 @@ MiRosCleanupMemoryArea(
/* Make sure this worked! */
ASSERT(NT_SUCCESS(Status));
}
-
-VOID
-NTAPI
-MmDeleteProcessAddressSpace2(IN PEPROCESS Process);
-
-NTSTATUS
-NTAPI
-MmDeleteProcessAddressSpace(PEPROCESS Process)
-{
-#ifndef _M_AMD64
- KIRQL OldIrql;
-#endif
-
- DPRINT("MmDeleteProcessAddressSpace(Process %p (%s))\n", Process,
- Process->ImageFileName);
-
-#ifndef _M_AMD64
- OldIrql = MiAcquireExpansionLock();
- RemoveEntryList(&Process->MmProcessLinks);
- MiReleaseExpansionLock(OldIrql);
-#endif
- MmLockAddressSpace(&Process->Vm);
-
-#if (_MI_PAGING_LEVELS == 2)
- {
- KIRQL OldIrql;
- PVOID Address;
- PMMPDE pointerPde;
-
- /* Attach to Process */
- KeAttachProcess(&Process->Pcb);
-
- /* Acquire PFN lock */
- OldIrql = MiAcquirePfnLock();
-
- for (Address = MI_LOWEST_VAD_ADDRESS;
- Address < MM_HIGHEST_VAD_ADDRESS;
- Address = (PVOID)((ULONG_PTR)Address + (PTE_PER_PAGE * PAGE_SIZE)))
- {
- /* At this point all references should be dead */
- if (MiQueryPageTableReferences(Address) != 0)
- {
- DPRINT1("Process %p, Address %p, UsedPageTableEntries %lu\n",
- Process,
- Address,
- MiQueryPageTableReferences(Address));
- ASSERT(MiQueryPageTableReferences(Address) == 0);
- }
-
- pointerPde = MiAddressToPde(Address);
- /* Unlike in ARM3, we don't necesarrily free the PDE page as soon as
reference reaches 0,
- * so we must clean up a bit when process closes */
- if (pointerPde->u.Hard.Valid)
- MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL);
- ASSERT(pointerPde->u.Hard.Valid == 0);
- }
-
- /* Release lock */
- MiReleasePfnLock(OldIrql);
-
- /* Detach */
- KeDetachProcess();
- }
-#endif
-
- MmUnlockAddressSpace(&Process->Vm);
-
- DPRINT("Finished MmDeleteProcessAddressSpace()\n");
- MmDeleteProcessAddressSpace2(Process);
- return(STATUS_SUCCESS);
-}
-
/* EOF */