使用MAP_FIXED时mmap addr是否需要页面对齐
Does mmap addr need to page aligned when using MAP_FIXED
的公认答案指出:
"So instead you first make a dummy mapping of the total length needed (the type of this mapping doesn't matter) without MAP_FIXED just to reserve a sufficient range of contiguous addresses at a kernel-assigned location, then you use MAP_FIXED to map over top of parts of this range as needed with the three or more mappings you need to create."
我的问题是:使用 MAP_FIXED 的后续 mmap 调用是否意味着覆盖保留的页面对齐范围,是否需要将页面对齐地址参数传递给 mmap?
mmap man page 有您需要的信息(强调我的):
MAP_FIXED
Don't interpret addr as a hint: place the mapping at exactly that address. addr must be suitably aligned: for most architectures a multiple of the page size is sufficient; however, some architectures may impose additional restrictions.
我的问题是:使用 MAP_FIXED 的后续 mmap 调用是否意味着覆盖保留的页面对齐范围,是否需要将页面对齐地址参数传递给 mmap?
mmap man page 有您需要的信息(强调我的):
MAP_FIXED
Don't interpret addr as a hint: place the mapping at exactly that address. addr must be suitably aligned: for most architectures a multiple of the page size is sufficient; however, some architectures may impose additional restrictions.