Skip to content
Advertisement

Allocating physically contiguous pages in Kernel Module

I am trying to allocate physically contiguous pages in DRAM using the alloc_pages_exact function. When I try to allocate 10MB of pages, the returned address is always 0. But when I try to allocate 1MB of pages, the allocation is almost immediate. Also, can someone please tell me how to find the exact row size of DRAM? I had to search the datasheet of my RAM to figure it out. I was wondering if there is a command to determine the row size of DRAM. Earlier I thought that the System page size should be the DRAM row size as well, but the System page size turned out to be 4kB and my calculated row size came to be 8kB. Please help. Code:

JavaScript

Advertisement

Answer

The maximum size in pages supported by alloc_pages and family is 2 to the power of MAX_ORDER. MAX_ORDER is usually 11 unless overridden by the CONFIG_FORCE_MAX_ZONEORDER kernel configuration (which is only set for some architectures, and it may be manually configurable).

A MAX_ORDER value of 11 allows 2048 pages to be allocated, which for the most usual page size of 4096 allows a maximum allocation size of 8388608 (8 MiB).

I have no idea how to determine the DRAM row size, but it probably is not related to the system page size because the latter is determined by the architecture’s MMU (and is 4096 for most architectures).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement