Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752120AbbBUXTK (ORCPT ); Sat, 21 Feb 2015 18:19:10 -0500 Received: from mout.gmx.net ([212.227.15.19]:54246 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbbBUXTH (ORCPT ); Sat, 21 Feb 2015 18:19:07 -0500 From: Heinrich Schuchardt To: Jonathan Corbet Cc: Yasunori Goto , KAMEZAWA Hiroyuki , Dave Hansen , David Rientjes , Toshi Kani , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Heinrich Schuchardt Subject: [PATCH 1/1 v2] Doc/memory-hotplug.txt: callback function prototype Date: Sun, 22 Feb 2015 00:18:49 +0100 Message-Id: <1424560729-5716-1-git-send-email-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424283727-5795-1-git-send-email-xypron.glpk@gmx.de> References: <1424283727-5795-1-git-send-email-xypron.glpk@gmx.de> X-Provags-ID: V03:K0:fcjAgfQQHmP6S/XDttpemrvxOO3pYnCiIOdV0kIRoz9P0moKnXy 7O446m6IPTOLqnw/0mpQQBM4xM0h6aa+74kWXMasOkBk/z/zRSPB+yALucsooA4vJwtxjEI pGcRja68dM5Unab2YV7x6N5Q5c92oXyY+2AAm4RBJvAc8hxNKla7JaAXB8wfQtvheR73y6/ xBy4h5RziLDiofLdfHasg== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4104 Lines: 115 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 funciton 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. version 2: correction of event type constants return values Signed-off-by: Heinrich Schuchardt --- Documentation/memory-hotplug.txt | 45 +++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index ea03abf..c5a0645 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt @@ -359,38 +359,51 @@ Need more implementation yet.... -------------------------------- 8. Memory hotplug event notifier -------------------------------- -Memory hotplug has event notifier. There are 6 types of notification. +Hotplugging events are sent to a notification queue. -MEMORY_GOING_ONLINE +There are six types of notification defined in include/linux/memory.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. -MEMORY_CANCEL_ONLINE +MEM_CANCEL_ONLINE Generated if MEMORY_GOING_ONLINE fails. -MEMORY_ONLINE +MEM_ONLINE Generated when memory has successfully brought online. The callback may allocate pages from the new memory. -MEMORY_GOING_OFFLINE +MEM_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. -MEMORY_CANCEL_OFFLINE +MEM_CANCEL_OFFLINE Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from the memory block that we attempted to offline. -MEMORY_OFFLINE +MEM_OFFLINE Generated after offlining memory is complete. -A callback routine can be registered by +A callback routine can be registered by calling + hotplug_memory_notifier(callback_func, priority) -The second argument of callback function (action) is event types of above. -The third argument is passed by pointer of struct memory_notify. +Callback functions with higher values of priority are called before callback +functions with lower values. + +A callback function must have the following prototype: + + int callback_func( + struct notifier_block *self, unsigned long action, void *arg); + +The 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. struct memory_notify { unsigned long start_pfn; @@ -412,6 +425,18 @@ node loses all memory. If this is -1, then nodemask status is not changed. If status_changed_nid* >= 0, callback should create/discard structures for the node if necessary. +The callback routine shall return one of the values +NOTIFY_DONE, NOTIFY_OK, NOTIFY_BAD, NOTIFY_STOP +defined in include/linux/notifier.h + +NOTIFY_DONE and NOTIFY_OK have no effect on the further processing. + +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. + +NOTIFY_STOP stops further processing of the notification queue. + -------------- 9. Future Work -------------- -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/