c - Means to allocate contiguous physical memory -


i aware c malloc , posix_memaligh 1 can allocate contiguous memory virtual address space of process. however, wondering whether somehow 1 can allocate buffer of physically contiguous memory? investigating side channel attacks exploit l2 cache want sure can access right cache lines..

your best , easiest take @ continuous memory request single "huge" page system. availability of depends on cpu , kernel options (on x86_64 2mb huge pages available , cpus can 1gb pages; other architectures can more flexible this). check out hugepagesize field in /proc/meminfo size of huge pages on setup.

those can accessed in 2 ways:

  1. by means of map_hugetlb flag passed mmap(). way can sure "huge" virtual page corresponds continuous physical memory range. unfortunately, whether kernel can supply "huge" page depends on many factors (current layout of memory utilization, kernel options, etc - see hugepages kernel boot parameter).

  2. by means of mapping file dedicated hugetlb filesystem (see here: http://lwn.net/articles/375096/). hugetlb file system can configure number of huge pages available in advance assurance necessary amount of huge pages available.

the other approach write kernel module allocate continuous physical memory on kernel side , map process' address space on request. approach employed on special purpose hardware in embedded systems. of course, there's still no guarantee kernel side memory allocator able come appropriately sized continuous physical address range, on occasions such address ranges pre-reserved on boot (one dumb approach pass max_addr parameter kernel on boot leave of ram out of kernel's reach).


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -