https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a6e080bd3db21d64f1b43222377bb9c70e805857
commit a6e080bd3db21d64f1b43222377bb9c70e805857 Author: Pierre Schweitzer <pie...@reactos.org> AuthorDate: Fri Feb 9 21:52:41 2018 +0100 Commit: Pierre Schweitzer <pie...@reactos.org> CommitDate: Fri Feb 9 21:52:41 2018 +0100 [NTOSKRNL] Avoid private cache map allocation for the first handle Standard shared cache map provides space for a private cache map, do the same and make it available for the first handle. It avoids two allocations in a row. --- ntoskrnl/cc/view.c | 19 +++++++++++++++++-- ntoskrnl/include/internal/cc.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index d69b195c10..cf2d2c5cb7 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -1194,7 +1194,14 @@ CcRosReleaseFileCache ( KeReleaseSpinLock(&SharedCacheMap->CacheMapLock, OldIrql); /* And free it. */ - ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP); + if (PrivateMap != &SharedCacheMap->PrivateCacheMap) + { + ExFreePoolWithTag(PrivateMap, TAG_PRIVATE_CACHE_MAP); + } + else + { + PrivateMap->NodeTypeCode = 0; + } if (SharedCacheMap->OpenCount > 0) { @@ -1271,7 +1278,15 @@ CcRosInitializeFileCache ( PPRIVATE_CACHE_MAP PrivateMap; /* Allocate the private cache map for this handle */ - PrivateMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(PRIVATE_CACHE_MAP), TAG_PRIVATE_CACHE_MAP); + if (SharedCacheMap->PrivateCacheMap.NodeTypeCode != 0) + { + PrivateMap = ExAllocatePoolWithTag(NonPagedPool, sizeof(PRIVATE_CACHE_MAP), TAG_PRIVATE_CACHE_MAP); + } + else + { + PrivateMap = &SharedCacheMap->PrivateCacheMap; + } + if (PrivateMap == NULL) { /* If we also allocated the shared cache map for this file, kill it */ diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h index d34360a7e3..5751ab665e 100644 --- a/ntoskrnl/include/internal/cc.h +++ b/ntoskrnl/include/internal/cc.h @@ -169,6 +169,7 @@ typedef struct _ROS_SHARED_CACHE_MAP PVOID LazyWriteContext; LIST_ENTRY PrivateList; ULONG DirtyPageThreshold; + PRIVATE_CACHE_MAP PrivateCacheMap; /* ROS specific */ LIST_ENTRY CacheMapVacbListHead;