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

标签 linux linux-kernel embedded-linux kmalloc

据我了解,GFP_USER 标志(在对kmalloc 的调用中)的使用用于为用户空间分配内存。这是否意味着分配的页面位于用户可以访问的内核空间中? 这些页面是否需要在用户空间中被 mmapp 编辑,或者地址是否可供用户直接访问。 如果他们需要 mmapp 那么 GFP_USERGFP_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/

相关文章:

c# - Linux相当于Direct draw

c - 在 Linux 内核中从 sk_buff 和 inode 获取 PID

linux - Linux 帧缓冲区驱动程序能否获得有关其内容的所有更改的通知?

linux - 如何保留 Linux 内核模块构建的 asm 输出

c++ - 预加载运算符删除释放大小

Python套接字: how to enable promiscuous mode in linux

linux - Linux 如何知道驱动程序中的延迟工作以及何时使用从硬件设备带来的数据?

c - 从旧的 init_timer 到新的 timer_setup 的适配

asp.net-mvc - 对 Mono XSP 托管 Web 应用程序的第一个浏览器请求出现巨大延迟

linux - Linux 内核中的 DECLARE_COMPLETION_ONSTACK 功能