userfaultfd现在支持文件支持的地图吗? [英] Does userfaultfd now support file backed map?

查看:84
本文介绍了userfaultfd现在支持文件支持的地图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从userfaultfd的文档中看到了

I saw from the documentation of userfaultfd

https://manpages.debian.org/testing/manpages-dev/userfaultfd.2.en.html http://man7.org/linux/man-pages/man2/ioctl_userfaultfd.2.html

从内核4.11开始,userfaultfd将开始支持共享地图.但是,从某种程度上讲,该文档仍然看起来非常模棱两可,我仍然想知道这些功能是否包括支持文件支持的mmap(也可以是MAP_SHARED)?

that userfaultfd will start supporting shared map since kernel 4.11. However, the documentation still looks very ambiguous in the sense that I'm still wondering will these include supporting file-backed mmap (which can also be MAP_SHARED)?

推荐答案

要明确回答,由于该信息不在手册页中,因此我们可以查看源代码.

To answer definitively, since the information is not in the manual page(s), we can see the source.

尝试使用地址范围注册userfaultfd对象必须

Attempting to register a userfaultfd object with an address range must check whether that range is "compatible":

…
/* check not compatible vmas */
ret = -EINVAL;
if (!vma_can_userfault(cur))
    goto out_unlock;

兼容性定义是:

static inline bool vma_can_userfault(struct vm_area_struct *vma)
{
    return vma_is_anonymous(vma) || is_vm_hugetlb_page(vma) || vma_is_shmem(vma);
}

因此,只有匿名映射( vma_is_anonymous )或以下位置的映射:

Thus, only anonymous mappings (vma_is_anonymous), or mappings in:

  • tmpfs-支持,又名共享内存虚拟文件系统(tmpfs, shmget )映射
  • 禁用CONFIG_SHMEM时,也可以兼容已重新映射(使用 generic_file_mmap )作为共享的文件支持范围
  • tmpfs-backed, aka shared memory virtual filesystem (tmpfs, shmget) mappings are compatible
  • when CONFIG_SHMEM is disabled, file-backed ranges which have been remapped (with generic_file_mmap) as shared are also compatible

这篇关于userfaultfd现在支持文件支持的地图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆