Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp322092ybf; Thu, 27 Feb 2020 22:06:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzUwUTBgi/CYOXTD/VX5L1f+E40SqiveNRu/S739KlqhSVhedKExoGYcNOixhro1wEyGhLV X-Received: by 2002:a54:4816:: with SMTP id j22mr1967925oij.179.1582869990519; Thu, 27 Feb 2020 22:06:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582869990; cv=none; d=google.com; s=arc-20160816; b=MQH8xJRyetrxcBu48Ki8340/P8w1IRMPeojRlytgwai7oWAx3uAGb3dvXXisR9bAoc ERZX25io5c1RS1FmjQzZMnSwE88IVT4c+flwI84HsjOcMge/Ec77oFDKgeK9f+MdNqPz tSCZZZPOhDsWs2/pnZ/2+M5wox16xmdBrgz3O7oPUqWK+cW6YnTPK0ujEvyskXg3eSKE +R+IvIz6S0buga9689ahWieJQw9oivSH/LQs7XYg5w04lbV0FxQY1keptFt/4t22e5QN Z//r7t/8Q6t18UKhoIBvW+Yi9DdegLkvq+FdHOcGsKxK19y2dNnzpy4F7GqOx87W9wuV OOjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=tdDe968ePT5/0PRbe6WWsGlSFy+luJYO7oUhIyjuTv8=; b=kh5LqPExE7Y3t2pMwqN8qQM8rpdIdyllDGULJjq/g0ujPos+MBMEwoc7/Gv2Sq+24F bea1GPEvAlAamNoS0UeT+T6LIQXGhgSHmYMwUz9ITRcZDTEhGQRfkipbTkGpQEiNiIKj rYja2+aBweYrmq5WTBgTdMjBhUOdV9OLFQ1eoZqw85qMfZNhDfAY+1Q9JDeAlJQSnPGc 7nGseq2XhkRrRsv4Bf8NnYJiIpolDV9/EhmqS2ruPajDkf41T+7F7OOfnUieXEWXKN18 f8nI07oJD/0CVz6smUMHlKBEFUHAMsZaK+YRKnbZWYBvD88LV0f6GgS2Lby9fSYt8rMm xq5A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si1328638oic.140.2020.02.27.22.06.16; Thu, 27 Feb 2020 22:06:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726407AbgB1GGG (ORCPT + 99 others); Fri, 28 Feb 2020 01:06:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46062 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725868AbgB1GGG (ORCPT ); Fri, 28 Feb 2020 01:06:06 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01S64NUd029316; Fri, 28 Feb 2020 01:05:39 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yepxjj11j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Feb 2020 01:05:39 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01S61pwT008934; Fri, 28 Feb 2020 06:05:38 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 2yepv2js52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Feb 2020 06:05:38 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01S65aR459572596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 06:05:37 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7FFDBE054; Fri, 28 Feb 2020 06:05:36 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED8D2BE053; Fri, 28 Feb 2020 06:05:32 +0000 (GMT) Received: from LeoBras.aus.stglabs.ibm.com (unknown [9.85.198.107]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 28 Feb 2020 06:05:32 +0000 (GMT) From: Leonardo Bras To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Greg Kroah-Hartman , Hari Bathini , Leonardo Bras , Christophe Leroy , Thomas Gleixner , Claudio Carvalho , mdroth@linux.vnet.ibm.com Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] powerpc/kernel: Enables memory hot-remove after reboot on pseries guests Date: Fri, 28 Feb 2020 03:04:39 -0300 Message-Id: <20200228060439.52749-1-leonardo@linux.ibm.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-28_01:2020-02-26,2020-02-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } while (--rngs); } #endif /* CONFIG_PPC_PSERIES */ -- 2.24.1