€•O©Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ./translations/zh_CN/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/zh_TW/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/it_IT/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ja_JP/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ko_KR/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/pt_BR/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/sp_SP/core-api/memory-allocation”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒtarget”“”)�”}”(hŒ.. _memory_allocation:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œmemory-allocation”uh1hµh´Khhh²hh³ŒH/var/lib/git/docbuild/linux/Documentation/core-api/memory-allocation.rst”ubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒMemory Allocation Guide”h]”hŒMemory Allocation Guide”…”�”}”(hhËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhhÆh²hh³hÃh´KubhŒ paragraph”“”)�”}”(hXzLinux provides a variety of APIs for memory allocation. You can allocate small chunks using `kmalloc` or `kmem_cache_alloc` families, large virtually contiguous areas using `vmalloc` and its derivatives, or you can directly request pages from the page allocator with `alloc_pages`. It is also possible to use more specialized allocators, for instance `cma_alloc` or `zs_malloc`.”h]”(hŒ\Linux provides a variety of APIs for memory allocation. You can allocate small chunks using ”…”�”}”(hhÛh²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hhåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒ or ”…”�”}”(hhÛh²hh³Nh´Nubhä)�”}”(hŒ`kmem_cache_alloc`”h]”hŒkmem_cache_alloc”…”�”}”(hh÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒ2 families, large virtually contiguous areas using ”…”�”}”(hhÛh²hh³Nh´Nubhä)�”}”(hŒ `vmalloc`”h]”hŒvmalloc”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒU and its derivatives, or you can directly request pages from the page allocator with ”…”�”}”(hhÛh²hh³Nh´Nubhä)�”}”(hŒ `alloc_pages`”h]”hŒ alloc_pages”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒG. It is also possible to use more specialized allocators, for instance ”…”�”}”(hhÛh²hh³Nh´Nubhä)�”}”(hŒ `cma_alloc`”h]”hŒ cma_alloc”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒ or ”…”�”}”hhÛsbhä)�”}”(hŒ `zs_malloc`”h]”hŒ zs_malloc”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhhÛubhŒ.”…”�”}”(hhÛh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhÚ)�”}”(hŒ¸Most of the memory allocation APIs use GFP flags to express how that memory should be allocated. The GFP acronym stands for "get free pages", the underlying memory allocation function.”h]”hŒ¼Most of the memory allocation APIs use GFP flags to express how that memory should be allocated. The GFP acronym stands for “get free pagesâ€�, the underlying memory allocation function.”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhÚ)�”}”(hŒµDiversity of the allocation APIs combined with the numerous GFP flags makes the question "How should I allocate memory?" not that easy to answer, although very likely you should use”h]”hŒ¹Diversity of the allocation APIs combined with the numerous GFP flags makes the question “How should I allocate memory?â€� not that easy to answer, although very likely you should use”…”�”}”(hjeh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhŒ literal_block”“”)�”}”(hŒkzalloc(, GFP_KERNEL);”h]”hŒkzalloc(, GFP_KERNEL);”…”�”}”hjusbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jsh³hÃh´KhhÆh²hubhÚ)�”}”(hŒZOf course there are cases when other allocation APIs and different GFP flags must be used.”h]”hŒZOf course there are cases when other allocation APIs and different GFP flags must be used.”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒGet Free Page flags”h]”hŒGet Free Page flags”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj“h²hh³hÃh´KubhÚ)�”}”(hX†The GFP flags control the allocators behavior. They tell what memory zones can be used, how hard the allocator should try to find free memory, whether the memory can be accessed by the userspace etc. The :ref:`Documentation/core-api/mm-api.rst ` provides reference documentation for the GFP flags and their combinations and here we briefly outline their recommended usage:”h]”(hŒÌThe GFP flags control the allocators behavior. They tell what memory zones can be used, how hard the allocator should try to find free memory, whether the memory can be accessed by the userspace etc. The ”…”�”}”(hj¤h²hh³Nh´Nubh)�”}”(hŒ;:ref:`Documentation/core-api/mm-api.rst `”h]”hŒinline”“”)�”}”(hj®h]”hŒ!Documentation/core-api/mm-api.rst”…”�”}”(hj²h²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j°hj¬ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œcore-api/memory-allocation”Œ refdomain”j½Œreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆŒ reftarget”Œmm-api-gfp-flags”uh1hh³hÃh´K hj¤ubhŒ provides reference documentation for the GFP flags and their combinations and here we briefly outline their recommended usage:”…”�”}”(hj¤h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K hj“h²hubhŒ block_quote”“”)�”}”(hX* Most of the time ``GFP_KERNEL`` is what you need. Memory for the kernel data structures, DMAable memory, inode cache, all these and many other allocations types can use ``GFP_KERNEL``. Note, that using ``GFP_KERNEL`` implies ``GFP_RECLAIM``, which means that direct reclaim may be triggered under memory pressure; the calling context must be allowed to sleep. * If the allocation is performed from an atomic context, e.g interrupt handler, use ``GFP_NOWAIT``. This flag prevents direct reclaim and IO or filesystem operations. Consequently, under memory pressure ``GFP_NOWAIT`` allocation is likely to fail. Users of this flag need to provide a suitable fallback to cope with such failures where appropriate. * If you think that accessing memory reserves is justified and the kernel will be stressed unless allocation succeeds, you may use ``GFP_ATOMIC``. * Untrusted allocations triggered from userspace should be a subject of kmem accounting and must have ``__GFP_ACCOUNT`` bit set. There is the handy ``GFP_KERNEL_ACCOUNT`` shortcut for ``GFP_KERNEL`` allocations that should be accounted. * Userspace allocations should use either of the ``GFP_USER``, ``GFP_HIGHUSER`` or ``GFP_HIGHUSER_MOVABLE`` flags. The longer the flag name the less restrictive it is. ``GFP_HIGHUSER_MOVABLE`` does not require that allocated memory will be directly accessible by the kernel and implies that the data is movable. ``GFP_HIGHUSER`` means that the allocated memory is not movable, but it is not required to be directly accessible by the kernel. An example may be a hardware allocation that maps data directly into userspace but has no addressing limitations. ``GFP_USER`` means that the allocated memory is not movable and it must be directly accessible by the kernel. ”h]”hŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hXgMost of the time ``GFP_KERNEL`` is what you need. Memory for the kernel data structures, DMAable memory, inode cache, all these and many other allocations types can use ``GFP_KERNEL``. Note, that using ``GFP_KERNEL`` implies ``GFP_RECLAIM``, which means that direct reclaim may be triggered under memory pressure; the calling context must be allowed to sleep.”h]”hÚ)�”}”(hXgMost of the time ``GFP_KERNEL`` is what you need. Memory for the kernel data structures, DMAable memory, inode cache, all these and many other allocations types can use ``GFP_KERNEL``. Note, that using ``GFP_KERNEL`` implies ``GFP_RECLAIM``, which means that direct reclaim may be triggered under memory pressure; the calling context must be allowed to sleep.”h]”(hŒMost of the time ”…”�”}”(hjìh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``GFP_KERNEL``”h]”hŒ GFP_KERNEL”…”�”}”(hjöh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjìubhŒŠ is what you need. Memory for the kernel data structures, DMAable memory, inode cache, all these and many other allocations types can use ”…”�”}”(hjìh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_KERNEL``”h]”hŒ GFP_KERNEL”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjìubhŒ. Note, that using ”…”�”}”(hjìh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_KERNEL``”h]”hŒ GFP_KERNEL”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjìubhŒ implies ”…”�”}”(hjìh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_RECLAIM``”h]”hŒ GFP_RECLAIM”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjìubhŒw, which means that direct reclaim may be triggered under memory pressure; the calling context must be allowed to sleep.”…”�”}”(hjìh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K'hjèubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjãubjç)�”}”(hXZIf the allocation is performed from an atomic context, e.g interrupt handler, use ``GFP_NOWAIT``. This flag prevents direct reclaim and IO or filesystem operations. Consequently, under memory pressure ``GFP_NOWAIT`` allocation is likely to fail. Users of this flag need to provide a suitable fallback to cope with such failures where appropriate.”h]”hÚ)�”}”(hXZIf the allocation is performed from an atomic context, e.g interrupt handler, use ``GFP_NOWAIT``. This flag prevents direct reclaim and IO or filesystem operations. Consequently, under memory pressure ``GFP_NOWAIT`` allocation is likely to fail. Users of this flag need to provide a suitable fallback to cope with such failures where appropriate.”h]”(hŒRIf the allocation is performed from an atomic context, e.g interrupt handler, use ”…”�”}”(hjNh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_NOWAIT``”h]”hŒ GFP_NOWAIT”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjNubhŒi. This flag prevents direct reclaim and IO or filesystem operations. Consequently, under memory pressure ”…”�”}”(hjNh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_NOWAIT``”h]”hŒ GFP_NOWAIT”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjNubhŒƒ allocation is likely to fail. Users of this flag need to provide a suitable fallback to cope with such failures where appropriate.”…”�”}”(hjNh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K-hjJubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjãubjç)�”}”(hŒ�If you think that accessing memory reserves is justified and the kernel will be stressed unless allocation succeeds, you may use ``GFP_ATOMIC``.”h]”hÚ)�”}”(hŒ�If you think that accessing memory reserves is justified and the kernel will be stressed unless allocation succeeds, you may use ``GFP_ATOMIC``.”h]”(hŒ�If you think that accessing memory reserves is justified and the kernel will be stressed unless allocation succeeds, you may use ”…”�”}”(hjŠh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_ATOMIC``”h]”hŒ GFP_ATOMIC”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjŠubhŒ.”…”�”}”(hjŠh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K3hj†ubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjãubjç)�”}”(hŒêUntrusted allocations triggered from userspace should be a subject of kmem accounting and must have ``__GFP_ACCOUNT`` bit set. There is the handy ``GFP_KERNEL_ACCOUNT`` shortcut for ``GFP_KERNEL`` allocations that should be accounted.”h]”hÚ)�”}”(hŒêUntrusted allocations triggered from userspace should be a subject of kmem accounting and must have ``__GFP_ACCOUNT`` bit set. There is the handy ``GFP_KERNEL_ACCOUNT`` shortcut for ``GFP_KERNEL`` allocations that should be accounted.”h]”(hŒdUntrusted allocations triggered from userspace should be a subject of kmem accounting and must have ”…”�”}”(hj´h²hh³Nh´Nubjõ)�”}”(hŒ``__GFP_ACCOUNT``”h]”hŒ __GFP_ACCOUNT”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj´ubhŒ bit set. There is the handy ”…”�”}”(hj´h²hh³Nh´Nubjõ)�”}”(hŒ``GFP_KERNEL_ACCOUNT``”h]”hŒGFP_KERNEL_ACCOUNT”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj´ubhŒ shortcut for ”…”�”}”(hj´h²hh³Nh´Nubjõ)�”}”(hŒ``GFP_KERNEL``”h]”hŒ GFP_KERNEL”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj´ubhŒ& allocations that should be accounted.”…”�”}”(hj´h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K5hj°ubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjãubjç)�”}”(hXšUserspace allocations should use either of the ``GFP_USER``, ``GFP_HIGHUSER`` or ``GFP_HIGHUSER_MOVABLE`` flags. The longer the flag name the less restrictive it is. ``GFP_HIGHUSER_MOVABLE`` does not require that allocated memory will be directly accessible by the kernel and implies that the data is movable. ``GFP_HIGHUSER`` means that the allocated memory is not movable, but it is not required to be directly accessible by the kernel. An example may be a hardware allocation that maps data directly into userspace but has no addressing limitations. ``GFP_USER`` means that the allocated memory is not movable and it must be directly accessible by the kernel. ”h]”(hÚ)�”}”(hŒ¥Userspace allocations should use either of the ``GFP_USER``, ``GFP_HIGHUSER`` or ``GFP_HIGHUSER_MOVABLE`` flags. The longer the flag name the less restrictive it is.”h]”(hŒ/Userspace allocations should use either of the ”…”�”}”(hjh²hh³Nh´Nubjõ)�”}”(hŒ ``GFP_USER``”h]”hŒGFP_USER”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhŒ, ”…”�”}”(hjh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_HIGHUSER``”h]”hŒ GFP_HIGHUSER”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhŒ or ”…”�”}”(hjh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_HIGHUSER_MOVABLE``”h]”hŒGFP_HIGHUSER_MOVABLE”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhŒ< flags. The longer the flag name the less restrictive it is.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K9hjþubhÚ)�”}”(hŒ�``GFP_HIGHUSER_MOVABLE`` does not require that allocated memory will be directly accessible by the kernel and implies that the data is movable.”h]”(jõ)�”}”(hŒ``GFP_HIGHUSER_MOVABLE``”h]”hŒGFP_HIGHUSER_MOVABLE”…”�”}”(hjJh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjFubhŒw does not require that allocated memory will be directly accessible by the kernel and implies that the data is movable.”…”�”}”(hjFh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K=hjþubhÚ)�”}”(hŒò``GFP_HIGHUSER`` means that the allocated memory is not movable, but it is not required to be directly accessible by the kernel. An example may be a hardware allocation that maps data directly into userspace but has no addressing limitations.”h]”(jõ)�”}”(hŒ``GFP_HIGHUSER``”h]”hŒ GFP_HIGHUSER”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjbubhŒâ means that the allocated memory is not movable, but it is not required to be directly accessible by the kernel. An example may be a hardware allocation that maps data directly into userspace but has no addressing limitations.”…”�”}”(hjbh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KAhjþubhÚ)�”}”(hŒm``GFP_USER`` means that the allocated memory is not movable and it must be directly accessible by the kernel.”h]”(jõ)�”}”(hŒ ``GFP_USER``”h]”hŒGFP_USER”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj~ubhŒa means that the allocated memory is not movable and it must be directly accessible by the kernel.”…”�”}”(hj~h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KFhjþubeh}”(h]”h ]”h"]”h$]”h&]”uh1jæhjãubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jáh³hÃh´K'hjÝubah}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³hÃh´K'hj“h²hubhÚ)�”}”(hXµYou may notice that quite a few allocations in the existing code specify ``GFP_NOIO`` or ``GFP_NOFS``. Historically, they were used to prevent recursion deadlocks caused by direct memory reclaim calling back into the FS or IO paths and blocking on already held resources. Since 4.12 the preferred way to address this issue is to use new scope APIs described in :ref:`Documentation/core-api/gfp_mask-from-fs-io.rst `.”h]”(hŒIYou may notice that quite a few allocations in the existing code specify ”…”�”}”(hj®h²hh³Nh´Nubjõ)�”}”(hŒ ``GFP_NOIO``”h]”hŒGFP_NOIO”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj®ubhŒ or ”…”�”}”(hj®h²hh³Nh´Nubjõ)�”}”(hŒ ``GFP_NOFS``”h]”hŒGFP_NOFS”…”�”}”(hjÈh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj®ubhX. Historically, they were used to prevent recursion deadlocks caused by direct memory reclaim calling back into the FS or IO paths and blocking on already held resources. Since 4.12 the preferred way to address this issue is to use new scope APIs described in ”…”�”}”(hj®h²hh³Nh´Nubh)�”}”(hŒK:ref:`Documentation/core-api/gfp_mask-from-fs-io.rst `”h]”j±)�”}”(hjÜh]”hŒ.Documentation/core-api/gfp_mask-from-fs-io.rst”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”(j¼Œstd”Œstd-ref”eh"]”h$]”h&]”uh1j°hjÚubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jÉŒ refdomain”jèŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆjÏŒgfp_mask_from_fs_io”uh1hh³hÃh´KIhj®ubhŒ.”…”�”}”(hj®h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KIhj“h²hubhÚ)�”}”(hX`Other legacy GFP flags are ``GFP_DMA`` and ``GFP_DMA32``. They are used to ensure that the allocated memory is accessible by hardware with limited addressing capabilities. So unless you are writing a driver for a device with such restrictions, avoid using these flags. And even with hardware with restrictions it is preferable to use `dma_alloc*` APIs.”h]”(hŒOther legacy GFP flags are ”…”�”}”(hjh²hh³Nh´Nubjõ)�”}”(hŒ ``GFP_DMA``”h]”hŒGFP_DMA”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhŒ and ”…”�”}”(hjh²hh³Nh´Nubjõ)�”}”(hŒ ``GFP_DMA32``”h]”hŒ GFP_DMA32”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhX. They are used to ensure that the allocated memory is accessible by hardware with limited addressing capabilities. So unless you are writing a driver for a device with such restrictions, avoid using these flags. And even with hardware with restrictions it is preferable to use ”…”�”}”(hjh²hh³Nh´Nubhä)�”}”(hŒ `dma_alloc*`”h]”hŒ dma_alloc*”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjubhŒ APIs.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KQhj“h²hubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒGFP flags and reclaim behavior”h]”hŒGFP flags and reclaim behavior”…”�”}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjHh²hh³hÃh´KYubhÚ)�”}”(hŒ£Memory allocations may trigger direct or background reclaim and it is useful to understand how hard the page allocator will try to satisfy that or another request.”h]”hŒ£Memory allocations may trigger direct or background reclaim and it is useful to understand how hard the page allocator will try to satisfy that or another request.”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KZhjHh²hubjÜ)�”}”(hX±* ``GFP_KERNEL & ~__GFP_RECLAIM`` - optimistic allocation without _any_ attempt to free memory at all. The most light weight mode which even doesn't kick the background reclaim. Should be used carefully because it might deplete the memory and the next user might hit the more aggressive reclaim. * ``GFP_KERNEL & ~__GFP_DIRECT_RECLAIM`` (or ``GFP_NOWAIT``)- optimistic allocation without any attempt to free memory from the current context but can wake kswapd to reclaim memory if the zone is below the low watermark. Can be used from either atomic contexts or when the request is a performance optimization and there is another fallback for a slow path. * ``(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM`` (aka ``GFP_ATOMIC``) - non sleeping allocation with an expensive fallback so it can access some portion of memory reserves. Usually used from interrupt/bottom-half context with an expensive slow path fallback. * ``GFP_KERNEL`` - both background and direct reclaim are allowed and the **default** page allocator behavior is used. That means that not costly allocation requests are basically no-fail but there is no guarantee of that behavior so failures have to be checked properly by callers (e.g. OOM killer victim is allowed to fail currently). * ``GFP_KERNEL | __GFP_NORETRY`` - overrides the default allocator behavior and all allocation requests fail early rather than cause disruptive reclaim (one round of reclaim in this implementation). The OOM killer is not invoked. * ``GFP_KERNEL | __GFP_RETRY_MAYFAIL`` - overrides the default allocator behavior and all allocation requests try really hard. The request will fail if the reclaim cannot make any progress. The OOM killer won't be triggered. * ``GFP_KERNEL | __GFP_NOFAIL`` - overrides the default allocator behavior and all allocation requests will loop endlessly until they succeed. This might be really dangerous especially for larger orders. ”h]”jâ)�”}”(hhh]”(jç)�”}”(hX&``GFP_KERNEL & ~__GFP_RECLAIM`` - optimistic allocation without _any_ attempt to free memory at all. The most light weight mode which even doesn't kick the background reclaim. Should be used carefully because it might deplete the memory and the next user might hit the more aggressive reclaim. ”h]”hÚ)�”}”(hX%``GFP_KERNEL & ~__GFP_RECLAIM`` - optimistic allocation without _any_ attempt to free memory at all. The most light weight mode which even doesn't kick the background reclaim. Should be used carefully because it might deplete the memory and the next user might hit the more aggressive reclaim.”h]”(jõ)�”}”(hŒ``GFP_KERNEL & ~__GFP_RECLAIM``”h]”hŒGFP_KERNEL & ~__GFP_RECLAIM”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjrubhX - optimistic allocation without _any_ attempt to free memory at all. The most light weight mode which even doesn’t kick the background reclaim. Should be used carefully because it might deplete the memory and the next user might hit the more aggressive reclaim.”…”�”}”(hjrh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K^hjnubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hXe``GFP_KERNEL & ~__GFP_DIRECT_RECLAIM`` (or ``GFP_NOWAIT``)- optimistic allocation without any attempt to free memory from the current context but can wake kswapd to reclaim memory if the zone is below the low watermark. Can be used from either atomic contexts or when the request is a performance optimization and there is another fallback for a slow path. ”h]”hÚ)�”}”(hXd``GFP_KERNEL & ~__GFP_DIRECT_RECLAIM`` (or ``GFP_NOWAIT``)- optimistic allocation without any attempt to free memory from the current context but can wake kswapd to reclaim memory if the zone is below the low watermark. Can be used from either atomic contexts or when the request is a performance optimization and there is another fallback for a slow path.”h]”(jõ)�”}”(hŒ&``GFP_KERNEL & ~__GFP_DIRECT_RECLAIM``”h]”hŒ"GFP_KERNEL & ~__GFP_DIRECT_RECLAIM”…”�”}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj˜ubhŒ (or ”…”�”}”(hj˜h²hh³Nh´Nubjõ)�”}”(hŒ``GFP_NOWAIT``”h]”hŒ GFP_NOWAIT”…”�”}”(hj®h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhj˜ubhX+)- optimistic allocation without any attempt to free memory from the current context but can wake kswapd to reclaim memory if the zone is below the low watermark. Can be used from either atomic contexts or when the request is a performance optimization and there is another fallback for a slow path.”…”�”}”(hj˜h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kdhj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hX``(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM`` (aka ``GFP_ATOMIC``) - non sleeping allocation with an expensive fallback so it can access some portion of memory reserves. Usually used from interrupt/bottom-half context with an expensive slow path fallback. ”h]”hÚ)�”}”(hX``(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM`` (aka ``GFP_ATOMIC``) - non sleeping allocation with an expensive fallback so it can access some portion of memory reserves. Usually used from interrupt/bottom-half context with an expensive slow path fallback.”h]”(jõ)�”}”(hŒ3``(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM``”h]”hŒ/(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjÐubhŒ (aka ”…”�”}”(hjÐh²hh³Nh´Nubjõ)�”}”(hŒ``GFP_ATOMIC``”h]”hŒ GFP_ATOMIC”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjÐubhŒ¾) - non sleeping allocation with an expensive fallback so it can access some portion of memory reserves. Usually used from interrupt/bottom-half context with an expensive slow path fallback.”…”�”}”(hjÐh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KkhjÌubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hXO``GFP_KERNEL`` - both background and direct reclaim are allowed and the **default** page allocator behavior is used. That means that not costly allocation requests are basically no-fail but there is no guarantee of that behavior so failures have to be checked properly by callers (e.g. OOM killer victim is allowed to fail currently). ”h]”hÚ)�”}”(hXN``GFP_KERNEL`` - both background and direct reclaim are allowed and the **default** page allocator behavior is used. That means that not costly allocation requests are basically no-fail but there is no guarantee of that behavior so failures have to be checked properly by callers (e.g. OOM killer victim is allowed to fail currently).”h]”(jõ)�”}”(hŒ``GFP_KERNEL``”h]”hŒ GFP_KERNEL”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjubhŒ: - both background and direct reclaim are allowed and the ”…”�”}”(hjh²hh³Nh´NubhŒstrong”“”)�”}”(hŒ **default**”h]”hŒdefault”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubhŒû page allocator behavior is used. That means that not costly allocation requests are basically no-fail but there is no guarantee of that behavior so failures have to be checked properly by callers (e.g. OOM killer victim is allowed to fail currently).”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kphjubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hŒä``GFP_KERNEL | __GFP_NORETRY`` - overrides the default allocator behavior and all allocation requests fail early rather than cause disruptive reclaim (one round of reclaim in this implementation). The OOM killer is not invoked. ”h]”hÚ)�”}”(hŒã``GFP_KERNEL | __GFP_NORETRY`` - overrides the default allocator behavior and all allocation requests fail early rather than cause disruptive reclaim (one round of reclaim in this implementation). The OOM killer is not invoked.”h]”(jõ)�”}”(hŒ``GFP_KERNEL | __GFP_NORETRY``”h]”hŒGFP_KERNEL | __GFP_NORETRY”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjBubhŒÅ - overrides the default allocator behavior and all allocation requests fail early rather than cause disruptive reclaim (one round of reclaim in this implementation). The OOM killer is not invoked.”…”�”}”(hjBh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kvhj>ubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hŒß``GFP_KERNEL | __GFP_RETRY_MAYFAIL`` - overrides the default allocator behavior and all allocation requests try really hard. The request will fail if the reclaim cannot make any progress. The OOM killer won't be triggered. ”h]”hÚ)�”}”(hŒÞ``GFP_KERNEL | __GFP_RETRY_MAYFAIL`` - overrides the default allocator behavior and all allocation requests try really hard. The request will fail if the reclaim cannot make any progress. The OOM killer won't be triggered.”h]”(jõ)�”}”(hŒ$``GFP_KERNEL | __GFP_RETRY_MAYFAIL``”h]”hŒ GFP_KERNEL | __GFP_RETRY_MAYFAIL”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjhubhŒ¼ - overrides the default allocator behavior and all allocation requests try really hard. The request will fail if the reclaim cannot make any progress. The OOM killer won’t be triggered.”…”�”}”(hjhh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K{hjdubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubjç)�”}”(hŒÊ``GFP_KERNEL | __GFP_NOFAIL`` - overrides the default allocator behavior and all allocation requests will loop endlessly until they succeed. This might be really dangerous especially for larger orders. ”h]”hÚ)�”}”(hŒÉ``GFP_KERNEL | __GFP_NOFAIL`` - overrides the default allocator behavior and all allocation requests will loop endlessly until they succeed. This might be really dangerous especially for larger orders.”h]”(jõ)�”}”(hŒ``GFP_KERNEL | __GFP_NOFAIL``”h]”hŒGFP_KERNEL | __GFP_NOFAIL”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jôhjŽubhŒ¬ - overrides the default allocator behavior and all allocation requests will loop endlessly until they succeed. This might be really dangerous especially for larger orders.”…”�”}”(hjŽh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K€hjŠubah}”(h]”h ]”h"]”h$]”h&]”uh1jæhjkubeh}”(h]”h ]”h"]”h$]”h&]”j¦j§uh1jáh³hÃh´K^hjgubah}”(h]”h ]”h"]”h$]”h&]”uh1jÛh³hÃh´K^hjHh²hubeh}”(h]”Œgfp-flags-and-reclaim-behavior”ah ]”h"]”Œgfp flags and reclaim behavior”ah$]”h&]”uh1hÄhj“h²hh³hÃh´KYubeh}”(h]”Œget-free-page-flags”ah ]”h"]”Œget free page flags”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´KubhÅ)�”}”(hhh]”(hÊ)�”}”(hŒSelecting memory allocator”h]”hŒSelecting memory allocator”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjÌh²hh³hÃh´K…ubhÚ)�”}”(hX˜The most straightforward way to allocate memory is to use a function from the kmalloc() family. And, to be on the safe side it's best to use routines that set memory to zero, like kzalloc(). If you need to allocate memory for an array, there are kmalloc_array() and kcalloc() helpers. The helpers struct_size(), array_size() and array3_size() can be used to safely calculate object sizes without overflowing.”h]”hXšThe most straightforward way to allocate memory is to use a function from the kmalloc() family. And, to be on the safe side it’s best to use routines that set memory to zero, like kzalloc(). If you need to allocate memory for an array, there are kmalloc_array() and kcalloc() helpers. The helpers struct_size(), array_size() and array3_size() can be used to safely calculate object sizes without overflowing.”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K‡hjÌh²hubhÚ)�”}”(hŒâThe maximal size of a chunk that can be allocated with `kmalloc` is limited. The actual limit depends on the hardware and the kernel configuration, but it is a good practice to use `kmalloc` for objects smaller than page size.”h]”(hŒ7The maximal size of a chunk that can be allocated with ”…”�”}”(hjëh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hjóh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjëubhŒu is limited. The actual limit depends on the hardware and the kernel configuration, but it is a good practice to use ”…”�”}”(hjëh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjëubhŒ$ for objects smaller than page size.”…”�”}”(hjëh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KŽhjÌh²hubhÚ)�”}”(hX6The address of a chunk allocated with `kmalloc` is aligned to at least ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the alignment is also guaranteed to be at least the respective size. For other sizes, the alignment is guaranteed to be at least the largest power-of-two divisor of the size.”h]”(hŒ&The address of a chunk allocated with ”…”�”}”(hjh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hj%h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjubhX is aligned to at least ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the alignment is also guaranteed to be at least the respective size. For other sizes, the alignment is guaranteed to be at least the largest power-of-two divisor of the size.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K“hjÌh²hubhÚ)�”}”(hŒ§Chunks allocated with kmalloc() can be resized with krealloc(). Similarly to kmalloc_array(): a helper for resizing arrays is provided in the form of krealloc_array().”h]”hŒ§Chunks allocated with kmalloc() can be resized with krealloc(). Similarly to kmalloc_array(): a helper for resizing arrays is provided in the form of krealloc_array().”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K™hjÌh²hubhÚ)�”}”(hŒÃFor large allocations you can use vmalloc() and vzalloc(), or directly request pages from the page allocator. The memory allocated by `vmalloc` and related functions is not physically contiguous.”h]”(hŒ†For large allocations you can use vmalloc() and vzalloc(), or directly request pages from the page allocator. The memory allocated by ”…”�”}”(hjKh²hh³Nh´Nubhä)�”}”(hŒ `vmalloc`”h]”hŒvmalloc”…”�”}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjKubhŒ4 and related functions is not physically contiguous.”…”�”}”(hjKh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K�hjÌh²hubhÚ)�”}”(hX³If you are not sure whether the allocation size is too large for `kmalloc`, it is possible to use kvmalloc() and its derivatives. It will try to allocate memory with `kmalloc` and if the allocation fails it will be retried with `vmalloc`. There are restrictions on which GFP flags can be used with `kvmalloc`; please see kvmalloc_node() reference documentation. Note that `kvmalloc` may return memory that is not physically contiguous.”h]”(hŒAIf you are not sure whether the allocation size is too large for ”…”�”}”(hjkh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjkubhŒ\, it is possible to use kvmalloc() and its derivatives. It will try to allocate memory with ”…”�”}”(hjkh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjkubhŒ5 and if the allocation fails it will be retried with ”…”�”}”(hjkh²hh³Nh´Nubhä)�”}”(hŒ `vmalloc`”h]”hŒvmalloc”…”�”}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjkubhŒ=. There are restrictions on which GFP flags can be used with ”…”�”}”(hjkh²hh³Nh´Nubhä)�”}”(hŒ `kvmalloc`”h]”hŒkvmalloc”…”�”}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjkubhŒ@; please see kvmalloc_node() reference documentation. Note that ”…”�”}”(hjkh²hh³Nh´Nubhä)�”}”(hŒ `kvmalloc`”h]”hŒkvmalloc”…”�”}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjkubhŒ5 may return memory that is not physically contiguous.”…”�”}”(hjkh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¡hjÌh²hubhÚ)�”}”(hX‹If you need to allocate many identical objects you can use the slab cache allocator. The cache should be set up with kmem_cache_create() or kmem_cache_create_usercopy() before it can be used. The second function should be used if a part of the cache might be copied to the userspace. After the cache is created kmem_cache_alloc() and its convenience wrappers can allocate memory from that cache.”h]”hX‹If you need to allocate many identical objects you can use the slab cache allocator. The cache should be set up with kmem_cache_create() or kmem_cache_create_usercopy() before it can be used. The second function should be used if a part of the cache might be copied to the userspace. After the cache is created kmem_cache_alloc() and its convenience wrappers can allocate memory from that cache.”…”�”}”(hjÓh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K©hjÌh²hubhÚ)�”}”(hŒ?When the allocated memory is no longer needed it must be freed.”h]”hŒ?When the allocated memory is no longer needed it must be freed.”…”�”}”(hjáh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K°hjÌh²hubhÚ)�”}”(hXObjects allocated by `kmalloc` can be freed by `kfree` or `kvfree`. Objects allocated by `kmem_cache_alloc` can be freed with `kmem_cache_free`, `kfree` or `kvfree`, where the latter two might be more convenient thanks to not needing the kmem_cache pointer.”h]”(hŒObjects allocated by ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ `kmalloc`”h]”hŒkmalloc”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ can be freed by ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kfree`”h]”hŒkfree”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ or ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kvfree`”h]”hŒkvfree”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ. Objects allocated by ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kmem_cache_alloc`”h]”hŒkmem_cache_alloc”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ can be freed with ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kmem_cache_free`”h]”hŒkmem_cache_free”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ, ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kfree`”h]”hŒkfree”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ or ”…”�”}”(hjïh²hh³Nh´Nubhä)�”}”(hŒ`kvfree`”h]”hŒkvfree”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhjïubhŒ], where the latter two might be more convenient thanks to not needing the kmem_cache pointer.”…”�”}”(hjïh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K²hjÌh²hubhÚ)�”}”(hŒDThe same rules apply to _bulk and _rcu flavors of freeing functions.”h]”hŒDThe same rules apply to _bulk and _rcu flavors of freeing functions.”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K·hjÌh²hubhÚ)�”}”(hXMemory allocated by `vmalloc` can be freed with `vfree` or `kvfree`. Memory allocated by `kvmalloc` can be freed with `kvfree`. Caches created by `kmem_cache_create` should be freed with `kmem_cache_destroy` only after freeing all the allocated objects first.”h]”(hŒMemory allocated by ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ `vmalloc`”h]”hŒvmalloc”…”�”}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ can be freed with ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ`vfree`”h]”hŒvfree”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ or ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ`kvfree`”h]”hŒkvfree”…”�”}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ. Memory allocated by ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ `kvmalloc`”h]”hŒkvmalloc”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ can be freed with ”…”�”}”hj‰sbhä)�”}”(hŒ`kvfree`”h]”hŒkvfree”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ. Caches created by ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ`kmem_cache_create`”h]”hŒkmem_cache_create”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ should be freed with ”…”�”}”(hj‰h²hh³Nh´Nubhä)�”}”(hŒ`kmem_cache_destroy`”h]”hŒkmem_cache_destroy”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hãhj‰ubhŒ4 only after freeing all the allocated objects first.”…”�”}”(hj‰h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¹hjÌh²hubeh}”(h]”Œselecting-memory-allocator”ah ]”h"]”Œselecting memory allocator”ah$]”h&]”uh1hÄhhÆh²hh³hÃh´K…ubeh}”(h]”(Œmemory-allocation-guide”hÂeh ]”h"]”(Œmemory allocation guide”Œmemory_allocation”eh$]”h&]”uh1hÄhhh²hh³hÃh´KŒexpect_referenced_by_name”}”j#h·sŒexpect_referenced_by_id”}”hÂh·subeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÃuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÉNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jMŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÃŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”hÂ]”h·asŒnameids”}”(j#hÂj"jjÉjÆjÁj¾jjuŒ nametypes”}”(j#ˆj"‰jɉjÁ‰j‰uh}”(hÂhÆjhÆjÆj“j¾jHjjÌuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)�”}”(hhh]”hÚ)�”}”(hhh]”hŒ7Hyperlink target "memory-allocation" is not referenced.”…”�”}”hj·sbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhj´ubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÃŒline”Kuh1j²ubaŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.