据我了解,GFP_USER
标志(在对kmalloc
的调用中)的使用用于为用户空间分配内存。这是否意味着分配的页面位于用户可以访问的内核空间中?
这些页面是否需要在用户空间中被 mmapp
编辑,或者地址是否可供用户直接访问。
如果他们需要 mmapp
那么 GFP_USER
和 GFP_KERNEL
有什么区别?
最佳答案
内核sources中可以找到简要说明:
GFP_KERNEL
is typical for kernel-internal allocations. The caller requires ZONE_NORMAL or a lower zone for direct access but can direct reclaim.
GFP_USER
is for userspace allocations that also need to be directly accessibly by the kernel or hardware. It is typically used by hardware for buffers that are mapped to userspace (e.g. graphics) that hardware still must DMA to. cpuset limits are enforced for these allocations.
#define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS)
#define GFP_USER (__GFP_RECLAIM | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
来自 here :
__GFP_HARDWALL enforces the cpuset memory allocation policy.
关于linux - kmalloc 中 GFP_USER 标志的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35217230/