https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9ac2e9855af67e4442aaf198654f701dbb377591

commit 9ac2e9855af67e4442aaf198654f701dbb377591
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Sat Feb 24 14:02:33 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Sat Feb 24 14:52:04 2018 +0100

    [NTOSKRNL] Add the CcDataFlushes and CcDataPages counters
---
 ntoskrnl/cc/copy.c             | 7 +++++++
 ntoskrnl/ex/sysinfo.c          | 4 ++--
 ntoskrnl/include/internal/cc.h | 2 ++
 ntoskrnl/io/iomgr/iofunc.c     | 8 ++++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/cc/copy.c b/ntoskrnl/cc/copy.c
index 496cef6d4d..8525d9f549 100644
--- a/ntoskrnl/cc/copy.c
+++ b/ntoskrnl/cc/copy.c
@@ -43,6 +43,13 @@ ULONG CcFastReadWait;
 ULONG CcFastReadNoWait;
 ULONG CcFastReadResourceMiss;
 
+/* Counters:
+ * - Amount of pages flushed to the disk
+ * - Number of flush operations
+ */
+ULONG CcDataPages = 0;
+ULONG CcDataFlushes = 0;
+
 /* FUNCTIONS *****************************************************************/
 
 VOID
diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c
index 4db50e5b0b..ceb1d22842 100644
--- a/ntoskrnl/ex/sysinfo.c
+++ b/ntoskrnl/ex/sysinfo.c
@@ -709,8 +709,8 @@ QSI_DEF(SystemPerformanceInformation)
     Spi->CcReadAheadIos = 0; /* FIXME */
     Spi->CcLazyWriteIos = CcLazyWriteIos;
     Spi->CcLazyWritePages = CcLazyWritePages;
-    Spi->CcDataFlushes = 0; /* FIXME */
-    Spi->CcDataPages = 0; /* FIXME */
+    Spi->CcDataFlushes = CcDataFlushes;
+    Spi->CcDataPages = CcDataPages;
     Spi->ContextSwitches = 0; /* FIXME */
     Spi->FirstLevelTbFills = 0; /* FIXME */
     Spi->SecondLevelTbFills = 0; /* FIXME */
diff --git a/ntoskrnl/include/internal/cc.h b/ntoskrnl/include/internal/cc.h
index 32caa551b2..e91f1b4993 100644
--- a/ntoskrnl/include/internal/cc.h
+++ b/ntoskrnl/include/internal/cc.h
@@ -62,6 +62,8 @@ extern ULONG CcMapDataWait;
 extern ULONG CcMapDataNoWait;
 extern ULONG CcPinReadWait;
 extern ULONG CcPinReadNoWait;
+extern ULONG CcDataPages;
+extern ULONG CcDataFlushes;
 
 typedef struct _PF_SCENARIO_ID
 {
diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 19f54e070d..aa08bf7232 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -1039,6 +1039,14 @@ IoSynchronousPageWrite(IN PFILE_OBJECT FileObject,
     IOTRACE(IO_API_DEBUG, "FileObject: %p. Mdl: %p. Offset: %p \n",
             FileObject, Mdl, Offset);
 
+    /* Is the write originating from Cc? */
+    if (FileObject->SectionObjectPointer != NULL &&
+        FileObject->SectionObjectPointer->SharedCacheMap != NULL)
+    {
+        ++CcDataFlushes;
+        CcDataPages += BYTES_TO_PAGES(MmGetMdlByteCount(Mdl));
+    }
+
     /* Get the Device Object */
     DeviceObject = IoGetRelatedDeviceObject(FileObject);
 

Reply via email to