Thursday, June 2, 2011

Large and Small Pages

System make use of Large and Small pages for their individual merits. Although hardware these days are capable of supporting Page size as large as 1GB. But System assign an optimal size for Large and Small Page based on their performance results. For example on x86 Windows system, Small Pages are 4KB and Large Pages are 4MB (2MB on PAE systems).

Large page gives better performance as it make efficient use of TLB. When a byte is referred from a Large page its translation information is cached in TLB. This Cache will help efficiently accessing other bytes from that page next time.

On the down side, the memory protection are enforced at Page granularity. So for Large pages, many times Read only code and Read/Write data are mapped to a same page. This will relax the protection flag for this page to Read/Write. And any faulty or malicious program can write to Read only code mapped to this page and go undetected.

Windows configure their Page usage such that it can take advantage of both Large and Small pages. It maps core operating system images and data to the Large Pages. And User programs and data to Small pages. Although for debugging purpose, developer can override this behavior and run Driver Verifier to disable Large pages.

No comments:

Post a Comment