Is memory management in the Linux Kernel done using paging or segmentation or both?

migrated from stackoverflow.com Mar 12 '11 at 23:14

This question came from our site for professional and enthusiast programmers.


Linux uses both. It uses segmentation to map all the available address space while giving different access rights: basically a kernel and a user space view. You can grep the Linux source code for KERNEL_DS (kernel data segment) for some examples.

Paging is then used for implementing virtual memory (Grep for "struct gdt_page" in the kernel, for a starting point)


Memory management under Linux works exclusively by paging.

Linux supports both "small" (usually 4kB) and "large" (2M) pages. The former "just work" without you knowing or doing anything special, and the latter need special treatment (have to be reserved at boot time and mapped via a special device).

The only context in which "segment" appears under Linux is the brk() syscall which is used to increase the data segment of a process (you will not normally need this, malloc does it without you having to care). But either way, the memory comes in pages and is managed in pages, and it has nothing to do with x86 segmentation.

  • X86 segmentation was obsolete when the i386 came out. Linux has never used segmentation for memory management. Some derivatives like ELKS and (possibly) uClinux might. – LawrenceC Mar 12 '11 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy