Memory Management

Revision as of 02:22, 14 November 2008 by WillNewton (talk | contribs) (Additional Resources/Mailing Lists)
Jump to: navigation, search

This page has information about various memory management projects and activities which are of interest to embedded Linux developers.

Areas of Interest

Most of these areas have wider reaching implications, but are of relatively simpler in the embedded case, largely thanks to not having to contend with swap and things of that nature. Simpler memory management as well as vendors not afraid of deviation from mainline for product programs makes for an excellent playground for experimenting with new things in the memory management and virtual memory space.


  • This applies to both transparent large page usage as well as the more static usage models, primarily relating to work outside of the hugetlb interface/libhugetlbfs.
  • Embedded systems suffer from very small TLBs generally using PAGE_SIZE'd pages (4kB) for coverage. In most cases this places the system under very heavy pressure for any kind of userspace work, and very visibly degrading performance, with most applications taking anywhere from 5-40% of their time on the CPU servicing page faults.
  • Preliminary discussion on this subject as well as links to additional information is happening through the wiki here: Huge Pages

Page cache compression

  • This relates to using various compression algorithms for performing run-time compression and decompression of page cache pages, specifically aimed at both reducing memory pressure as well as helping performance in certain workloads.
  • More information can be found on the wiki here CompressedCaching as well as at the SF Compressed Caching home page.

Reserving (and accessing) the top of memory on startup

A quote from Todd's email on how to use the reserved physical memory in "mem=".

Given that you have a fixed address for your memory, and is already reserved, the easier way to use it is by calling mmap() over the /dev/ mem device, use 0 as the start address, and the physical address of the reserved memory as the offset. The flags could be MAP_WRITE| MAP_READ. That will return you a pointer on user space for your memory mapped by the kernel. For example

If your SDRAM base address is 0x80000000 and your memory is of 64MB, but you use the cmdline mem=60M to reserve 4MB at the end. Then your reserved memory will be at 0x83c00000, so all you need to do is

int fd;
char *reserved_memory;

fd = open("/dev/mem",O_RDWR);
reserved_memory = (char *) mmap(0,4*1024*1024,PROT_READ| PROT_WRITE,MAP_SHARED,fd,0x83c00000);

Additional Resources/Mailing Lists

  • LinuxMM - links to various sub-projects, and acts as a centralized point for discussion relating to memory management topics (linux-mm mailing list and archives).