Freigeben über


Retaining the dwCeLogTLBMiss Counter (Windows CE 5.0)

Send Feedback

ARM and x86 CPUs handle translation look-aside buffer (TLB) misses with hardware. As a result, CeLog cannot record TLB-miss counts for these CPUs. MIPS and SH CPUs use software TLB-miss handling, and so for these CPUs it is possible for CeLog to record TLB-miss counts by communicating with the kernel TLB-miss handling routines.

The kernel TLB-miss handling routines only record TLB-miss counts on profiling builds, so it is only possible for CeLog to record TLB-miss counts on these builds.

The kernel variable dwCeLogTLBMiss stores a count of TLB misses. The kernel TLB-miss handler updates this variable on each TLB miss. A pointer to this variable is passed to the event tracking library in the CeLogImportTable structure. The kernel does not log CELID_SYSTEM_TLB events to record TLB misses. The kernel only updates the dwCeLogTLBMiss counter. If you implement an event-tracking library, your library will not receive notification of TLB misses other than the contents of the dwCeLogTLBMiss variable.

To track the count of TLB misses, check whether the variable value has changed occasionally, and log the changes as CELID_SYSTEM_TLB events. The variable does not reset to 0, so you must store a copy of the previous value of the TLB miss counter, for use in measuring how much the value changed.

The following sample code demonstrates how your event-tracking library can record TLB miss counts.

CeLogImportTable imports; // Initialization from IOCTL_CELOG_IMPORT not shown here

void CheckTLBMisses()
{
    static DWORD dwPrevCount = 0;
    DWORD dwCurrentCount;

    // Keep a local copy in case it changes asynchronously
    dwCurrentCount = *imports.pdwCeLogTLBMiss;

    if (dwCurrentCount != dwPrevCount) {
        // The TLB miss count has increased since last time this code executed.

        // Convenient structure for logging the change in a CELID_SYSTEM_TLB event
        struct {
            CEL_HEADER header;
            DWORD dwTLBMissCount;
        } MyTLBEvent;
        MyTLBEvent.header.ID = CELID_SYSTEM_TLB;
        MyTLBEvent.header.Length = sizeof(MyTLBEvent.dwTLBMissCount);
        MyTLBEvent.header.fTimeStamp = FALSE;
        MyTLBEvent.dwTLBMissCount = dwCurrentCount – dwPrevCount;

        // Now write the MyTLBEvent structure to the memory-mapped file
        // or to a log file – not shown here.

        // Remember the counter value for next time
        dwPrevCount = dwCurrentCount;
    }
}

See Also

Implementing an Event Tracking Library | OAL Elements for CeLog Event Tracking

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.