系统相关
首页 > 系统相关> > linux – kmalloc中GFP_USER标志的用途是什么?

linux – kmalloc中GFP_USER标志的用途是什么?

作者:互联网

据我所知,在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.

标签:linux,embedded-linux,linux-kernel,kmalloc
来源: https://codeday.me/bug/20191007/1866512.html