Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

callperf.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1994 Microsoft Corporation 00004 00005 Module Name: 00006 00007 callperf.c 00008 00009 Abstract: 00010 00011 This module implements the functions necessary to collect call data. 00012 00013 Author: 00014 00015 David N. Cutler (davec) 22-May-1994 00016 00017 Environment: 00018 00019 Kernel mode only. 00020 00021 Revision History: 00022 00023 --*/ 00024 00025 #include "exp.h" 00026 00027 VOID 00028 ExInitializeCallData ( 00029 IN PCALL_PERFORMANCE_DATA CallData 00030 ) 00031 00032 /*++ 00033 00034 Routine Description: 00035 00036 This function initializes a call performance data structure. 00037 00038 Arguments: 00039 00040 CallData - Supplies a pointer to the call performance data structure 00041 that is initialized. 00042 00043 Return Value: 00044 00045 None. 00046 00047 --*/ 00048 00049 { 00050 00051 ULONG Index; 00052 00053 // 00054 // Initialize the spinlock and listheads for the call performance 00055 // data structure. 00056 // 00057 00058 KeInitializeSpinLock(&CallData->SpinLock); 00059 for (Index = 0; Index < CALL_HASH_TABLE_SIZE; Index += 1) { 00060 InitializeListHead(&CallData->HashTable[Index]); 00061 } 00062 } 00063 00064 VOID 00065 ExRecordCallerInHashTable ( 00066 IN PCALL_PERFORMANCE_DATA CallData, 00067 IN PVOID CallersAddress, 00068 IN PVOID CallersCaller 00069 ) 00070 00071 /*++ 00072 00073 Routine Description: 00074 00075 This function records call data in the specified call performance 00076 data structure. 00077 00078 Arguments: 00079 00080 CallData - Supplies a pointer to the call performance data structure 00081 in which the call data is recorded. 00082 00083 CallersAddress - Supplies the address of the caller of a fucntion. 00084 00085 CallersCaller - Supplies the address of the caller of a caller of 00086 a function. 00087 00088 Return Value: 00089 00090 None. 00091 00092 --*/ 00093 00094 { 00095 00096 PCALL_HASH_ENTRY HashEntry; 00097 ULONG Hash; 00098 PCALL_HASH_ENTRY MatchEntry; 00099 PLIST_ENTRY NextEntry; 00100 KIRQL OldIrql; 00101 00102 // 00103 // If the initialization phase is not zero, then collect call performance 00104 // data. 00105 // 00106 00107 if (InitializationPhase != 0) { 00108 00109 // 00110 // Acquire the call performance data structure spinlock. 00111 // 00112 00113 ExAcquireSpinLock(&CallData->SpinLock, &OldIrql); 00114 00115 // 00116 // Lookup the callers address in call performance data hash table. If 00117 // the address does not exist in the table, then create a new entry. 00118 // 00119 00120 Hash = (ULONG)((ULONG_PTR)CallersAddress ^ (ULONG_PTR)CallersCaller); 00121 Hash = ((Hash > 24) ^ (Hash > 16) ^ (Hash > 8) ^ (Hash)) & (CALL_HASH_TABLE_SIZE - 1); 00122 MatchEntry = NULL; 00123 NextEntry = CallData->HashTable[Hash].Flink; 00124 while (NextEntry != &CallData->HashTable[Hash]) { 00125 HashEntry = CONTAINING_RECORD(NextEntry, 00126 CALL_HASH_ENTRY, 00127 ListEntry); 00128 00129 if ((HashEntry->CallersAddress == CallersAddress) && 00130 (HashEntry->CallersCaller == CallersCaller)) { 00131 MatchEntry = HashEntry; 00132 break; 00133 } 00134 00135 NextEntry = NextEntry->Flink; 00136 } 00137 00138 // 00139 // If a matching caller address was found, then update the call site 00140 // statistics. Otherwise, allocate a new hash entry and initialize 00141 // call site statistics. 00142 // 00143 00144 if (MatchEntry != NULL) { 00145 MatchEntry->CallCount += 1; 00146 00147 } else { 00148 MatchEntry = ExAllocatePoolWithTag(NonPagedPool, 00149 sizeof(CALL_HASH_ENTRY), 00150 'CdHe'); 00151 00152 if (MatchEntry != NULL) { 00153 MatchEntry->CallersAddress = CallersAddress; 00154 MatchEntry->CallersCaller = CallersCaller; 00155 MatchEntry->CallCount = 1; 00156 InsertTailList(&CallData->HashTable[Hash], 00157 &MatchEntry->ListEntry); 00158 } 00159 } 00160 00161 // 00162 // Release the call performance data structure spinlock. 00163 // 00164 00165 ExReleaseSpinLock(&CallData->SpinLock, OldIrql); 00166 } 00167 00168 return; 00169 }

Generated on Sat May 15 19:39:21 2004 for test by doxygen 1.3.7