Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. cachedat.c
  5. Abstract:
  6. This module implements the Memory Management based cache management
  7. routines for the common Cache subsystem.
  8. Author:
  9. Tom Miller [TomM] 4-May-1990
  10. Revision History:
  11. --*/
  12. #include "cc.h"
  13. //
  14. // Global SharedCacheMap lists and resource to synchronize access to it.
  15. //
  16. //
  17. // extern KSPIN_LOCK CcMasterSpinLock;
  18. LIST_ENTRY CcCleanSharedCacheMapList;
  19. SHARED_CACHE_MAP_LIST_CURSOR CcDirtySharedCacheMapList;
  20. SHARED_CACHE_MAP_LIST_CURSOR CcLazyWriterCursor;
  21. //
  22. // Worker thread structures:
  23. //
  24. // A spinlock to synchronize all three lists.
  25. // A count of the number of worker threads Cc will use
  26. // A count of the number of worker threads Cc in use
  27. // A listhead for preinitialized executive work items for Cc use.
  28. // A listhead for an express queue of WORK_QUEUE_ENTRYs
  29. // A listhead for a regular queue of WORK_QUEUE_ENTRYs
  30. // A listhead for a post-tick queue of WORK_QUEUE_ENTRYs
  31. //
  32. // A flag indicating if we are throttling the queue to a single thread
  33. //
  34. // extern KSPIN_LOCK CcWorkQueueSpinLock;
  35. ULONG CcNumberWorkerThreads = 0;
  36. ULONG CcNumberActiveWorkerThreads = 0;
  37. LIST_ENTRY CcIdleWorkerThreadList;
  38. LIST_ENTRY CcExpressWorkQueue;
  39. LIST_ENTRY CcRegularWorkQueue;
  40. LIST_ENTRY CcPostTickWorkQueue;
  41. BOOLEAN CcQueueThrottle = FALSE;
  42. //
  43. // Store the current idle delay and target time to clean all. We must calculate
  44. // the idle delay in terms of clock ticks for the lazy writer timeout.
  45. //
  46. ULONG CcIdleDelayTick;
  47. LARGE_INTEGER CcNoDelay;
  48. LARGE_INTEGER CcFirstDelay = {(ULONG)-(3*LAZY_WRITER_IDLE_DELAY), -1};
  49. LARGE_INTEGER CcIdleDelay = {(ULONG)-LAZY_WRITER_IDLE_DELAY, -1};
  50. LARGE_INTEGER CcCollisionDelay = {(ULONG)-LAZY_WRITER_COLLISION_DELAY, -1};
  51. LARGE_INTEGER CcTargetCleanDelay = {(ULONG)-(LONG)(LAZY_WRITER_IDLE_DELAY * (LAZY_WRITER_MAX_AGE_TARGET + 1)), -1};
  52. //
  53. // Spinlock for controlling access to Vacb and related global structures,
  54. // and a counter indicating how many Vcbs are active.
  55. //
  56. // extern KSPIN_LOCK CcVacbSpinLock;
  57. ULONG_PTR CcNumberVacbs;
  58. //
  59. // Pointer to the global Vacb vector.
  60. //
  61. PVACB CcVacbs;
  62. PVACB CcBeyondVacbs;
  63. LIST_ENTRY CcVacbLru;
  64. LIST_ENTRY CcVacbFreeList;
  65. ULONG CcMaxVacbLevelsSeen = 1;
  66. ULONG CcVacbLevelEntries = 0;
  67. PVACB *CcVacbLevelFreeList = NULL;
  68. ULONG CcVacbLevelWithBcbsEntries = 0;
  69. PVACB *CcVacbLevelWithBcbsFreeList = NULL;
  70. //
  71. // Deferred write list and respective Thresholds
  72. //
  73. extern KSPIN_LOCK CcDeferredWriteSpinLock;
  74. LIST_ENTRY CcDeferredWrites;
  75. ULONG CcDirtyPageThreshold;
  76. ULONG CcDirtyPageTarget;
  77. ULONG CcPagesYetToWrite;
  78. ULONG CcPagesWrittenLastTime = 0;
  79. ULONG CcDirtyPagesLastScan = 0;
  80. ULONG CcAvailablePagesThreshold = 100;
  81. ULONG CcTotalDirtyPages = 0;
  82. //
  83. // Captured system size
  84. //
  85. MM_SYSTEMSIZE CcCapturedSystemSize;
  86. //
  87. // Number of outstanding aggresive zeroers in the system. Used
  88. // to throttle the activity.
  89. //
  90. LONG CcAggressiveZeroCount;
  91. LONG CcAggressiveZeroThreshold;
  92. //
  93. // Tuning options du Jour
  94. //
  95. ULONG CcTune = 0;
  96. //
  97. // Global structure controlling lazy writer algorithms
  98. //
  99. LAZY_WRITER LazyWriter;
  100. GENERAL_LOOKASIDE CcTwilightLookasideList;
  101. #ifdef CCDBG
  102. LONG CcDebugTraceLevel = 0;
  103. LONG CcDebugTraceIndent = 0;
  104. #ifdef CCDBG_LOCK
  105. extern KSPIN_LOCK CcDebugTraceLock;
  106. #endif // def CCDBG_LOCK
  107. #endif
  108. //
  109. // Global list of pinned Bcbs which may be examined for debug purposes
  110. //
  111. #if DBG
  112. ULONG CcBcbCount;
  113. LIST_ENTRY CcBcbList;
  114. #endif
  115. //
  116. // Throw away miss counter.
  117. //
  118. ULONG CcThrowAway;
  119. //
  120. // Performance Counters
  121. //
  122. ULONG CcFastReadNoWait;
  123. ULONG CcFastReadWait;
  124. ULONG CcFastReadResourceMiss;
  125. ULONG CcFastReadNotPossible;
  126. ULONG CcFastMdlReadNoWait;
  127. ULONG CcFastMdlReadWait;
  128. ULONG CcFastMdlReadResourceMiss;
  129. ULONG CcFastMdlReadNotPossible;
  130. ULONG CcMapDataNoWait;
  131. ULONG CcMapDataWait;
  132. ULONG CcMapDataNoWaitMiss;
  133. ULONG CcMapDataWaitMiss;
  134. ULONG CcPinMappedDataCount;
  135. ULONG CcPinReadNoWait;
  136. ULONG CcPinReadWait;
  137. ULONG CcPinReadNoWaitMiss;
  138. ULONG CcPinReadWaitMiss;
  139. ULONG CcCopyReadNoWait;
  140. ULONG CcCopyReadWait;
  141. ULONG CcCopyReadNoWaitMiss;
  142. ULONG CcCopyReadWaitMiss;
  143. ULONG CcMdlReadNoWait;
  144. ULONG CcMdlReadWait;
  145. ULONG CcMdlReadNoWaitMiss;
  146. ULONG CcMdlReadWaitMiss;
  147. ULONG CcReadAheadIos;
  148. ULONG CcLazyWriteHotSpots;
  149. ULONG CcLazyWriteIos;
  150. ULONG CcLazyWritePages;
  151. ULONG CcDataFlushes;
  152. ULONG CcDataPages;
  153. ULONG CcLostDelayedWrites;
  154. PULONG CcMissCounter = &CcThrowAway;