Implementation of system performance auditing hax.

svn path=/trunk/; revision=9136
This commit is contained in:
James Tabor 2004-04-14 07:11:20 +00:00
parent 900e819d27
commit 7d88f002d2
6 changed files with 84 additions and 20 deletions

View file

@ -1,4 +1,4 @@
/* $Id: sysinfo.c,v 1.26 2003/12/14 17:44:02 hbirr Exp $
/* $Id: sysinfo.c,v 1.27 2004/04/14 07:10:44 jimtabor Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -21,6 +21,7 @@
#include <internal/ldr.h>
#include <internal/safe.h>
#include <internal/ps.h>
#include <internal/mm.h>
#include <internal/debug.h>
@ -303,7 +304,7 @@ QSI_DEF(SystemBasicInformation)
Sbi->LowestUserAddress = 0; /* FIXME */
Sbi->HighestUserAddress = 0; /* FIXME */
Sbi->ActiveProcessors = 0x00000001; /* FIXME */
Sbi->NumberProcessors = 1; /* FIXME */
Sbi->NumberProcessors = KeNumberProcessors;
return (STATUS_SUCCESS);
}
@ -348,14 +349,15 @@ QSI_DEF(SystemPerformanceInformation)
return (STATUS_INFO_LENGTH_MISMATCH);
}
Spi->IdleTime.QuadPart = 0; /* FIXME */
Spi->IdleTime.QuadPart = PsInitialSystemProcess->Pcb.KernelTime * 100000;
Spi->ReadTransferCount.QuadPart = 0; /* FIXME */
Spi->WriteTransferCount.QuadPart = 0; /* FIXME */
Spi->OtherTransferCount.QuadPart = 0; /* FIXME */
Spi->ReadOperationCount = 0; /* FIXME */
Spi->WriteOperationCount = 0; /* FIXME */
Spi->OtherOperationCount = 0; /* FIXME */
Spi->AvailablePages = 0; /* FIXME */
Spi->AvailablePages = MiNrAvailablePages;
Spi->TotalCommittedPages = 0; /* FIXME */
Spi->TotalCommitLimit = 0; /* FIXME */
Spi->PeakCommitment = 0; /* FIXME */
@ -435,6 +437,8 @@ QSI_DEF(SystemPerformanceInformation)
/* Class 3 - Time Of Day Information */
QSI_DEF(SystemTimeOfDayInformation)
{
LARGE_INTEGER CurrentTime;
PSYSTEM_TIMEOFDAY_INFORMATION Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION) Buffer;
@ -447,9 +451,11 @@ QSI_DEF(SystemTimeOfDayInformation)
return (STATUS_INFO_LENGTH_MISMATCH);
}
Sti->BootTime.QuadPart = 0; /* FIXME */
Sti->CurrentTime.QuadPart = 0; /* FIXME */
Sti->TimeZoneBias.QuadPart = 0; /* FIXME */
KeQuerySystemTime(&CurrentTime);
Sti->BootTime= SystemBootTime;
Sti->CurrentTime = CurrentTime;
Sti->TimeZoneBias.QuadPart = _SystemTimeZoneInfo.Bias;
Sti->TimeZoneId = 0; /* FIXME */
Sti->Reserved = 0; /* FIXME */
@ -515,8 +521,11 @@ QSI_DEF(SystemProcessInformation)
SpiCur->NextEntryDelta = curSize+inLen; // relative offset to the beginnnig of the next structure
SpiCur->ThreadCount = nThreads;
SpiCur->CreateTime = pr->CreateTime;
//SpiCur->UserTime = 0; // FIXME
//SpiCur->KernelTime = 0; // FIXME
/*
* System Clock is 18.2 psec.
*/
SpiCur->UserTime.QuadPart = pr->Pcb.UserTime * 100000;
SpiCur->KernelTime.QuadPart = pr->Pcb.KernelTime * 100000;
SpiCur->ProcessName.Length = strlen(pr->ImageFileName) * sizeof(WCHAR);
SpiCur->ProcessName.MaximumLength = inLen;
@ -526,7 +535,7 @@ QSI_DEF(SystemProcessInformation)
RtlInitAnsiString(&imgName, pr->ImageFileName);
RtlAnsiStringToUnicodeString(&SpiCur->ProcessName, &imgName, FALSE);
SpiCur->BasePriority = 0; // FIXME
SpiCur->BasePriority = pr->Pcb.BasePriority;
SpiCur->ProcessId = pr->UniqueProcessId;
SpiCur->InheritedFromProcessId = (DWORD)(pr->InheritedFromUniqueProcessId);
SpiCur->HandleCount = 0; // FIXME
@ -602,8 +611,27 @@ QSI_DEF(SystemDeviceInformation)
/* Class 8 - Processor Performance Information */
QSI_DEF(SystemProcessorPerformanceInformation)
{
/* FIXME */
return (STATUS_NOT_IMPLEMENTED);
PSYSTEM_PROCESSORTIME_INFO Spi
= (PSYSTEM_PROCESSORTIME_INFO) Buffer;
*ReqSize = sizeof (SYSTEM_PROCESSORTIME_INFO);
/*
* Check user buffer's size
*/
if (Size < sizeof (SYSTEM_PROCESSORTIME_INFO))
{
return (STATUS_INFO_LENGTH_MISMATCH);
}
Spi->TotalProcessorRunTime.QuadPart =
PsInitialSystemProcess->Pcb.KernelTime * 100000; // IdleTime
Spi->TotalProcessorTime.QuadPart = KiKernelTime * 100000; // KernelTime
Spi->TotalProcessorUserTime.QuadPart = KiUserTime * 100000;
Spi->TotalDPCTime.QuadPart = KiDpcTime * 100000;
Spi->TotalInterruptTime.QuadPart = 0;
Spi->TotalInterrupts = 0; // Interrupt Count
return (STATUS_SUCCESS);
}
/* Class 9 - Flags Information */
@ -941,7 +969,7 @@ QSI_DEF(SystemCurrentTimeZoneInformation)
/* Copy the time zone information struct */
memcpy (
Buffer,
& SystemTimeZoneInfo,
& _SystemTimeZoneInfo,
sizeof (TIME_ZONE_INFORMATION)
);
@ -960,7 +988,7 @@ SSI_DEF(SystemCurrentTimeZoneInformation)
}
/* Copy the time zone information struct */
memcpy (
& SystemTimeZoneInfo,
& _SystemTimeZoneInfo,
(TIME_ZONE_INFORMATION *) Buffer,
sizeof (TIME_ZONE_INFORMATION)
);
@ -1141,6 +1169,8 @@ NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
NTSTATUS Status;
NTSTATUS FStatus;
DPRINT("NtQuerySystemInformation Start.\n");
/*if (ExGetPreviousMode() == KernelMode)
{*/
SystemInformation = UnsafeSystemInformation;

View file

@ -98,7 +98,7 @@ typedef VOID (*PLOOKASIDE_MINMAX_ROUTINE)(
/* GLOBAL VARIABLES *********************************************************/
TIME_ZONE_INFORMATION SystemTimeZoneInfo;
TIME_ZONE_INFORMATION _SystemTimeZoneInfo;
extern POBJECT_TYPE ExEventPairObjectType;

View file

@ -29,6 +29,14 @@
#include "arch/ke.h"
extern LARGE_INTEGER SystemBootTime;
extern ULONG KiKernelTime;
extern ULONG KiUserTime;
extern ULONG KiDpcTime;
/* INTERNAL KERNEL FUNCTIONS ************************************************/
#ifdef __USE_W32API

View file

@ -10,6 +10,8 @@
/* TYPES *********************************************************************/
extern ULONG MiNrAvailablePages;
struct _EPROCESS;
struct _MM_RMAP_ENTRY;

View file

@ -1,4 +1,4 @@
/* $Id: timer.c,v 1.67 2004/01/18 22:32:47 gdalsnes Exp $
/* $Id: timer.c,v 1.68 2004/04/14 07:10:58 jimtabor Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -33,11 +33,15 @@
* Current time
*/
#if defined(__GNUC__)
static LARGE_INTEGER SystemBootTime = (LARGE_INTEGER)0LL;
LARGE_INTEGER SystemBootTime = (LARGE_INTEGER)0LL;
#else
static LARGE_INTEGER SystemBootTime = { 0 };
LARGE_INTEGER SystemBootTime = { 0 };
#endif
ULONG KiKernelTime;
ULONG KiUserTime;
ULONG KiDpcTime;
/*
* Number of timer interrupts since initialisation
*/
@ -596,6 +600,9 @@ KiUpdateSystemTime(KIRQL oldIrql,
*/
{
LARGE_INTEGER Time;
PKTHREAD CurrentThread;
PKPROCESS CurrentProcess;
assert(KeGetCurrentIrql() == PROFILE_LEVEL);
KiRawTicks++;
@ -626,6 +633,23 @@ KiUpdateSystemTime(KIRQL oldIrql,
SharedUserData->SystemTime.LowPart = Time.u.LowPart;
SharedUserData->SystemTime.High1Part = Time.u.HighPart;
CurrentThread = KeGetCurrentThread();
CurrentProcess = KeGetCurrentProcess();
if (CurrentThread->PreviousMode == UserMode)
{
++CurrentThread->UserTime;
++CurrentProcess->UserTime;
++KiUserTime;
}
if (CurrentThread->PreviousMode == KernelMode)
{
++CurrentProcess->KernelTime;
++CurrentThread->KernelTime;
++KiKernelTime;
}
KiReleaseSpinLock(&TimerValueLock);
/*

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: balance.c,v 1.27 2004/04/10 22:35:25 gdalsnes Exp $
/* $Id: balance.c,v 1.28 2004/04/14 07:11:08 jimtabor Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/balance.c
@ -57,7 +57,7 @@ MM_ALLOCATION_REQUEST, *PMM_ALLOCATION_REQUEST;
static MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
static ULONG MiMinimumAvailablePages;
static ULONG MiNrAvailablePages;
ULONG MiNrAvailablePages;
static ULONG MiNrTotalPages;
static LIST_ENTRY AllocationListHead;
static KSPIN_LOCK AllocationListLock;