斗士狗 2018-11-05 05:57 采纳率: 0%
浏览 483

我们可以通过 mmap ()分配物理上的连续内存吗?

I need physically contiguous memory in aarch64 Linux 4.15 for an experimental purpose.

I guessed if the required size is smaller than the page size, the allocated memory may be physically contiguous as below.

void * p = mmap(0, getpagesize() - 1, PROT_READ | PROT_WRITE, MAP_SHARED, 0, 0);

After the allocation, I will identify its physical address by /proc/self/pagemap.

However I cannot find any documentation about this. Can I allocate physicall contiguous memory?

Thank you.

转载于:https://stackoverflow.com/questions/53149071/can-we-allocate-physically-contiguous-memory-by-mmap

  • 写回答

1条回答 默认 最新

  • csdnceshi62 2018-11-05 06:05
    关注

    You have very little control over physical memory locations. Within a page, the memory will be contiguous (it's more or less the definition of a page). But different pages that are contiguous in virtual address space need not be contiguous in the physical address space (and pages that are contiguous in the physical address space need not be contiguous in the virtual address space).

    Unless you are going to be working in the lowest levels of the kernel memory management, you're not going to be able to spot physical contiguity in a hurry.

    If the memory is dual-ported between Linux and something else, then you may have issues, but simply using mmap() won't resolve them.

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题