Author: fireball Date: Fri Mar 26 09:39:27 2010 New Revision: 46459
URL: http://svn.reactos.org/svn/reactos?rev=46459&view=rev Log: [NTOSKRNL/CONFIG] - Add a macro for asserting hash lock ownership. - Add a macro for getting an alloc page from KCB / delay alloc item. - Add a newly allocated KCB to the tail of CmpFreeKCBList, not to its head.
Modified: trunk/reactos/ntoskrnl/config/cmalloc.c trunk/reactos/ntoskrnl/include/internal/cm_x.h
Modified: trunk/reactos/ntoskrnl/config/cmalloc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmalloc.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmalloc.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmalloc.c [iso-8859-1] Fri Mar 26 09:39:27 2010 @@ -70,14 +70,13 @@ KeAcquireGuardedMutex(&CmpAllocBucketLock);
/* Sanity check on lock ownership */ - //ASSERT((CmpIsKcbLockedExclusive(Kcb) == TRUE) || - // (CmpTestRegistryLockExclusive() == TRUE)); + CMP_ASSERT_HASH_ENTRY_LOCK(Kcb->ConvKey);
/* Add us to the free list */ InsertTailList(&CmpFreeKCBListHead, &Kcb->FreeListEntry);
/* Get the allocation page */ - AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Kcb & 0xFFFFF000); + AllocPage = CmpGetAllocPageFromKcb(Kcb);
/* Sanity check */ ASSERT(AllocPage->FreeCount != CM_KCBS_PER_PAGE); @@ -134,7 +133,7 @@ FreeListEntry);
/* Get the allocation page */ - AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)CurrentKcb & 0xFFFFF000); + AllocPage = CmpGetAllocPageFromKcb(CurrentKcb);
/* Decrease the free count */ ASSERT(AllocPage->FreeCount != 0); @@ -168,7 +167,7 @@ /* Set it up */ CurrentKcb->PrivateAlloc = TRUE; CurrentKcb->DelayCloseEntry = NULL; - InsertHeadList(&CmpFreeKCBListHead, + InsertTailList(&CmpFreeKCBListHead, &CurrentKcb->FreeListEntry); }
@@ -178,9 +177,7 @@ }
/* Allocate a KCB only */ - CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), - TRUE, - TAG_CM); + CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_CM); if (CurrentKcb) { /* Set it up */ @@ -219,7 +216,7 @@ Entry->ListEntry.Flink = Entry->ListEntry.Blink = NULL;
/* Grab the alloc page */ - AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000); + AllocPage = CmpGetAllocPageFromDelayAlloc(Entry);
/* Decrease free entries */ ASSERT(AllocPage->FreeCount != 0); @@ -278,7 +275,7 @@ InsertTailList(&CmpFreeDelayItemsListHead, &AllocEntry->ListEntry);
/* Get the alloc page */ - AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000); + AllocPage = CmpGetAllocPageFromDelayAlloc(Entry); ASSERT(AllocPage->FreeCount != CM_DELAYS_PER_PAGE);
/* Increase the number of free items */
Modified: trunk/reactos/ntoskrnl/include/internal/cm_x.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/c... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cm_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cm_x.h [iso-8859-1] Fri Mar 26 09:39:27 2010 @@ -254,3 +254,25 @@ ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable, \ (k)).Lock); \ } + +// +// Asserts that either the registry or the KCB is locked +// +#define CMP_ASSERT_HASH_ENTRY_LOCK(k) \ +{ \ + ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k).Owner == \ + KeGetCurrentThread())) || \ + (CmpTestRegistryLockExclusive() == TRUE)); \ +} + +// +// Gets the page attached to the KCB +// +#define CmpGetAllocPageFromKcb(k) \ + (PCM_ALLOC_PAGE)(((ULONG_PTR)(k)) & ~(PAGE_SIZE - 1)) + +// +// Gets the page attached to the delayed allocation +// +#define CmpGetAllocPageFromDelayAlloc(a) \ + (PCM_ALLOC_PAGE)(((ULONG_PTR)(a)) & ~(PAGE_SIZE - 1))