Computer Memory Page

A page, memory page, or virtual page is a fixed-length contiguous block of virtual memory, described by a single entry in a page table.

It is the smallest unit of data for memory management in an operating system that uses virtual memory. Similarly, a page frame is the smallest fixed-length contiguous block of physical memory into which memory pages are mapped by the operating system.

A transfer of pages between main memory and an auxiliary store, such as a hard disk drive, is referred to as paging or swapping.

Explanation

Computer memory is divided into pages so that information can be found more quickly.

The concept is named by analogy to the pages of a printed book. If a reader wanted to find, for example, the 5,000th word in the book, they could count from the first word. This would be time-consuming. It would be much faster if the reader had a listing of how many words are on each page. From this listing they could determine which page the 5,000th word appears on, and how many words to count on that page. This listing of the words per page of the book is analogous to a page table of a computer file system.

Page size

Page size trade-off

Page size is usually determined by the processor architecture. Traditionally, pages in a system had uniform size, such as 4,096 bytes. However, processor designs often allow two or more, sometimes simultaneous, page sizes due to its benefits. There are several points that can factor into choosing the best page size.

Page table size

A system with a smaller page size uses more pages, requiring a page table that occupies more space. For example, if a 232 virtual address space is mapped to 4 KiB (212 bytes) pages, the number of virtual pages is 220 = (232 / 212). However, if the page size is increased to 32 KiB (215 bytes), only 217 pages are required. A multi-level paging algorithm can decrease the memory cost of allocating a large page table for each process by further dividing the page table up into smaller tables, effectively paging the page table.

TLB usage

Since every access to memory must be mapped from virtual to physical address, reading the page table every time can be quite costly. Therefore, a very fast kind of cache, the translation lookaside buffer (TLB), is often used. The TLB is of limited size, and when it cannot satisfy a given request (a TLB miss) the page tables must be searched manually (either in hardware or software, depending on the architecture) for the correct mapping. Larger page sizes mean that a TLB cache of the same size can keep track of larger amounts of memory, which avoids the costly TLB misses.

Internal fragmentation

Rarely do processes require the use of an exact number of pages. As a result, the last page will likely only be partially full, wasting some amount of memory. Larger page sizes lead to a large amount of wasted memory, as more potentially unused portions of memory are loaded into the main memory. Smaller page sizes ensure a closer match to the actual amount of memory required in an allocation.

As an example, assume the page size is 1024 B. If a process allocates 1025 B, two pages must be used, resulting in 1023 B of unused space (where one page fully consumes 1024 B and the other only 1 B).

Disk access

When transferring from a rotational disk, much of the delay is caused by seek time, the time it takes to correctly position the read/write heads above the disk platters. Because of this, large sequential transfers are more efficient than several smaller transfers. Transferring the same amount of data from disk to memory often requires less time with larger pages than with smaller pages.

Getting page size programmatically

Most operating systems allow programs to discover the page size at runtime. This allows programs to use memory more efficiently by aligning allocations to this size and reducing overall internal fragmentation of pages.

Unix and POSIX-based operating systems

Unix and POSIX-based systems may use the system function sysconf(), as illustrated in the following example written in the C programming language.

#include  #include  /* sysconf(3) */  int main(void) { printf("The page size for this system is %ld bytes.\n", sysconf(_SC_PAGESIZE)); /* _SC_PAGE_SIZE is OK too. */  return 0; } 

In many Unix systems, the command-line utility getconf can be used. For example, getconf PAGESIZE will return the page size in bytes.

Windows-based operating systems

Win32-based operating systems, such as those in the Windows 9x and Windows NT families, may use the system function GetSystemInfo() from kernel32.dll.

#include  #include   int main(void) { SYSTEM_INFO si; GetSystemInfo(&si);  printf("The page size for this system is %u bytes.\n", si.dwPageSize);  return 0; } 

Multiple page sizes

Some instruction set architectures can support multiple page sizes, including pages significantly larger than the standard page size. The available page sizes depend on the instruction set architecture, processor type, and operating (addressing) mode. The operating system selects one or more sizes from the sizes supported by the architecture. Note that not all processors implement all defined larger page sizes. This support for larger pages (known as "huge pages" in Linux, "superpages" in FreeBSD, and "large pages" in Microsoft Windows and IBM AIX terminology) allows for "the best of both worlds", reducing the pressure on the TLB cache (sometimes increasing speed by as much as 15%) for large allocations while still keeping memory usage at a reasonable level for small allocations.

Page sizes among architectures
Architecture Smallest page size Larger page sizes
IA-32 (32-bit x86) 4 KiB MiB in PSE mode, 2 MiB in PAE mode
x86-64 4 KiB 2 MiB, 1 GiB (only when the CPU has PDPE1GB flag)
IA-64 (Itanium) 4 KiB 8 KiB, 64 KiB, 256 KiB, 1 MiB, 4 MiB, 16 MiB, 256 MiB
Power ISA 4 KiB 64 KiB, 16 MiB, 16 GiB
SPARC v8 with SPARC Reference MMU 4 KiB 256 KiB, 16 MiB
UltraSPARC Architecture 2007 8 KiB 64 KiB, 512 KiB (optional), 4 MiB, 32 MiB (optional), 256 MiB (optional), 2 GiB (optional), 16 GiB (optional)
ARMv7 4 KiB 64 KiB, 1 MiB ("section"), 16 MiB ("supersection") (defined by a particular implementation)
AArch64 4 KiB 16 KiB, 64 KiB, 2 MiB, 32 MiB, 512 MiB, 1 GiB
RISCV32 4 KiB 4 MiB ("megapage")
RISCV64 4 KiB 2 MiB ("megapage"), 1 GiB ("gigapage"), 512 GiB ("terapage", only for CPUs with 43-bit address space or more), 256 TiB ("petapage", only for CPUs with 57-bit address space or more),

Starting with the Pentium Pro, and the AMD Athlon, x86 processors support 4 MiB pages (called Page Size Extension) (2 MiB pages if using PAE) in addition to their standard 4 KiB pages; newer x86-64 processors, such as AMD's newer AMD64 processors and Intel's Westmere and later Xeon processors can use 1 GiB pages in long mode. IA-64 supports as many as eight different page sizes, from 4 KiB up to 256 MiB, and some other architectures have similar features.[specify]

Larger pages, despite being available in the processors used in most contemporary personal computers, are not in common use except in large-scale applications, the applications typically found in large servers and in computational clusters, and in the operating system itself. Commonly, their use requires elevated privileges, cooperation from the application making the large allocation (usually setting a flag to ask the operating system for huge pages), or manual administrator configuration; operating systems commonly, sometimes by design, cannot page them out to disk.

However, SGI IRIX has general-purpose support for multiple page sizes. Each individual process can provide hints and the operating system will automatically use the largest page size possible for a given region of address space. Later work proposed transparent operating system support for using a mix of page sizes for unmodified applications through preemptible reservations, opportunistic promotions, speculative demotions, and fragmentation control.

Linux has supported huge pages on several architectures since the 2.6 series via the hugetlbfs filesystem and without hugetlbfs since 2.6.38. Windows Server 2003 (SP1 and newer), Windows Vista and Windows Server 2008 support huge pages under the name of large pages. Windows 2000 and Windows XP support large pages internally, but do not expose them to applications. Beginning with version 9, Solaris supports large pages on SPARC and x86. FreeBSD 7.2-RELEASE features superpages. Note that until recently in Linux, applications needed to be modified in order to use huge pages. The 2.6.38 kernel introduced support for transparent use of huge pages. On Linux kernels supporting transparent huge pages, as well as FreeBSD and Solaris, applications take advantage of huge pages automatically, without the need for modification.

See also

References

Further reading

  • Dandamudi, Sivarama P. (2003). Fundamentals of Computer Organization and Design (1st ed.). Springer. pp. 740–741. ISBN 0-387-95211-X.

Tags:

Computer Memory Page ExplanationComputer Memory Page Page sizeComputer Memory Page Further readingComputer Memory PagePage tablePhysical memoryVirtual memory

🔥 Trending searches on Wiki English:

Wiki FoundationQuentin TarantinoJordan CameronKu Klux KlanJackie Chan2024 Indian general election in West BengalNullPete TownshendImaginary (film)The Bear (TV series)Narendra ModiMargaret QualleySama-BajauPriss FotheringhamPakistanVin DieselPhilippe TroussierXXXXRonald ReaganSeven deadly sinsThe First OmenNatalie PortmanNavneet Kaur RanaGeneration XJosh PeckChennai Super KingsTaiwanEdward VIIICincinnati riots of 1884Piyush ChawlaDark webPablo EscobarZach HymanThe Idea of YouRussell SimmonsEarthToyotomi HideyoshiThe Zone of Interest (film)I-35W Mississippi River bridgeDrag Me to HellFábián Marozsán2026 FIFA World Cup qualificationPier Gerlofs DoniaDrake BellX (2022 film)Anne WojcickiBianca CensoriHarvey WeinsteinNetherlandsThe Age of AdalineMike TysonLady GagaJack BlackUnited Arab EmiratesHazbin HotelNew York CityList of ethnic slursVinayak Damodar SavarkarMister SinisterLiam CunninghamAmanda BynesKalanithi MaranEasterLarry FinkTaylor SwiftRashida JonesDaphne du MaurierFrankie MunizAaron Taylor-JohnsonAmazon (company)Land of BadBody Cam (film)Generation ZSeptember 11 attacksCarlos Sainz Jr.2024 Indian general election in Tamil Nadu🡆 More