€•@xŒ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ŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/pt_BR/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 ”…””}”(hj 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&]”uh1jhj ubhŒ:”…””}”(hj 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&]”uh1j8h³hÃh´Khj4ubhŒ 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.”…””}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´KhjJubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhj4ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Khj/ubj3)”}”(hŒ7MEM_CANCEL_ONLINE Generated if MEM_GOING_ONLINE fails. ”h]”(j9)”}”(hŒMEM_CANCEL_ONLINE”h]”hŒMEM_CANCEL_ONLINE”…””}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´KhjgubjI)”}”(hhh]”hë)”}”(hŒ$Generated if MEM_GOING_ONLINE fails.”h]”hŒ$Generated if MEM_GOING_ONLINE fails.”…””}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´Khjyubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjgubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Khj/h²hubj3)”}”(hŒwMEM_ONLINE Generated when memory has successfully brought online. The callback may allocate pages from the new memory. ”h]”(j9)”}”(hŒ MEM_ONLINE”h]”hŒ MEM_ONLINE”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´Khj–ubjI)”}”(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&]”uh1jHhj–ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Khj/h²hubj3)”}”(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]”(j9)”}”(hŒMEM_GOING_OFFLINE”h]”hŒMEM_GOING_OFFLINE”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´K!hjÅubjI)”}”(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&]”uh1jHhjÅubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´K!hj/h²hubj3)”}”(hŒ‡MEM_CANCEL_OFFLINE Generated if MEM_GOING_OFFLINE fails. Memory is available again from the memory block that we attempted to offline. ”h]”(j9)”}”(hŒMEM_CANCEL_OFFLINE”h]”hŒMEM_CANCEL_OFFLINE”…””}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´K%hjôubjI)”}”(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$hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjôubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´K%hj/h²hubj3)”}”(hŒ:MEM_OFFLINE Generated after offlining memory is complete. ”h]”(j9)”}”(hŒ MEM_OFFLINE”h]”hŒ MEM_OFFLINE”…””}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´K(hj#ubjI)”}”(hhh]”hë)”}”(hŒ-Generated after offlining memory is complete.”h]”hŒ-Generated after offlining memory is complete.”…””}”(hj8h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K(hj5ubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhj#ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´K(hj/h²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hhúh²hh³hÃh´Nubhë)”}”(hŒ1A callback routine can be registered by calling::”h]”hŒ0A callback routine can be registered by calling:”…””}”(hjXh²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)”…””}”hjhsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jfh³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.”…””}”(hjxh²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:”…””}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K1hhúh²hubjg)”}”(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&]”jvjwuh1jfh³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²hubjg)”}”(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&]”jvjwuh1jfh³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”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj 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.”…””}”(hj&h²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.”…””}”(hj4h²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.”…””}”(hjBh²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”…””}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjXh²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 ”…””}”(hjih²hh³Nh´Nubj)”}”(hŒ``include/linux/node.h``”h]”hŒinclude/linux/node.h”…””}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjiubhŒ:”…””}”(hjih²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´KZhjXh²hubj.)”}”(hhh]”(j3)”}”(hŒdNODE_ADDING_FIRST_MEMORY Generated before memory becomes available to this node for the first time. ”h]”(j9)”}”(hŒNODE_ADDING_FIRST_MEMORY”h]”hŒNODE_ADDING_FIRST_MEMORY”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´K]hjŒubjI)”}”(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.”…””}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K]hjžubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjŒubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´K]hj‰ubj3)”}”(hŒMNODE_CANCEL_ADDING_FIRST_MEMORY Generated if NODE_ADDING_FIRST_MEMORY fails. ”h]”(j9)”}”(hŒNODE_CANCEL_ADDING_FIRST_MEMORY”h]”hŒNODE_CANCEL_ADDING_FIRST_MEMORY”…””}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´K`hj»ubjI)”}”(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&]”uh1jHhj»ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´K`hj‰h²hubj3)”}”(hŒeNODE_ADDED_FIRST_MEMORY Generated when memory has become available for this node for the first time. ”h]”(j9)”}”(hŒNODE_ADDED_FIRST_MEMORY”h]”hŒNODE_ADDED_FIRST_MEMORY”…””}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´KchjêubjI)”}”(hhh]”hë)”}”(hŒLGenerated when memory has become available for this node for the first time.”h]”hŒLGenerated when memory has become available for 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&]”uh1jHhjêubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Kchj‰h²hubj3)”}”(hŒiNODE_REMOVING_LAST_MEMORY Generated when the last memory available to this node is about to be offlined. ”h]”(j9)”}”(hŒNODE_REMOVING_LAST_MEMORY”h]”hŒNODE_REMOVING_LAST_MEMORY”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´KfhjubjI)”}”(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.”…””}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´Kfhj+ubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Kfhj‰h²hubj3)”}”(hŒXNODE_CANCEL_REMOVING_LAST_MEMORY Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails. ”h]”(j9)”}”(hŒ NODE_CANCEL_REMOVING_LAST_MEMORY”h]”hŒ NODE_CANCEL_REMOVING_LAST_MEMORY”…””}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´KihjHubjI)”}”(hhh]”hë)”}”(hŒ6Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails.”h]”hŒ6Generated when NODE_CANCEL_REMOVING_LAST_MEMORY fails.”…””}”(hj]h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´KihjZubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjHubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Kihj‰h²hubj3)”}”(hŒbNODE_REMOVED_LAST_MEMORY Generated when the last memory available to this node has been offlined. ”h]”(j9)”}”(hŒNODE_REMOVED_LAST_MEMORY”h]”hŒNODE_REMOVED_LAST_MEMORY”…””}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j8h³hÃh´KlhjwubjI)”}”(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.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´Klhj‰ubah}”(h]”h ]”h"]”h$]”h&]”uh1jHhjwubeh}”(h]”h ]”h"]”h$]”h&]”uh1j2h³hÃh´Klhj‰h²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1j-hjXh²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´KnhjXh²hubjg)”}”(hŒ.hotplug_node_notifier(callback_func, priority)”h]”hŒ.hotplug_node_notifier(callback_func, priority)”…””}”hjºsbah}”(h]”h ]”h"]”h$]”h&]”jvjwuh1jfh³hÃh´KphjXh²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´KrhjXh²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´KuhjXh²hubjg)”}”(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&]”jvjwuh1jfh³hÃh´KwhjXh²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{hjXh²hubjg)”}”(hŒ'struct node_notify { int nid; }”h]”hŒ'struct node_notify { int nid; }”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jvjwuh1jfh³hÃh´K€hjXh²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„hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÃhjh²hh³hÃh´Nubah}”(h]”h ]”h"]”h$]”h&]”jújûuh1j¾h³hÃh´K„hjXh²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.”…””}”(hj/h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K†hjXh²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”…””}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj=ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´KŽhjXh²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.”…””}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K’hjXh²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.”…””}”(hjgh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K”hjXh²hubhë)”}”(hŒ?NOTIFY_STOP stops further processing of the notification queue.”h]”hŒ?NOTIFY_STOP stops further processing of the notification queue.”…””}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K™hjXh²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.”…””}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K›hjXh²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”…””}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj¡h²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¢hj¡h²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¥hj¡h²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«hj¡h²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”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K¯hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÃhjh²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()).”…””}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K±hj"ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÃhjh²hh³hÃh´Nubeh}”(h]”h ]”h"]”h$]”h&]”jújûuh1j¾h³hÃh´K¯hj¡h²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´hj¡h²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)”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K·hj¡h²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).”…””}”(hj\h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´K»hj¡h²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.”…””}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hêh³hÃh´KÀhj¡h²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”}”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”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”}”(j†hÂj…j‚jžj›jUjRj–j“j}jzuŒ nametypes”}”(j†ˆj…‰jž‰jU‰j–‰j}‰uh}”(hÂhÆj‚hÆj›hÙjRhúj“jXjzj¡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”“”}”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.