From patchwork Thu Oct 4 22:11:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10626935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8ACF41731 for ; Thu, 4 Oct 2018 22:11:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 782CE294D6 for ; Thu, 4 Oct 2018 22:11:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A53B294F3; Thu, 4 Oct 2018 22:11:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A196C294D6 for ; Thu, 4 Oct 2018 22:11:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A8486B026B; Thu, 4 Oct 2018 18:11:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 32EE96B026C; Thu, 4 Oct 2018 18:11:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D0D76B026D; Thu, 4 Oct 2018 18:11:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by kanga.kvack.org (Postfix) with ESMTP id DDCEF6B026B for ; Thu, 4 Oct 2018 18:11:24 -0400 (EDT) Received: by mail-oi1-f197.google.com with SMTP id p11-v6so7309824oih.17 for ; Thu, 04 Oct 2018 15:11:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=SKedq4/6cNxZ3Fyelu+y4RSRtNmFL6vsSGS+ksYjzdg=; b=jG7INjCEqKX02iOcl7b8ifuCKE2cZYwpaMRJfWwguyIPHKuS2yP6KjuJOi8uXK2Gm+ g79zeFfjqbG0Ou2LLW5/Dw0aKmgre09G395BkeHa6lYKCD6bAMJwMFxjjEuG1ljUSVE0 +lEarZ0R3K+IVBpS3XEUqQZLDIRexGHhHpVsMDdcDC9+VoGDYk4oOyCuMfcAeXJx7+i8 JgW3dvFkvuzfmOsu708tg1pxR6Yt2oIKApwbarGlsk6TYfZKtgQJTWMgYrJT9GLte9Qc 63MJh8eeDLaQ23q0iiyL6O2nQSN7kIfOOtWsa3NgvZXpTjIVGcrxhMecF/AEfDMPgdDJ UFeQ== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: ABuFfoiGVFMvVxwiWxDB2aNQRN4vNPZRDdJmQ4OKlzc0PoIMMzE4T8+q I2L0WxLwHxJCl6P/W5LSvSROkvn+MUcaW1+HsUGR+XH5xw2qJIMQA1fzDbmB4P9Hugoi2qJD54n 4tgYDbKR44dCw4CHunLvfX7TMqvsbkzo4AnkdZ2shoFozcW2znLArB1c9fR5vAgI= X-Received: by 2002:aca:3b42:: with SMTP id i63-v6mr1451832oia.312.1538691084587; Thu, 04 Oct 2018 15:11:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV63CzjHFViLjOdGspFNtKMWtVmtB2z0eCijsc29WgF8+qQCTK9GLzop3J1Wd+dgpEp9JHmQd X-Received: by 2002:aca:3b42:: with SMTP id i63-v6mr1451794oia.312.1538691083337; Thu, 04 Oct 2018 15:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538691083; cv=none; d=google.com; s=arc-20160816; b=Y5UdjvFmrFEvSwtV3YpNlceb049kIMMkNKOB9FIjqdm9LwNrc6C/C+9jouqruXBm14 DNbfIlHjrcxJQuA5Xo3cYpQkhrfhAh/Ojk0/05KGvk4nxQxT9J98202xziI/qrmfjjDa O5LS/XmGScxfvWc8pxgjHsx7eWYd/tDTQ7jI9Bf7kJbLdiB2XT4F+6Di0GPVozAZ+UK7 otw9f2WojOMxiAoarmcs4pQ1dumBUTJy/cDBOkq8fF5Jh5cUE/3T/a10bHYZ5GjwAINS QDeriRnZd9o8dRzdnmdYvI17zfA/ta56yijX8jCWl45HpKpA4VG6kbVA5eqU/jeBwLrf d6yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from; bh=SKedq4/6cNxZ3Fyelu+y4RSRtNmFL6vsSGS+ksYjzdg=; b=W8gKUdOeTBdgk3voac8uLOKlyBWnvSq4cmcMS9XT7WnKcOWtnlJ3PGP0nsRzqedvMk V30XfR+FPK4qXLxw/xE9zd0mi0ht+v3bVN4wRk802T48uZ+pxvrOvzLyeZD+Qer7R7UJ E2bII4BMfKn1wZgowzY/KqbFQjxAOZaFiwV9C/Ek2kkUE2rz+nHwAs6iUJgSVBv8IcMH xvie2cweEwnS+8905W5Qsi97licphHmdpjnlwDl+tatKSUbCtYcJ+w0CP2TEIbWzG7/1 FHy0dYA3DqRdnBexUeKr/B1sNr+l4SUIYbvPbvJAiyaYD1AT0Sgb9cGaGu9T/Ns6LyI9 kMQw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id g1-v6si3137101otb.294.2018.10.04.15.11.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 15:11:23 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w94M9FCT124116 for ; Thu, 4 Oct 2018 18:11:22 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mwrs9g1qd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 04 Oct 2018 18:11:22 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Oct 2018 23:11:20 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 4 Oct 2018 23:11:17 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w94MBGqS65273894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Oct 2018 22:11:16 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25422A4053; Fri, 5 Oct 2018 01:10:53 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE787A4051; Fri, 5 Oct 2018 01:10:51 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.204.110]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 5 Oct 2018 01:10:51 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Fri, 05 Oct 2018 01:11:14 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: linux-doc@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport Subject: [PATCH 2/2] docs/vm: split memory hotplug notifier description to Documentation/core-api Date: Fri, 5 Oct 2018 01:11:01 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538691061-31289-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1538691061-31289-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18100422-0020-0000-0000-000002CFAB38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100422-0021-0000-0000-0000211DFC79 Message-Id: <1538691061-31289-3-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-04_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810040199 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The memory hotplug notifier description is about kernel internals rather than admin/user visible API. Place it appropriately. Signed-off-by: Mike Rapoport Signed-off-by: Mike Rapoport --- Documentation/admin-guide/mm/memory-hotplug.rst | 83 --------------------- Documentation/core-api/index.rst | 2 + Documentation/core-api/memory-hotplug-notifier.rst | 84 ++++++++++++++++++++++ 3 files changed, 86 insertions(+), 83 deletions(-) create mode 100644 Documentation/core-api/memory-hotplug-notifier.rst diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index a33090c..0b9c83e 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -31,7 +31,6 @@ be changed often. 6.1 Memory offline and ZONE_MOVABLE 6.2. How to offline memory 7. Physical memory remove - 8. Memory hotplug event notifier 9. Future Work List @@ -414,88 +413,6 @@ Need more implementation yet.... - Notification completion of remove works by OS to firmware. - Guard from remove if not yet. -Memory hotplug event notifier -============================= - -Hotplugging events are sent to a notification queue. - -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. - -MEM_CANCEL_ONLINE - Generated if MEMORY_GOING_ONLINE fails. - -MEM_ONLINE - Generated when memory has successfully brought online. The callback may - allocate pages from the new memory. - -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. - -MEM_CANCEL_OFFLINE - Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from - the memory block that we attempted to offline. - -MEM_OFFLINE - Generated after offlining memory is complete. - -A callback routine can be registered by calling:: - - hotplug_memory_notifier(callback_func, priority) - -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; - unsigned long nr_pages; - int status_change_nid_normal; - int status_change_nid_high; - int status_change_nid; - } - -- start_pfn is start_pfn of online/offline memory. -- nr_pages is # of pages of online/offline memory. -- status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask - is (will be) set/clear, if this is -1, then nodemask status is not changed. -- status_change_nid_high is set node id when N_HIGH_MEMORY of nodemask - is (will be) set/clear, if this is -1, then nodemask status is not changed. -- status_change_nid is set node id when N_MEMORY of nodemask is (will be) - set/clear. It means a new(memoryless) node gets new memory by online and a - 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. - Future Work =========== diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst index 165d7688..4f8a426 100644 --- a/Documentation/core-api/index.rst +++ b/Documentation/core-api/index.rst @@ -32,6 +32,8 @@ Core utilities gfp_mask-from-fs-io timekeeping boot-time-mm + memory-hotplug-notifier + Interfaces for kernel debugging =============================== diff --git a/Documentation/core-api/memory-hotplug-notifier.rst b/Documentation/core-api/memory-hotplug-notifier.rst new file mode 100644 index 0000000..35347cc --- /dev/null +++ b/Documentation/core-api/memory-hotplug-notifier.rst @@ -0,0 +1,84 @@ +.. _memory_hotplug_notifier: + +============================= +Memory hotplug event notifier +============================= + +Hotplugging events are sent to a notification queue. + +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. + +MEM_CANCEL_ONLINE + Generated if MEM_GOING_ONLINE fails. + +MEM_ONLINE + Generated when memory has successfully brought online. The callback may + allocate pages from the new memory. + +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. + +MEM_CANCEL_OFFLINE + Generated if MEM_GOING_OFFLINE fails. Memory is available again from + the memory block that we attempted to offline. + +MEM_OFFLINE + Generated after offlining memory is complete. + +A callback routine can be registered by calling:: + + hotplug_memory_notifier(callback_func, priority) + +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; + unsigned long nr_pages; + int status_change_nid_normal; + int status_change_nid_high; + int status_change_nid; + } + +- start_pfn is start_pfn of online/offline memory. +- nr_pages is # of pages of online/offline memory. +- status_change_nid_normal is set node id when N_NORMAL_MEMORY of nodemask + is (will be) set/clear, if this is -1, then nodemask status is not changed. +- status_change_nid_high is set node id when N_HIGH_MEMORY of nodemask + is (will be) set/clear, if this is -1, then nodemask status is not changed. +- status_change_nid is set node id when N_MEMORY of nodemask is (will be) + set/clear. It means a new(memoryless) node gets new memory by online and a + 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.