gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 12:01:17 28 4
gpt4 key购买 nike

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

最佳答案

内核sources中可以找到简要说明:

GFP_KERNEL is typical for kernel-internal allocations. The callerrequires ZONE_NORMAL or a lower zone for direct access but can directreclaim.

GFP_USER is for userspace allocations that also need to be directlyaccessibly by the kernel or hardware. It is typically used by hardwarefor buffers that are mapped to userspace (e.g. graphics) that hardwarestill 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com