Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4122222ybf; Tue, 3 Mar 2020 20:44:37 -0800 (PST) X-Google-Smtp-Source: ADFU+vu0Rhqf64zRDRmJ+8oNo/lELf8GjvXdFQJycTjtYd/dCal3WgeJOVFr9c2AKlYDdFle+OCM X-Received: by 2002:a9d:708a:: with SMTP id l10mr975739otj.371.1583297076861; Tue, 03 Mar 2020 20:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583297076; cv=none; d=google.com; s=arc-20160816; b=R1OAL8cNSgOJv5EhzO29qR4VEltoU58nI8MeMSZsCFmIDuRoMT7DkERVrrobvx134A T093YT4O4u+WuKe/ZBpP8kCkpis/Bvg45pRONkwRI3S4E3cjf61okJfWB9R+3Xs+KkTf K8oL8gCBN9bcUDXeR8CVdEMi0bWmenWWL1IxjO+OD8UZW6yue8CB56TzrFarG0vE5+ly 9dquJfPvc7JGuKL4M4/gxUimzwi9eI1MkaZIUdDhSTP0/PaZcinQLTGicPZpmma7a0hT V0Er4UAjJPVFwrwLdt+cJ36hFeDYLv0a6fHZ3HJXSncI2quIAxVZONaSH/ZCuKNII4AP bGHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=okutyK5a8uQZodANWxrUAY3lG9R/jofu3YcVmmvfiXg=; b=wxbJYGWrIWF/oz3KuJ2CSDIifHDqIJ0t6mB5VpSLccBKCcRIRVAwJyjrbGFROXcrOd G890UqopHBvl2Qo3mLc2Mm0h/rStA14jOK51ZJHWdFPniejgCDzimWIc1HGdEvvglomP PFMeDv7R36/ZstntmH6LuAdgQ5aYlHqez9tzYxu8RT7XzpyGQFOLMC9Mtg9UvLauGdYA Ch4H0baN5Lrk0iqTWYEE9M9C0kGcUqEWo6kgMlDdtNgS0xd/aoFPUCgSNhTavwX43m+e isBvD6ob0j43vKSvlTCfSuXyvt3Qs8yUXi1C9iXPiAz82wQGYraUBjdDAkHVQHz4yThJ GoAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UtZrFgtj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si499286oii.54.2020.03.03.20.44.24; Tue, 03 Mar 2020 20:44:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UtZrFgtj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbgCDEnh (ORCPT + 99 others); Tue, 3 Mar 2020 23:43:37 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39468 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgCDEnh (ORCPT ); Tue, 3 Mar 2020 23:43:37 -0500 Received: by mail-wr1-f66.google.com with SMTP id y17so674280wrn.6 for ; Tue, 03 Mar 2020 20:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=okutyK5a8uQZodANWxrUAY3lG9R/jofu3YcVmmvfiXg=; b=UtZrFgtjsSVPD97F4GruvTZtyh2VBOeQ4HKg0HP2gH+pqaH90Kj/tqXWvqJVgqLWUI A8QRfAJIG0iLFragRxQi4JY75xgzmcKasIin+nANgxxdQj9csad7RLWFPuSK1AkvF8Cl 77q3rKVMKwuwtHS9sl3wggvbcKpP2CyzlN3pAXHRUeVObFSyVsoXOiWgS+JLlk6mXo+9 cmIKQD9kIzJ9Mwhfoyu+DawM7UQVpWrrbIoKDQo8Iy7sXz9L14XsI6wu4f6Gfy30+KQB pmO1bQOZ2SB4rEEezl777klETr4hsjIYo9hTKe++NOgJdeaTbZSA5WKK/3EhrIpXHv0v qUyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=okutyK5a8uQZodANWxrUAY3lG9R/jofu3YcVmmvfiXg=; b=aKDrUCrC6LLOahivcgU0QVUlDFZGrzgHh5+AP7c8WATRdWZZkcui9rWn2iv9h/N1YA yvdnRV804+CA1RSFJKbm34qZAyRC84kNKMTYSrRhF4FqxdPYUvg1fL46mKS8H2952xqD 9iYO5/QvzIJH4fvdKqHaoincLO+Wcj9/X3murVhvggQm4c9DpK0p+Ataaz6yQRuxdWKg VIfY5mbYn/qa1Nc8wrImIsB6KfUvHLBFijMj5J4te3tGl5RSbiBwuYBNzaIFvtfaISOB qK6GD/xhgK3msI8VXmQ1KaOA3CqkXNBsuLETFGYjnzhN8fd5l5nWhN1HZ3JwI/FCh+AF DIYg== X-Gm-Message-State: ANhLgQ08zxg2Jzdzhn+NSJ6MW1fumlyJvfukDRmwTh57vz8RAtd+xrak /RZhYC9CnMRw6FZtyyvAjq+sByAMcBn2Dg6lMXw= X-Received: by 2002:a5d:538e:: with SMTP id d14mr1770087wrv.62.1583297014940; Tue, 03 Mar 2020 20:43:34 -0800 (PST) MIME-Version: 1.0 References: <20200228060439.52749-1-leonardo@linux.ibm.com> In-Reply-To: <20200228060439.52749-1-leonardo@linux.ibm.com> From: Bharata B Rao Date: Wed, 4 Mar 2020 10:13:23 +0530 Message-ID: Subject: Re: [PATCH 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests To: Leonardo Bras Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Greg Kroah-Hartman , Hari Bathini , Christophe Leroy , Thomas Gleixner , Claudio Carvalho , Michael Roth , linuxppc-dev , "linux-kernel@vger.kernel.org" , arbab@linux.ibm.com, ndfont@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 28, 2020 at 11:36 AM Leonardo Bras wrote: > > 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 base memory, qemu assigns these flags for it's LMBs: > (DRCONF_MEM_AI_INVALID | DRCONF_MEM_RESERVED) > For hot-plugged memory, it assigns (DRCONF_MEM_ASSIGNED). > > While guest kernel reads the device-tree, early_init_drmem_lmb() is > called for every added LMBs, doing nothing for base memory, and adding > memblocks for hot-plugged memory. Skipping base memory happens here: > > if ((lmb->flags & DRCONF_MEM_RESERVED) || > !(lmb->flags & DRCONF_MEM_ASSIGNED)) > return; > > Marking memblocks added by this function as hotplugable memory > is enough to get the desirable behavior, and should cause no change > if 'movable_node' parameter is not passed to kernel. > > Signed-off-by: Leonardo Bras > --- > arch/powerpc/kernel/prom.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > index 6620f37abe73..f4d14c67bf53 100644 > --- a/arch/powerpc/kernel/prom.c > +++ b/arch/powerpc/kernel/prom.c > @@ -518,6 +518,8 @@ static void __init early_init_drmem_lmb(struct drmem_lmb *lmb, > DBG("Adding: %llx -> %llx\n", base, size); > if (validate_mem_limit(base, &size)) > memblock_add(base, size); > + > + early_init_dt_mark_hotplug_memory_arch(base, size); Hi, I tried this a few years back (https://patchwork.ozlabs.org/patch/800142/) and didn't pursue it further because at that time, it was felt that the approach might not work for PowerVM guests, because all the present memory except RMA gets marked as hot-pluggable by PowerVM. This discussion is not present in the above thread, but during my private discussions with Reza and Nathan, it was noted that making all that memory as MOVABLE is not preferable for PowerVM guests as we might run out of memory for kernel allocations. Regards, Bharata. -- http://raobharata.wordpress.com/