linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests
@ 2020-03-05 23:32 Leonardo Bras
  2020-03-06  0:24 ` Leonardo Bras
  2020-04-01 15:07 ` Leonardo Bras
  0 siblings, 2 replies; 5+ messages in thread
From: Leonardo Bras @ 2020-03-05 23:32 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Allison Randal, Greg Kroah-Hartman, Leonardo Bras,
	Nathan Fontenot, Thomas Gleixner, Michael Anderson,
	Mike Rapoport, Claudio Carvalho, Hari Bathini, Christophe Leroy,
	bharata.rao
  Cc: linuxppc-dev, linux-kernel

While providing guests, it's desirable to resize it's memory on demand.

By now, it's possible to do so by creating a guest with a small base
memory, hot-plugging all the rest, and using 'movable_node' kernel
command-line parameter, which puts all hot-plugged memory in
ZONE_MOVABLE, allowing it to be removed whenever needed.

But there is an issue regarding guest reboot:
If memory is hot-plugged, and then the guest is rebooted, all hot-plugged
memory goes to ZONE_NORMAL, which offers no guaranteed hot-removal.
It usually prevents this memory to be hot-removed from the guest.

It's possible to use device-tree information to fix that behavior, as
it stores flags for LMB ranges on ibm,dynamic-memory-vN.
It involves marking each memblock with the correct flags as hotpluggable
memory, which mm/memblock.c puts in ZONE_MOVABLE during boot if
'movable_node' is passed.

For carrying such information, the new flag DRCONF_MEM_HOTPLUGGED is
proposed, which should be true if memory was hot-plugged on guest, and
false if it's base memory.

During boot, guest kernel reads the device-tree, early_init_drmem_lmb()
is called for every added LMBs. Here, checking for this new flag and
marking memblocks as hotplugable memory is enough to get the desirable
behavior.

This should cause no change if 'movable_node' parameter is not passed
in kernel command-line.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>

---
The new flag was already proposed on Power Architecture documentation,
and it's waiting for approval.

I would like to get your comments on this change, but it's still not
ready for being merged.

I will send the matching qemu change as a reply later.

Changes since v1:
- Adds new flag, so PowerVM is compatible with the change.
- Fixes mistakes in code
---
 arch/powerpc/include/asm/drmem.h | 1 +
 arch/powerpc/kernel/prom.c       | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/drmem.h b/arch/powerpc/include/asm/drmem.h
index 3d76e1c388c2..92083b4565f6 100644
--- a/arch/powerpc/include/asm/drmem.h
+++ b/arch/powerpc/include/asm/drmem.h
@@ -65,6 +65,7 @@ struct of_drconf_cell_v2 {
 #define DRCONF_MEM_ASSIGNED	0x00000008
 #define DRCONF_MEM_AI_INVALID	0x00000040
 #define DRCONF_MEM_RESERVED	0x00000080
+#define DRCONF_MEM_HOTPLUGGED	0x00000100
 
 static inline u32 drmem_lmb_size(void)
 {
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6620f37abe73..9c5cb2e8049e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -515,9 +515,14 @@ static void __init early_init_drmem_lmb(struct drmem_lmb *lmb,
 				size = 0x80000000ul - base;
 		}
 
+		if (!validate_mem_limit(base, &size))
+			continue;
+
 		DBG("Adding: %llx -> %llx\n", base, size);
-		if (validate_mem_limit(base, &size))
-			memblock_add(base, size);
+		memblock_add(base, size);
+
+		if (lmb->flags & DRCONF_MEM_HOTPLUGGED)
+			memblock_mark_hotplug(base, size);
 	} while (--rngs);
 }
 #endif /* CONFIG_PPC_PSERIES */
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests
  2020-03-05 23:32 [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests Leonardo Bras
@ 2020-03-06  0:24 ` Leonardo Bras
  2020-04-01 15:07 ` Leonardo Bras
  1 sibling, 0 replies; 5+ messages in thread
From: Leonardo Bras @ 2020-03-06  0:24 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Allison Randal, Greg Kroah-Hartman, Nathan Fontenot,
	Thomas Gleixner, Michael Anderson, Mike Rapoport,
	Claudio Carvalho, Hari Bathini, Christophe Leroy, bharata.rao
  Cc: linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 161 bytes --]

On Thu, 2020-03-05 at 20:32 -0300, Leonardo Bras wrote:
> I will send the matching qemu change as a reply later.

http://patchwork.ozlabs.org/patch/1249931/

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests
  2020-03-05 23:32 [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests Leonardo Bras
  2020-03-06  0:24 ` Leonardo Bras
@ 2020-04-01 15:07 ` Leonardo Bras
  2020-04-02  9:14   ` Bharata B Rao
  1 sibling, 1 reply; 5+ messages in thread
From: Leonardo Bras @ 2020-04-01 15:07 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Allison Randal, Greg Kroah-Hartman, Nathan Fontenot,
	Thomas Gleixner, Michael Anderson, Mike Rapoport,
	Claudio Carvalho, Hari Bathini, Christophe Leroy, bharata.rao
  Cc: linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

On Thu, 2020-03-05 at 20:32 -0300, Leonardo Bras wrote:
> ---
> The new flag was already proposed on Power Architecture documentation,
> and it's waiting for approval.
> 
> I would like to get your comments on this change, but it's still not
> ready for being merged.

New flag got approved on the documentation.
Please review this patch.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests
  2020-04-01 15:07 ` Leonardo Bras
@ 2020-04-02  9:14   ` Bharata B Rao
  2020-04-02 17:08     ` Leonardo Bras
  0 siblings, 1 reply; 5+ messages in thread
From: Bharata B Rao @ 2020-04-02  9:14 UTC (permalink / raw)
  To: Leonardo Bras
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Allison Randal, Greg Kroah-Hartman, Nathan Fontenot,
	Thomas Gleixner, Michael Anderson, Mike Rapoport,
	Claudio Carvalho, Hari Bathini, Christophe Leroy, Bharata B Rao,
	linuxppc-dev, linux-kernel

On Wed, Apr 1, 2020 at 8:38 PM Leonardo Bras <leonardo@linux.ibm.com> wrote:
>
> On Thu, 2020-03-05 at 20:32 -0300, Leonardo Bras wrote:
> > ---
> > The new flag was already proposed on Power Architecture documentation,
> > and it's waiting for approval.
> >
> > I would like to get your comments on this change, but it's still not
> > ready for being merged.
>
> New flag got approved on the documentation.
> Please review this patch.

Looks good to me, also tested with PowerKVM guests.

Reviewed-by: Bharata B Rao <bharata@linux.ibm.com>

Regards,
Bharata.
-- 
http://raobharata.wordpress.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests
  2020-04-02  9:14   ` Bharata B Rao
@ 2020-04-02 17:08     ` Leonardo Bras
  0 siblings, 0 replies; 5+ messages in thread
From: Leonardo Bras @ 2020-04-02 17:08 UTC (permalink / raw)
  To: Bharata B Rao
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Allison Randal, Greg Kroah-Hartman, Nathan Fontenot,
	Thomas Gleixner, Michael Anderson, Mike Rapoport,
	Claudio Carvalho, Hari Bathini, Christophe Leroy, Bharata B Rao,
	linuxppc-dev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]

Hello Bharata, thank you for reviewing and testing!

During review of this new flag, it was suggested to change it's name to
a better one (on platform's viewpoint). 

So I will have to change the flag name from DRCONF_MEM_HOTPLUGGED to
DRCONF_MEM_HOTREMOVABLE.

Everything should work the same as today.

Best regards,
Leonardo

On Thu, 2020-04-02 at 14:44 +0530, Bharata B Rao wrote:
> Looks good to me, also tested with PowerKVM guests.
> 
> Reviewed-by: Bharata B Rao <bharata@linux.ibm.com>
> 
> Regards,
> Bharata.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-02 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05 23:32 [RFC PATCH v2 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests Leonardo Bras
2020-03-06  0:24 ` Leonardo Bras
2020-04-01 15:07 ` Leonardo Bras
2020-04-02  9:14   ` Bharata B Rao
2020-04-02 17:08     ` Leonardo Bras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).