Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Doc/memory-hotplug.txt: corrections and callback function prototype

Documentation/memory-hotplug.txt describes that a callback function can
be added to the notification chain by calling hotplug_memory_notifier().
The function prototype of the callback function is mssing. This missing
information is added by the patch.

The description of the arguments of the callback function is
reworked.

The constants for the event types are corrected.

The possible return values are explained.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Heinrich Schuchardt and committed by
Jonathan Corbet
433b89cf 09677e0f

+35 -10
+35 -10
Documentation/memory-hotplug.txt
··· 359 359 -------------------------------- 360 360 8. Memory hotplug event notifier 361 361 -------------------------------- 362 - Memory hotplug has event notifier. There are 6 types of notification. 362 + Hotplugging events are sent to a notification queue. 363 363 364 - MEMORY_GOING_ONLINE 364 + There are six types of notification defined in include/linux/memory.h: 365 + 366 + MEM_GOING_ONLINE 365 367 Generated before new memory becomes available in order to be able to 366 368 prepare subsystems to handle memory. The page allocator is still unable 367 369 to allocate from the new memory. 368 370 369 - MEMORY_CANCEL_ONLINE 371 + MEM_CANCEL_ONLINE 370 372 Generated if MEMORY_GOING_ONLINE fails. 371 373 372 - MEMORY_ONLINE 374 + MEM_ONLINE 373 375 Generated when memory has successfully brought online. The callback may 374 376 allocate pages from the new memory. 375 377 376 - MEMORY_GOING_OFFLINE 378 + MEM_GOING_OFFLINE 377 379 Generated to begin the process of offlining memory. Allocations are no 378 380 longer possible from the memory but some of the memory to be offlined 379 381 is still in use. The callback can be used to free memory known to a 380 382 subsystem from the indicated memory block. 381 383 382 - MEMORY_CANCEL_OFFLINE 384 + MEM_CANCEL_OFFLINE 383 385 Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from 384 386 the memory block that we attempted to offline. 385 387 386 - MEMORY_OFFLINE 388 + MEM_OFFLINE 387 389 Generated after offlining memory is complete. 388 390 389 - A callback routine can be registered by 391 + A callback routine can be registered by calling 392 + 390 393 hotplug_memory_notifier(callback_func, priority) 391 394 392 - The second argument of callback function (action) is event types of above. 393 - The third argument is passed by pointer of struct memory_notify. 395 + Callback functions with higher values of priority are called before callback 396 + functions with lower values. 397 + 398 + A callback function must have the following prototype: 399 + 400 + int callback_func( 401 + struct notifier_block *self, unsigned long action, void *arg); 402 + 403 + The first argument of the callback function (self) is a pointer to the block 404 + of the notifier chain that points to the callback function itself. 405 + The second argument (action) is one of the event types described above. 406 + The third argument (arg) passes a pointer of struct memory_notify. 394 407 395 408 struct memory_notify { 396 409 unsigned long start_pfn; ··· 424 411 node loses all memory. If this is -1, then nodemask status is not changed. 425 412 If status_changed_nid* >= 0, callback should create/discard structures for the 426 413 node if necessary. 414 + 415 + The callback routine shall return one of the values 416 + NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP 417 + defined in include/linux/notifier.h 418 + 419 + NOTIFY_DONE and NOTIFY_OK have no effect on the further processing. 420 + 421 + NOTIFY_BAD is used as response to the MEM_GOING_ONLINE, MEM_GOING_OFFLINE, 422 + MEM_ONLINE, or MEM_OFFLINE action to cancel hotplugging. It stops 423 + further processing of the notification queue. 424 + 425 + NOTIFY_STOP stops further processing of the notification queue. 427 426 428 427 -------------- 429 428 9. Future Work