€•QwŒ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-hotplug”Œ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-hotplug”Œ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-hotplug”Œ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-hotplug”Œ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-hotplug”Œ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-hotplug”Œ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_hotplug:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œmemory-hotplug”uh1h¡h KhhhžhhŸŒE/var/lib/git/docbuild/linux/Documentation/core-api/memory-hotplug.rst”ubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒMemory hotplug”h]”hŒMemory hotplug”…””}”(hh·hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hµhh²hžhhŸh¯h Kubh±)”}”(hhh]”(h¶)”}”(hŒMemory hotplug event notifier”h]”hŒMemory hotplug event notifier”…””}”(hhÈhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hµhhÅhžhhŸh¯h KubhŒ paragraph”“”)”}”(hŒ4Hotplugging events are sent to a notification queue.”h]”hŒ4Hotplugging events are sent to a notification queue.”…””}”(hhØhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K hhÅhžhubh±)”}”(hhh]”(h¶)”}”(hŒMemory notifier”h]”hŒMemory notifier”…””}”(hhéhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hµhhæhžhhŸh¯h K ubh×)”}”(hŒJThere are six types of notification defined in ``include/linux/memory.h``:”h]”(hŒ/There are six types of notification defined in ”…””}”(hh÷hžhhŸNh NubhŒliteral”“”)”}”(hŒ``include/linux/memory.h``”h]”hŒinclude/linux/memory.h”…””}”(hjhž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Œdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hŒ¿MEM_GOING_ONLINE Generated before new memory becomes available in order to be able to prepare subsystems to handle memory. The page allocator is still unable to allocate from the new memory. ”h]”(hŒterm”“”)”}”(hŒMEM_GOING_ONLINE”h]”hŒMEM_GOING_ONLINE”…””}”(hj&hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h Khj ubhŒ definition”“”)”}”(hhh]”h×)”}”(hŒ­Generated before new memory becomes available in order to be able to prepare subsystems to handle memory. The page allocator is still unable to allocate from the new memory.”h]”hŒ­Generated before new memory becomes available in order to be able to prepare subsystems to handle memory. The page allocator is still unable to allocate from the new memory.”…””}”(hj9hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Khj6ubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Khjubj)”}”(hŒ7MEM_CANCEL_ONLINE Generated if MEM_GOING_ONLINE fails. ”h]”(j%)”}”(hŒMEM_CANCEL_ONLINE”h]”hŒMEM_CANCEL_ONLINE”…””}”(hjWhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h KhjSubj5)”}”(hhh]”h×)”}”(hŒ$Generated if MEM_GOING_ONLINE fails.”h]”hŒ$Generated if MEM_GOING_ONLINE fails.”…””}”(hjhhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Khjeubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjSubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Khjhžhubj)”}”(hŒwMEM_ONLINE Generated when memory has successfully brought online. The callback may allocate pages from the new memory. ”h]”(j%)”}”(hŒ MEM_ONLINE”h]”hŒ MEM_ONLINE”…””}”(hj†hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h Khj‚ubj5)”}”(hhh]”h×)”}”(hŒkGenerated when memory has successfully brought online. The callback may allocate pages from the new memory.”h]”hŒkGenerated when memory has successfully brought online. The callback may allocate pages from the new memory.”…””}”(hj—hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Khj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj‚ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Khjhžhubj)”}”(hXMEM_GOING_OFFLINE Generated to begin the process of offlining memory. Allocations are no longer possible from the memory but some of the memory to be offlined is still in use. The callback can be used to free memory known to a subsystem from the indicated memory block. ”h]”(j%)”}”(hŒMEM_GOING_OFFLINE”h]”hŒMEM_GOING_OFFLINE”…””}”(hjµhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h K!hj±ubj5)”}”(hhh]”h×)”}”(hŒûGenerated to begin the process of offlining memory. Allocations are no longer possible from the memory but some of the memory to be offlined is still in use. The callback can be used to free memory known to a subsystem from the indicated memory block.”h]”hŒûGenerated to begin the process of offlining memory. Allocations are no longer possible from the memory but some of the memory to be offlined is still in use. The callback can be used to free memory known to a subsystem from the indicated memory block.”…””}”(hjÆhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KhjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj±ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h K!hjhžhubj)”}”(hŒ‡MEM_CANCEL_OFFLINE Generated if MEM_GOING_OFFLINE fails. Memory is available again from the memory block that we attempted to offline. ”h]”(j%)”}”(hŒMEM_CANCEL_OFFLINE”h]”hŒMEM_CANCEL_OFFLINE”…””}”(hjähžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h K%hjàubj5)”}”(hhh]”h×)”}”(hŒsGenerated if MEM_GOING_OFFLINE fails. Memory is available again from the memory block that we attempted to offline.”h]”hŒsGenerated if MEM_GOING_OFFLINE fails. Memory is available again from the memory block that we attempted to offline.”…””}”(hjõhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K$hjòubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjàubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h K%hjhžhubj)”}”(hŒ:MEM_OFFLINE Generated after offlining memory is complete. ”h]”(j%)”}”(hŒ MEM_OFFLINE”h]”hŒ MEM_OFFLINE”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h K(hjubj5)”}”(hhh]”h×)”}”(hŒ-Generated after offlining memory is complete.”h]”hŒ-Generated after offlining memory is complete.”…””}”(hj$hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K(hj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h K(hjhžhubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhæhžhhŸh¯h Nubh×)”}”(hŒ1A callback routine can be registered by calling::”h]”hŒ0A callback routine can be registered by calling:”…””}”(hjDhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K*hhæhžhubhŒ literal_block”“”)”}”(hŒ0hotplug_memory_notifier(callback_func, priority)”h]”hŒ0hotplug_memory_notifier(callback_func, priority)”…””}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jRhŸh¯h K,hhæhžhubh×)”}”(hŒiCallback functions with higher values of priority are called before callback functions with lower values.”h]”hŒiCallback functions with higher values of priority are called before callback functions with lower values.”…””}”(hjdhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K.hhæhžhubh×)”}”(hŒ7A callback function must have the following prototype::”h]”hŒ6A callback function must have the following prototype:”…””}”(hjrhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K1hhæhžhubjS)”}”(hŒSint callback_func( struct notifier_block *self, unsigned long action, void *arg);”h]”hŒSint callback_func( struct notifier_block *self, unsigned long action, void *arg);”…””}”hj€sbah}”(h]”h ]”h"]”h$]”h&]”jbjcuh1jRhŸh¯h K3hhæhžhubh×)”}”(hXThe first argument of the callback function (self) is a pointer to the block of the notifier chain that points to the callback function itself. The second argument (action) is one of the event types described above. The third argument (arg) passes a pointer of struct memory_notify::”h]”hXThe first argument of the callback function (self) is a pointer to the block of the notifier chain that points to the callback function itself. The second argument (action) is one of the event types described above. The third argument (arg) passes a pointer of struct memory_notify:”…””}”(hjŽhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K6hhæhžhubjS)”}”(hŒYstruct memory_notify { unsigned long start_pfn; unsigned long nr_pages; }”h]”hŒYstruct memory_notify { unsigned long start_pfn; unsigned long nr_pages; }”…””}”hjœsbah}”(h]”h ]”h"]”h$]”h&]”jbjcuh1jRhŸh¯h K;hhæhžhubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ0start_pfn is start_pfn of online/offline memory.”h]”h×)”}”(hj³h]”hŒ0start_pfn is start_pfn of online/offline memory.”…””}”(hjµhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K@hj±ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hj¬hžhhŸh¯h Nubj°)”}”(hŒ1nr_pages is # of pages of online/offline memory. ”h]”h×)”}”(hŒ0nr_pages is # of pages of online/offline memory.”h]”hŒ0nr_pages is # of pages of online/offline memory.”…””}”(hjÌhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KAhjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hj¬hžhhŸh¯h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jªhŸh¯h K@hhæhžhubh×)”}”(hX˜It is possible to get notified for MEM_CANCEL_ONLINE without having been notified for MEM_GOING_ONLINE, and the same applies to MEM_CANCEL_OFFLINE and MEM_GOING_OFFLINE. This can happen when a consumer fails, meaning we break the callchain and we stop calling the remaining consumers of the notifier. It is then important that users of memory_notify make no assumptions and get prepared to handle such cases.”h]”hX˜It is possible to get notified for MEM_CANCEL_ONLINE without having been notified for MEM_GOING_ONLINE, and the same applies to MEM_CANCEL_OFFLINE and MEM_GOING_OFFLINE. This can happen when a consumer fails, meaning we break the callchain and we stop calling the remaining consumers of the notifier. It is then important that users of memory_notify make no assumptions and get prepared to handle such cases.”…””}”(hjèhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KChhæhžhubh×)”}”(hŒ‹The callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP defined in ``include/linux/notifier.h``”h]”(hŒoThe callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP defined in ”…””}”(hjöhžhhŸNh Nubj)”}”(hŒ``include/linux/notifier.h``”h]”hŒinclude/linux/notifier.h”…””}”(hjþhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÿhjöubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KKhhæhžhubh×)”}”(hŒCNOTIFY_DONE and NOTIFY_OK have no effect on the further processing.”h]”hŒCNOTIFY_DONE and NOTIFY_OK have no effect on the further processing.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KOhhæhžhubh×)”}”(hŒºNOTIFY_BAD is used as response to the MEM_GOING_ONLINE, MEM_GOING_OFFLINE, MEM_ONLINE, or MEM_OFFLINE action to cancel hotplugging. It stops further processing of the notification queue.”h]”hŒºNOTIFY_BAD is used as response to the MEM_GOING_ONLINE, MEM_GOING_OFFLINE, MEM_ONLINE, or MEM_OFFLINE action to cancel hotplugging. It stops further processing of the notification queue.”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KQhhæhžhubh×)”}”(hŒ?NOTIFY_STOP stops further processing of the notification queue.”h]”hŒ?NOTIFY_STOP stops further processing of the notification queue.”…””}”(hj.hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KUhhæhžhubeh}”(h]”Œmemory-notifier”ah ]”h"]”Œmemory notifier”ah$]”h&]”uh1h°hhÅhžhhŸh¯h K ubh±)”}”(hhh]”(h¶)”}”(hŒNuma node notifier”h]”hŒNuma node notifier”…””}”(hjGhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hµhjDhžhhŸh¯h KXubh×)”}”(hŒHThere are six types of notification defined in ``include/linux/node.h``:”h]”(hŒ/There are six types of notification defined in ”…””}”(hjUhžhhŸNh Nubj)”}”(hŒ``include/linux/node.h``”h]”hŒinclude/linux/node.h”…””}”(hj]hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÿhjUubhŒ:”…””}”(hjUhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KZhjDhžhubj)”}”(hhh]”(j)”}”(hŒdNODE_ADDING_FIRST_MEMORY Generated before memory becomes available to this node for the first time. ”h]”(j%)”}”(hŒNODE_ADDING_FIRST_MEMORY”h]”hŒNODE_ADDING_FIRST_MEMORY”…””}”(hj|hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h K]hjxubj5)”}”(hhh]”h×)”}”(hŒJGenerated before memory becomes available to this node for the first time.”h]”hŒJGenerated before memory becomes available to this node for the first time.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K]hjŠubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjxubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h K]hjuubj)”}”(hŒMNODE_CANCEL_ADDING_FIRST_MEMORY Generated if NODE_ADDING_FIRST_MEMORY fails. ”h]”(j%)”}”(hŒNODE_CANCEL_ADDING_FIRST_MEMORY”h]”hŒNODE_CANCEL_ADDING_FIRST_MEMORY”…””}”(hj«hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h K`hj§ubj5)”}”(hhh]”h×)”}”(hŒ,Generated if NODE_ADDING_FIRST_MEMORY fails.”h]”hŒ,Generated if NODE_ADDING_FIRST_MEMORY fails.”…””}”(hj¼hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K`hj¹ubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj§ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h K`hjuhžhubj)”}”(hŒdNODE_ADDED_FIRST_MEMORY Generated when memory has become available fo this node for the first time. ”h]”(j%)”}”(hŒNODE_ADDED_FIRST_MEMORY”h]”hŒNODE_ADDED_FIRST_MEMORY”…””}”(hjÚhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h KchjÖubj5)”}”(hhh]”h×)”}”(hŒKGenerated when memory has become available fo this node for the first time.”h]”hŒKGenerated when memory has become available fo this node for the first time.”…””}”(hjëhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Kchjèubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjÖubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Kchjuhžhubj)”}”(hŒiNODE_REMOVING_LAST_MEMORY Generated when the last memory available to this node is about to be offlined. ”h]”(j%)”}”(hŒNODE_REMOVING_LAST_MEMORY”h]”hŒNODE_REMOVING_LAST_MEMORY”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h Kfhjubj5)”}”(hhh]”h×)”}”(hŒNGenerated when the last memory available to this node is about to be offlined.”h]”hŒNGenerated when the last memory available to this node is about to be offlined.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Kfhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Kfhjuhžhubj)”}”(hŒXNODE_CANCEL_REMOVING_LAST_MEMORY Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails. ”h]”(j%)”}”(hŒ NODE_CANCEL_REMOVING_LAST_MEMORY”h]”hŒ NODE_CANCEL_REMOVING_LAST_MEMORY”…””}”(hj8hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h Kihj4ubj5)”}”(hhh]”h×)”}”(hŒ6Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails.”h]”hŒ6Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails.”…””}”(hjIhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KihjFubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj4ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Kihjuhžhubj)”}”(hŒbNODE_REMOVED_LAST_MEMORY Generated when the last memory available to this node has been offlined. ”h]”(j%)”}”(hŒNODE_REMOVED_LAST_MEMORY”h]”hŒNODE_REMOVED_LAST_MEMORY”…””}”(hjghžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j$hŸh¯h Klhjcubj5)”}”(hhh]”h×)”}”(hŒHGenerated when the last memory available to this node has been offlined.”h]”hŒHGenerated when the last memory available to this node has been offlined.”…””}”(hjxhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h Klhjuubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjcubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh¯h Klhjuhžhubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjDhžhhŸh¯h Nubh×)”}”(hŒ1A callback routine can be registered by calling::”h]”hŒ0A callback routine can be registered by calling:”…””}”(hj˜hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KnhjDhžhubjS)”}”(hŒ.hotplug_node_notifier(callback_func, priority)”h]”hŒ.hotplug_node_notifier(callback_func, priority)”…””}”hj¦sbah}”(h]”h ]”h"]”h$]”h&]”jbjcuh1jRhŸh¯h KphjDhžhubh×)”}”(hŒiCallback functions with higher values of priority are called before callback functions with lower values.”h]”hŒiCallback functions with higher values of priority are called before callback functions with lower values.”…””}”(hj´hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KrhjDhžhubh×)”}”(hŒ7A callback function must have the following prototype::”h]”hŒ6A callback function must have the following prototype:”…””}”(hjÂhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KuhjDhžhubjS)”}”(hŒTint callback_func( struct notifier_block *self, unsigned long action, void *arg);”h]”hŒTint callback_func( struct notifier_block *self, unsigned long action, void *arg);”…””}”hjÐsbah}”(h]”h ]”h"]”h$]”h&]”jbjcuh1jRhŸh¯h KwhjDhžhubh×)”}”(hXThe first argument of the callback function (self) is a pointer to the block of the notifier chain that points to the callback function itself. The second argument (action) is one of the event types described above. The third argument (arg) passes a pointer of struct node_notify::”h]”hXThe first argument of the callback function (self) is a pointer to the block of the notifier chain that points to the callback function itself. The second argument (action) is one of the event types described above. The third argument (arg) passes a pointer of struct node_notify:”…””}”(hjÞhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K{hjDhžhubjS)”}”(hŒ'struct node_notify { int nid; }”h]”hŒ'struct node_notify { int nid; }”…””}”hjìsbah}”(h]”h ]”h"]”h$]”h&]”jbjcuh1jRhŸh¯h K€hjDhžhubj«)”}”(hhh]”j°)”}”(hŒ5nid is the node we are adding or removing memory to. ”h]”h×)”}”(hŒ4nid is the node we are adding or removing memory to.”h]”hŒ4nid is the node we are adding or removing memory to.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K„hjýubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hjúhžhhŸh¯h Nubah}”(h]”h ]”h"]”h$]”h&]”jæjçuh1jªhŸh¯h K„hjDhžhubh×)”}”(hXÂIt is possible to get notified for NODE_CANCEL_ADDING_FIRST_MEMORY without having been notified for NODE_ADDING_FIRST_MEMORY, and the same applies to NODE_CANCEL_REMOVING_LAST_MEMORY and NODE_REMOVING_LAST_MEMORY. This can happen when a consumer fails, meaning we break the callchain and we stop calling the remaining consumers of the notifier. It is then important that users of node_notify make no assumptions and get prepared to handle such cases.”h]”hXÂIt is possible to get notified for NODE_CANCEL_ADDING_FIRST_MEMORY without having been notified for NODE_ADDING_FIRST_MEMORY, and the same applies to NODE_CANCEL_REMOVING_LAST_MEMORY and NODE_REMOVING_LAST_MEMORY. This can happen when a consumer fails, meaning we break the callchain and we stop calling the remaining consumers of the notifier. It is then important that users of node_notify make no assumptions and get prepared to handle such cases.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K†hjDhžhubh×)”}”(hŒ‹The callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP defined in ``include/linux/notifier.h``”h]”(hŒoThe callback routine shall return one of the values NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP defined in ”…””}”(hj)hžhhŸNh Nubj)”}”(hŒ``include/linux/notifier.h``”h]”hŒinclude/linux/notifier.h”…””}”(hj1hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÿhj)ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KŽhjDhžhubh×)”}”(hŒCNOTIFY_DONE and NOTIFY_OK have no effect on the further processing.”h]”hŒCNOTIFY_DONE and NOTIFY_OK have no effect on the further processing.”…””}”(hjEhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K’hjDhžhubh×)”}”(hŒãNOTIFY_BAD is used as response to the NODE_ADDING_FIRST_MEMORY, NODE_REMOVING_LAST_MEMORY, NODE_ADDED_FIRST_MEMORY or NODE_REMOVED_LAST_MEMORY action to cancel hotplugging. It stops further processing of the notification queue.”h]”hŒãNOTIFY_BAD is used as response to the NODE_ADDING_FIRST_MEMORY, NODE_REMOVING_LAST_MEMORY, NODE_ADDED_FIRST_MEMORY or NODE_REMOVED_LAST_MEMORY action to cancel hotplugging. It stops further processing of the notification queue.”…””}”(hjShžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K”hjDhžhubh×)”}”(hŒ?NOTIFY_STOP stops further processing of the notification queue.”h]”hŒ?NOTIFY_STOP stops further processing of the notification queue.”…””}”(hjahžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K™hjDhžhubh×)”}”(hŒšPlease note that we should not fail for NODE_ADDED_FIRST_MEMORY / NODE_REMOVED_FIRST_MEMORY, as memory_hotplug code cannot rollback at that point anymore.”h]”hŒšPlease note that we should not fail for NODE_ADDED_FIRST_MEMORY / NODE_REMOVED_FIRST_MEMORY, as memory_hotplug code cannot rollback at that point anymore.”…””}”(hjohžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K›hjDhžhubeh}”(h]”Œnuma-node-notifier”ah ]”h"]”Œnuma node notifier”ah$]”h&]”uh1h°hhÅhžhhŸh¯h KXubeh}”(h]”Œmemory-hotplug-event-notifier”ah ]”h"]”Œmemory hotplug event notifier”ah$]”h&]”uh1h°hh²hžhhŸh¯h Kubh±)”}”(hhh]”(h¶)”}”(hŒLocking Internals”h]”hŒLocking Internals”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hµhjhžhhŸh¯h K ubh×)”}”(hŒzWhen adding/removing memory that uses memory block devices (i.e. ordinary RAM), the device_hotplug_lock should be held to:”h]”hŒzWhen adding/removing memory that uses memory block devices (i.e. ordinary RAM), the device_hotplug_lock should be held to:”…””}”(hjžhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K¢hjhžhubj«)”}”(hhh]”(j°)”}”(hŒÿsynchronize against online/offline requests (e.g. via sysfs). This way, memory block devices can only be accessed (.online/.state attributes) by user space once memory has been fully added. And when removing memory, we know nobody is in critical sections.”h]”h×)”}”(hŒÿsynchronize against online/offline requests (e.g. via sysfs). This way, memory block devices can only be accessed (.online/.state attributes) by user space once memory has been fully added. And when removing memory, we know nobody is in critical sections.”h]”hŒÿsynchronize against online/offline requests (e.g. via sysfs). This way, memory block devices can only be accessed (.online/.state attributes) by user space once memory has been fully added. And when removing memory, we know nobody is in critical sections.”…””}”(hj³hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K¥hj¯ubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hj¬hžhhŸh¯h Nubj°)”}”(hŒMsynchronize against CPU hotplug and similar (e.g. relevant for ACPI and PPC) ”h]”h×)”}”(hŒLsynchronize against CPU hotplug and similar (e.g. relevant for ACPI and PPC)”h]”hŒLsynchronize against CPU hotplug and similar (e.g. relevant for ACPI and PPC)”…””}”(hjËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K©hjÇubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hj¬hžhhŸh¯h Nubeh}”(h]”h ]”h"]”h$]”h&]”jæjçuh1jªhŸh¯h K¥hjhžhubh×)”}”(hŒ¬Especially, there is a possible lock inversion that is avoided using device_hotplug_lock when adding memory and user space tries to online that memory faster than expected:”h]”hŒ¬Especially, there is a possible lock inversion that is avoided using device_hotplug_lock when adding memory and user space tries to online that memory faster than expected:”…””}”(hjåhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K«hjhžhubj«)”}”(hhh]”(j°)”}”(hŒOdevice_online() will first take the device_lock(), followed by mem_hotplug_lock”h]”h×)”}”(hŒOdevice_online() will first take the device_lock(), followed by mem_hotplug_lock”h]”hŒOdevice_online() will first take the device_lock(), followed by mem_hotplug_lock”…””}”(hjúhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K¯hjöubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hjóhžhhŸh¯h Nubj°)”}”(hŒ‘add_memory_resource() will first take the mem_hotplug_lock, followed by the device_lock() (while creating the devices, during bus_add_device()). ”h]”h×)”}”(hŒadd_memory_resource() will first take the mem_hotplug_lock, followed by the device_lock() (while creating the devices, during bus_add_device()).”h]”hŒadd_memory_resource() will first take the mem_hotplug_lock, followed by the device_lock() (while creating the devices, during bus_add_device()).”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K±hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j¯hjóhžhhŸh¯h Nubeh}”(h]”h ]”h"]”h$]”h&]”jæjçuh1jªhŸh¯h K¯hjhžhubh×)”}”(hŒlAs the device is visible to user space before taking the device_lock(), this can result in a lock inversion.”h]”hŒlAs the device is visible to user space before taking the device_lock(), this can result in a lock inversion.”…””}”(hj,hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K´hjhžhubh×)”}”(hŒ×onlining/offlining of memory should be done via device_online()/ device_offline() - to make sure it is properly synchronized to actions via sysfs. Holding device_hotplug_lock is advised (to e.g. protect online_type)”h]”hŒ×onlining/offlining of memory should be done via device_online()/ device_offline() - to make sure it is properly synchronized to actions via sysfs. Holding device_hotplug_lock is advised (to e.g. protect online_type)”…””}”(hj:hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K·hjhžhubh×)”}”(hŒÛWhen adding/removing/onlining/offlining memory or adding/removing heterogeneous/device memory, we should always hold the mem_hotplug_lock in write mode to serialise memory hotplug (e.g. access to global/zone variables).”h]”hŒÛWhen adding/removing/onlining/offlining memory or adding/removing heterogeneous/device memory, we should always hold the mem_hotplug_lock in write mode to serialise memory hotplug (e.g. access to global/zone variables).”…””}”(hjHhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h K»hjhžhubh×)”}”(hŒÝIn addition, mem_hotplug_lock (in contrast to device_hotplug_lock) in read mode allows for a quite efficient get_online_mems/put_online_mems implementation, so code accessing memory can protect from that memory vanishing.”h]”hŒÝIn addition, mem_hotplug_lock (in contrast to device_hotplug_lock) in read mode allows for a quite efficient get_online_mems/put_online_mems implementation, so code accessing memory can protect from that memory vanishing.”…””}”(hjVhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhŸh¯h KÀhjhžhubeh}”(h]”Œlocking-internals”ah ]”h"]”Œlocking internals”ah$]”h&]”uh1h°hh²hžhhŸh¯h K ubeh}”(h]”(h®Œid1”eh ]”h"]”(Œmemory hotplug”Œmemory_hotplug”eh$]”h&]”uh1h°hhhžhhŸh¯h KŒexpect_referenced_by_name”}”jrh£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”jœŒ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”}”(jrh®jqjnjŠj‡jAj>j‚jjijfuŒ nametypes”}”(jrˆjq‰jЉjA‰j‚‰ji‰uh}”(h®h²jnh²j‡hÅj>hæjjDjfjuŒ 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”“”}”jªKs…”R”Œparse_messages”]”Œtransform_messages”]”hŒsystem_message”“”)”}”(hhh]”h×)”}”(hhh]”hŒ4Hyperlink target "memory-hotplug" is not referenced.”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÖhjubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”h¯Œline”Kuh1jubaŒ transformer”NŒ include_log”]”Œ decoration”Nhžhub.