Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
앞서 MSDN magazine에서 System PTEs 와 관련된 좋은 글을 전달해 드렸습니다. 좀더 System PTEs 에 대한 이해를 도와 드리기 위해 저의 경험에서 나온 정보를 좀 더 정리해 보았습니다.
System PTEs가 부족할 경우 어떤 문제가 발생할 수 있을 까요?
일단 시스템이 비 정상적으로 동작할 수 있습니다. System PTEs 가 부족하면 추가적으로 kernel stack 을 할당할 수 없으므로 Thread 의 생성 Process 의 생성은 물론 기존에 Slep 되어 있던 Thread가 깨어나면서 kerenl stack 을 할당 받고자 할 경우에도 문제가 될 것 같습니다. 제가 직접 적으로 경험했던 것으로는 Kernel Driver 다 Load 되지 않았던 것 입니다.
아래에서는 실제로 System PTEs 가 어떻게 할당되어 사용되고 있는지 확인해 보도록 하겠습니다.
!sysptes 명령으로 System Ptes 의 시작 PTE 와 마지막 PTE 의 가상 주소를 알 수 있습니다.
lkd> !sysptes
System PTE Information
Total System Ptes 4294967296
SysPtes list of size 1 has 127 free
SysPtes list of size 2 has 65 free
SysPtes list of size 4 has 94 free
SysPtes list of size 8 has 30 free
SysPtes list of size 16 has 72 free
starting PTE: c0228000
ending PTE: c03def78
free blocks: 289 total free: 167789 largest free block: 136815
커널 스택이 System PTEs 를 사용한 경우를 확인해 보면
THREAD 8896ec48 Cid 4f98.6dd4 Teb: 7ff9c000 Win32Thread: e32edbe8 WAIT: (Unknown) UserMode Non-Alertable
89a06180 SynchronizationEvent
Not impersonating
DeviceMap e280eec8
Owning Process 8976f9f8 Image: explorer.exe
Attached Process N/A Image: N/A
Wait Start TickCount 41056853 Ticks: 22 (0:00:00:00.343)
Context Switch Count 1943501 LargeStack
UserTime 00:00:01.406
KernelTime 00:00:03.296
Win32 Start Address 0x75d61c3f
Start Address 0x7c8217ec
Stack Init b6947000 Current b6946c50 Base b6947000 Limit b6940000 Call 0
Priority 10 BasePriority 8 PriorityDecrement 0
ChildEBP RetAddr
b6946c68 8083d5b1 nt!KiSwapContext+0x26
b6946c94 8083df9e nt!KiSwapThread+0x2e5
b6946cdc bf89ab63 nt!KeWaitForSingleObject+0x346
b6946d38 bf89d9d3 win32k!xxxSleepThread+0x1be
b6946d4c bf89e391 win32k!xxxRealWaitMessageEx+0x12
b6946d5c 80833bef win32k!NtUserWaitMessage+0x14
b6946d5c 7c96860c nt!KiFastCallEntry+0xfc
0446ff2c 00000000 0x7c96860c
커널 스택의 값 중 하나를 선택해서 !pte 명령으로 확인해 보면 PTE 의 가상 주소를 확인할 수 있고 System Pte 영역 안에 있음을 확인할 수 있습니다.
lkd> !pte b6946cdc
VA b6946cdc
PDE at 00000000C0300B68 PTE at 00000000C02DA518
Unable to get PDE FFFFFFFFC0300B68
kernel 에 load 되어 있는 module 을 살펴 보면 아래와 같은데 User 영역의 주소에 Map 되어 있는 파일은 일반 PTE 를 사용하고 Kernel 영역 주소에 Map 되어 있는 파일은 System PTEs 를 사용하는 것으로 보입니다.
lkd> lmvm tdi
start end module name
f7577000 f7582000 TDI (deferred)
Image path: \SystemRoot\system32\DRIVERS\TDI.SYS
Image name: TDI.SYS
Timestamp: Sat Feb 17 15:01:19 2007 (45D69A2F)
CheckSum: 0000C620
ImageSize: 0000B000
File version: 5.2.3790.3959
Product version: 5.2.3790.3959
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 3.6 Driver
File date: 00000000.00000000
Translations: 0409.04b0
CompanyName: Microsoft Corporation
ProductName: Microsoft® Windows® Operating System
InternalName: tdi.sys
OriginalFilename: tdi.sys
ProductVersion: 5.2.3790.3959
FileVersion: 5.2.3790.3959 (srv03_sp2_rtm.070216-1710)
FileDescription: TDI Wrapper
LegalCopyright: © Microsoft Corporation. All rights reserved.
이것 또한 System PTEs 영역에 위치하는 것을 확인할 수 있습니다.
lkd> !pte f7577000
VA f7577000
PDE at C0300F74 PTE at C03DD5DC
contains 00AAC963 contains 7D12E963
pfn aac -G-DA--KWEV pfn 7d12e -G-DA—KWEV
하지만 NT 와 HAL 은 다른 영역에 할당 됩니다.
80800000 80a7f000 nt
80a7f000 80aab000 hal
lkd> !pte 80800000
VA 80800000
PDE at C0300808 PTE at C0202000
contains 008009E3 contains 00000000
pfn 800 -GLDA--KWEV LARGE PAGE pfn 800
lkd> !pte 80a7f000
VA 80a7f000
PDE at C0300808 PTE at C02029FC
contains 008009E3 contains 00000000
pfn 800 -GLDA--KWEV LARGE PAGE pfn a7f
감사합니다.
Comments
Anonymous
October 03, 2010
위 예를 보면 Total System Ptes 4294967296 이라고 나오는데, 이게 bytes 인가요? 아니면 4k page인가요? system PTEs는 보통 4k page로 보이지않나요? 4294967296 라는 값은 마치 아래 계산에 의해 나온 것처럼 보입니다만: 1024 PTE's * 1024 PDE's * 4K each page = 4,294,967,296 bytesAnonymous
October 03, 2010
Total System Ptes 에 나온 결과는 Page 수 입니다. 이 포스트를 할때 Total System Ptes 의 값을 크게 신경쓰지 않았는데 일단 이 정보를 확인해 봐야 겠네요 아래 정보를 참고 하세요 3: kd> !sysptes System PTE Information Total System Ptes 33533440 starting PTE: fffff6fd30000000 free blocks: 1214 total free: 10211 largest free block: 155 3: kd> !vm 1 *** Virtual Memory Usage *** Physical Memory: 4193546 ( 16774184 Kb) Page File: ??C:pagefile.sys Current: 17081344 Kb Free Space: 17035420 Kb Minimum: 17081344 Kb Maximum: 17081344 Kb Available Pages: 3338870 ( 13355480 Kb) ResAvail Pages: 4028856 ( 16115424 Kb) Locked IO Pages: 0 ( 0 Kb) Free System PTEs: 33504239 ( 134016956 Kb)