据我所知,在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 07002 memory allocation policy.