[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191217123851.8854-3-david@redhat.com>
Date: Tue, 17 Dec 2019 13:38:50 +0100
From: David Hildenbrand <david@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: linux-mm@...ck.org, David Hildenbrand <david@...hat.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Michael Ellerman <mpe@...erman.id.au>,
Andrew Morton <akpm@...ux-foundation.org>,
Allison Randal <allison@...utok.net>,
Jens Axboe <axboe@...nel.dk>,
Anshuman Khandual <anshuman.khandual@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Balbir Singh <bsingharora@...il.com>,
Rashmica Gupta <rashmica.g@...il.com>,
linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH RFC v1 2/3] powerpc/memtrace: Factor out readding memory into memtrace_free_node()
While at it, move it, we want to reuse it soon.
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: David Hildenbrand <david@...hat.com>
Cc: Allison Randal <allison@...utok.net>
Cc: Jens Axboe <axboe@...nel.dk>
Cc: Anshuman Khandual <anshuman.khandual@....com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Balbir Singh <bsingharora@...il.com>
Cc: Rashmica Gupta <rashmica.g@...il.com>
Cc: linuxppc-dev@...ts.ozlabs.org
Signed-off-by: David Hildenbrand <david@...hat.com>
---
arch/powerpc/platforms/powernv/memtrace.c | 44 ++++++++++++++---------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 0c4c54d2e3c4..2d2a0a2acd60 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -50,6 +50,32 @@ static const struct file_operations memtrace_fops = {
.open = simple_open,
};
+static int online_mem_block(struct memory_block *mem, void *arg)
+{
+ return device_online(&mem->dev);
+}
+
+static int memtrace_free_node(int nid, unsigned long start, unsigned long size)
+{
+ int ret;
+
+ ret = add_memory(nid, start, size);
+ if (!ret) {
+ /*
+ * If the kernel isn't compiled with the auto online option, we
+ * will try to online ourselves. We'll ignore any errors here -
+ * user space can try to online itself later (after all, the
+ * memory was added successfully).
+ */
+ if (!memhp_auto_online) {
+ lock_device_hotplug();
+ walk_memory_blocks(start, size, NULL, online_mem_block);
+ unlock_device_hotplug();
+ }
+ }
+ return ret;
+}
+
static int check_memblock_online(struct memory_block *mem, void *arg)
{
if (mem->state != MEM_ONLINE)
@@ -202,11 +228,6 @@ static int memtrace_init_debugfs(void)
return ret;
}
-static int online_mem_block(struct memory_block *mem, void *arg)
-{
- return device_online(&mem->dev);
-}
-
/*
* Iterate through the chunks of memory we have removed from the kernel
* and attempt to add them back to the kernel.
@@ -229,24 +250,13 @@ static int memtrace_online(void)
ent->mem = 0;
}
- if (add_memory(ent->nid, ent->start, ent->size)) {
+ if (memtrace_free_node(ent->nid, ent->start, ent->size)) {
pr_err("Failed to add trace memory to node %d\n",
ent->nid);
ret += 1;
continue;
}
- /*
- * If kernel isn't compiled with the auto online option
- * we need to online the memory ourselves.
- */
- if (!memhp_auto_online) {
- lock_device_hotplug();
- walk_memory_blocks(ent->start, ent->size, NULL,
- online_mem_block);
- unlock_device_hotplug();
- }
-
/*
* Memory was added successfully so clean up references to it
* so on reentry we can tell that this chunk was added.
--
2.23.0
Powered by blists - more mailing lists