6.3. Noncontiguous Memory Area Management
We already know from an earlier discussion that it is preferable to map memory areas into sets of contiguous page frames, thus making better use of the cache and achieving lower average memory access times. Nevertheless, if the requests for memory areas are infrequent, it makes sense to consider an allocation schema based on noncontiguous page frames accessed through contiguous linear addresses. The main advantage of this schema is to avoid external fragmentation, while the disadvantage is that it is necessary to fiddle with the kernel page tables. Clearly, the size of a noncontiguous memory area must be a multiple of 4096. Linux uses noncontiguous memory areas sparingly, for instance, to allocate data structures for active swap areas (see Section 16.2.3 in Chapter 16), to allocate space for a module (see Appendix B), or to allocate buffers to some I/O drivers.
6.3.1. Linear Addresses of Noncontiguous Memory Areas
To find a free range of linear addresses, we can look in the area starting from PAGE_OFFSET (usually 0xc0000000, the beginning of the fourth gigabyte). We learned in the Chapter 2 in Section 2.5.4 that the kernel reserved this whole upper area of memory to map available RAM for kernel use. But available RAM occupies only a small fraction of the gigabyte, starting at the PAGE_OFFSET address. All the linear addresses above that reserved area are available for mapping noncontiguous memory areas. The linear address that corresponds ...
Get Understanding the Linux Kernel now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.