gpt4 book ai didi

带有 MAP_POPULATE 的 Linux mmap(),手册页似乎提供了错误的信息

转载 作者:IT王子 更新时间:2023-10-29 00:31:35 29 4
gpt4 key购买 nike

在我看来,MAP_POPULATE 不仅仅用于私有(private)映射,这与手册页所说的相矛盾:

MAP_POPULATE (since Linux 2.5.46) Populate (prefault) page tables for a mapping. For a file mapping, this causes read-ahead on the file. Later accesses to the mapping will not be blocked by page faults. MAP_POPULATE is only supported for private mappings since Linux 2.6.23.

基于我对 mmap.c 的 Linux 内核源代码的粗略检查,看起来 MAP_POPULATEMAP_PRIVATEversions going back as far as 2.6.34 中完全没有关系.

这是来自 mmap.c 的最新代码的摘录从 3.14 内核实现开始:

...
1364 addr = mmap_region(file, addr, len, vm_flags, pgoff);
1365 if (!IS_ERR_VALUE(addr) &&
1366 ((vm_flags & VM_LOCKED) ||
1367 (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
1368 *populate = len;
1369 return addr;
...

我的观察有误吗?

最佳答案

自您提出问题后,措辞已更新:

Before: MAP_POPULATE is only supported for private mappings since Linux 2.6.23.
After: MAP_POPULATE is supported for private mappings only since Linux 2.6.23.

换句话说,您可以使用 MAP_POPULATE 进行私有(private)映射,但至少需要 Linux 2.6.23。

希望这能澄清它!

关于带有 MAP_POPULATE 的 Linux mmap(),手册页似乎提供了错误的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23502361/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com