问题描述:explorer一直以38.8k的(峰值为77.5k)的速度规律性的读取IO,读取次数94/s。结果是一直占用cpu内核时间,引起页错误。没有内存变化,说明它一直没有读到需要的数据。不停的页错误,说明它不是读真实的物理设备,而是在读那俩个页。
问题分析:发起请求-----不在working set----引起page fault----kernel trap gate----1.若为硬fault,访问page backing store;2.软,不访问-----added to ws
由于无法加载page,使得线程循环请求。所以最简单粗暴的办法,就是关掉线程。
可疑线程如下:
1492 28 stobject.dll!CSysTray::SysTrayThreadProc
ntkrnlpa.exe!KiSwapContext+0x2f
ntkrnlpa.exe!KiSwapThread+0x8a
ntkrnlpa.exe!KeWaitForSingleObject+0x1c2
ntkrnlpa.exe!KiSuspendThread+0x18
ntkrnlpa.exe!KiDeliverApc+0x124
ntkrnlpa.exe!KiSwapThread+0xa8
ntkrnlpa.exe!KeWaitForSingleObject+0x1c2
win32k.sys!xxxSleepThread+0x192
win32k.sys!xxxRealInternalGetMessage+0x418
win32k.sys!NtUserGetMessage+0x27
ntkrnlpa.exe!KiFastCallEntry+0xfc
ntdll.dll!KiFastSystemCallRet
USER32.dll!NtUserGetMessage+0xc
stobject.dll!SysTrayMain+0x180
stobject.dll!CSysTray::SysTrayThreadProc+0x4f
kernel32.dll!BaseThreadStart+0x37
1424 5 SHLWAPI.dll!WrapperThreadProc
ntkrnlpa.exe!KiSwapContext+0x2f
ntkrnlpa.exe!KiSwapThread+0x8a
ntkrnlpa.exe!KeWaitForSingleObject+0x1c2
ntkrnlpa.exe!KiSuspendThread+0x18
ntkrnlpa.exe!KiDeliverApc+0x124
ntkrnlpa.exe!KiSwapThread+0xa8
ntkrnlpa.exe!KeWaitForSingleObject+0x1c2
win32k.sys!xxxSleepThread+0x192
win32k.sys!xxxRealWaitMessageEx+0x12
win32k.sys!NtUserWaitMessage+0x14
ntkrnlpa.exe!KiFastCallEntry+0xfc
ntdll.dll!KiFastSystemCallRet
USER32.dll!NtUserWaitMessage+0xc
Explorer.EXE!CTray::MainThreadProc+0x29
SHLWAPI.dll!WrapperThreadProc+0x94
kernel32.dll!BaseThreadStart+0x37
1604 1 BrowseUI.dll!BrowserProtectedThreadProc
学习资料
working set:the amount of memory in a given time interval,effective use of caches。 the working set strategy prevents thrashing while keeping the degree of multiprogramming as high as possible. Thus it optimizes CPU utilization and throughput.
ws可以从data和code分,也可以从share跟private分。
ws特点:通过TLB定位,pageable,不含Address Windowing Extensions(AWE)以及large page allocations。相关函数GetProcessMemoryInfo、Get(Set)ProcessWorkingSetSizeEx、EmptyWorkingSet、VirtualUnlock、UnmapViewOfFile。在psapi.h中还发现了一个函数QueryWorkingSet,返回了ws中每个页的属性跟位置。常态操作它的是系统的memory manager。当working set被全部进程抛弃的时候,进入transition page状态,等待着重利用。
通过工具(E:\book\0code\working-set)读出结果如下(尚未完善,待续)
process:
进程除了自己的结构之外,子系统部分csrss.exe/win32k.sys分别在用户跟内核维护着对应的结构:CSR_PROCESS、W32PROCESS。参考链接http://forum.sysinternals.com/topic15457.html