# Is page size always equal to frame size?

I'm learning about paging. My book says that the logical addresses generated by the CPU are in the form |p|d|(page number, page offset) and the physical addresses are in the form |f|d|(frame number, frame offset). It is also specifically mentioned that d i.e. the offset is copied directly to generate the physical address from the logical ones.

Now, commonsense says that if the offset is copied directly, the page size HAS to be equal to the frame size (otherwise, offsets wouldn't correspond). But unfortunately my book doesn't say anything about that.

So, is page size always equal to frame size?

A page is a region of virtual address space, and a page frame is a region of physical memory. A page which maps a region of physical memory must have the same size as that piece of physical memory, otherwise there's no point.

They also typically must be aligned correctly. If you try to map, say, a 2Mb page frame into virtual memory, both the virtual address and physical address must both be 2Mb aligned.

Many modern CPUs support more than one page size, and some can support different page sizes in the same address space. Current Intel x86-64, for example, supports 4kb, 2Mb and 1Gb page sizes. These numbers are not arbitrary; they represent the address space covered by different "levels" in the multilevel page table. Similarly, modern ARM supports 4kb, 64kb, and 1Mb pages, though ARM does not refer to the 1Mb pages as "pages" (they are "sections"). ARMv4 and ARMv5 supported splitting pages further into so-called "subpages"; these are no longer available in ARMv7.

Interestingly, there are a few other things that are often the same size as the page size. Obviously a TLB entry is the same size as a page or frame, since it's conceptually a cache for page table entries. However, L1 cache size is often determined by the page size, too.

Suppose the L1 cache is set-associative (a direct-mapped cache is really just a 1-way set associative cache, so you can think of this as a limiting case), then it's often convenient to make one "set" the size of a physical page. So suppose that the page size is 4kb, and the L1 cache is a 4-way set-associative cache, then the "best" size for the L1 cache is 16kb (which is four times 4kb). See if you can work out for yourself this might be the case.

yes page size must be equal to frame size in order to minimize the internal fragmentation of main memory.

• Note that some architectures support several page sizes simultaneously. – TEMLIB Sep 25 '15 at 19:27
• Can you elaborate? We prefer detailed answers that provide explanation, justification, or analysis. If the page size were not equal to the frame size, how would this cause increased internal fragmentation of main memory? Can you edit the answer to add an explanation of this? – D.W. Sep 26 '15 at 5:17
• The above answer with 1 upvote is absolutely wrong. Paging uses constant-size blocks of memory, and thus minimizes external fragmentation at the expense of internal, if the memory allocated is less than a page. So, I concluded that your O.S will be happier if you choose pageSize=frameSize. – Jignesh Kumar Apr 20 '18 at 19:56