From patchwork Wed Sep 28 22:33:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 239F4C32771 for ; Wed, 28 Sep 2022 22:34:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08C86B0072; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9106B0087; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9329A6B0088; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 82AE06B0072 for ; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5EF2540F55 for ; Wed, 28 Sep 2022 22:34:10 +0000 (UTC) X-FDA: 79962948660.25.A253A0C Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf06.hostedemail.com (Postfix) with ESMTP id 1720E180005 for ; Wed, 28 Sep 2022 22:34:09 +0000 (UTC) Received: by mail-qv1-f53.google.com with SMTP id w9so3199538qvn.11 for ; Wed, 28 Sep 2022 15:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=kc8MnC2tZjfyT1OHr7oem13ar6CbGvXTPlsJPg4ls4ohROc83adATaBlEJCZezeH1C vsZ5oUUA+B9L0g+Bkk39PLzeubyp2DyfVoJoZ9Zuq2Qsb8+StameSMoVBPuMt3bVCnRL coy4RGa8VfE6Rbw622dqywhJ4WJzOSAvVN20qhVzwAACdHRDu9rFPEkPLP2ljJiJY43l IqGSh57dsBe0H2HHsWh1998DsIFN/Qm+GtfjxXU8olPYvmv6jkBMS834HsYzg10Atmro bL25Bin46Q5OK+V8UdIyXx7CaaLqS7R6BnZCiF4UnAN1AD9nXKL/uUXTGBwtWYMMWzbv oyAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=sBu0bxY4N6GVontXd4dyqoF8oa/BunFZoe3KZSbTKiadT9D1NKBv+s+nG8ySQ/fA3Z QBKo09jyElF9AQyLEgFy5RvILemZmYDsQRRE+gSPAuf9TsQZShrPVmsb3G8hrSO688H4 KF7MExX3RaBmvSJemlFdrSxkuA5V9APx08L09/RSz3IgmOTwaNy+0y+XD8EDDeVipYee JmHHbO+Yw5Ltk5KxdBiLjcxD9EEtjRnlxVbk6TCYLMrxAOQwl/j0yNB9ADBQWY/AYU4j I9xgTNx7j2AkxIGW+CVLmRqr8Hrajg1vD6SEwYoFIHsdz5OMH95odq6xl174vikgz/5+ kIFQ== X-Gm-Message-State: ACrzQf0ElPP1p1uVtzKpnAH0if099dZ9suZ+Pwbfs+sdOeq9P5cwTp4T xsdVti1mT38ZE8ckBjlrI+w= X-Google-Smtp-Source: AMsMyM6VoQtRRInmPkH9hx0tn+zQ9wF1eVVy8Cf8ySuI7caOUVeCsNTyQ/vn10yr9RGUky2CsTBgnQ== X-Received: by 2002:a05:6214:2301:b0:498:9f6f:28d with SMTP id gc1-20020a056214230100b004989f6f028dmr277150qvb.5.1664404449183; Wed, 28 Sep 2022 15:34:09 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:08 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 9/9] mm/page_alloc: allow base for movablecore Date: Wed, 28 Sep 2022 15:33:01 -0700 Message-Id: <20220928223301.375229-10-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404450; a=rsa-sha256; cv=none; b=AS01FdYl5eAYTWPDuT8mNd60TnNg6qR/xOCDMWn1um8MLNkRCsciMp0zZ0nVwsiCBrDrcO wuhaKz1kA8mPJaIUy5HVw7v1BsTM2Ux5updkunOnHC7AQEBkKYMVsyPYKjsCoHCpAcZrQG vyB+ObGrzHGJggrYiiRfpFBCziKfQpg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kc8MnC2t; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404450; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=fj96iXFe/XrVwngRP56SO8+AvK+Mix6ZyC1zYi/4RlOBxxPZpDnggptPyi4R60CM0t0qLr EnKfSP52iIZsV2qe5aBqPEzzQ/N8zZtdJGJqCB4ET7claR7qMGoDTTNakZeNAK5DICFJxd xlOkMRfNMNaVALGTs+rIb3N/uGwls0c= X-Rspamd-Queue-Id: 1720E180005 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kc8MnC2t; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 36trkegw19nfeu6hp89i3cgq8yb5p1ex X-HE-Tag: 1664404449-556763 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: A Designated Movable Block can be created by including the base address of the block when specifying a movablecore range on the kernel command line. Signed-off-by: Doug Berger --- .../admin-guide/kernel-parameters.txt | 14 ++++++- mm/page_alloc.c | 38 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 426fa892d311..8141fac7c7cb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3312,7 +3312,7 @@ reporting absolute coordinates, such as tablets movablecore= [KNL,X86,IA-64,PPC] - Format: nn[KMGTPE] | nn% + Format: nn[KMGTPE] | nn[KMGTPE]@ss[KMGTPE] | nn% This parameter is the complement to kernelcore=, it specifies the amount of memory used for migratable allocations. If both kernelcore and movablecore is @@ -3322,6 +3322,18 @@ that the amount of memory usable for all allocations is not too small. + If @ss[KMGTPE] is included, memory within the region + from ss to ss+nn will be designated as a movable block + and included in ZONE_MOVABLE. Designated Movable Blocks + must be aligned to pageblock_order. Designated Movable + Blocks take priority over values of kernelcore= and are + considered part of any memory specified by more general + movablecore= values. + Multiple Designated Movable Blocks may be specified, + comma delimited. + Example: + movablecore=100M@2G,100M@3G,1G@1024G + movable_node [KNL] Boot-time switch to make hotplugable memory NUMA nodes to be movable. This means that the memory of such nodes will be usable only for movable diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c07111a897c0..a151752c4266 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8370,9 +8370,9 @@ void __init free_area_init(unsigned long *max_zone_pfn) } static int __init cmdline_parse_core(char *p, unsigned long *core, - unsigned long *percent) + unsigned long *percent, bool movable) { - unsigned long long coremem; + unsigned long long coremem, address; char *endptr; if (!p) @@ -8387,6 +8387,17 @@ static int __init cmdline_parse_core(char *p, unsigned long *core, *percent = coremem; } else { coremem = memparse(p, &p); + if (movable && *p == '@') { + address = memparse(++p, &p); + if (*p != '\0' || + !memblock_is_region_memory(address, coremem) || + memblock_is_region_reserved(address, coremem)) + return -EINVAL; + memblock_reserve(address, coremem); + return dmb_reserve(address, coremem, NULL); + } else if (*p != '\0') { + return -EINVAL; + } /* Paranoid check that UL is enough for the coremem value */ WARN_ON((coremem >> PAGE_SHIFT) > ULONG_MAX); @@ -8409,17 +8420,32 @@ static int __init cmdline_parse_kernelcore(char *p) } return cmdline_parse_core(p, &required_kernelcore, - &required_kernelcore_percent); + &required_kernelcore_percent, false); } /* * movablecore=size sets the amount of memory for use for allocations that - * can be reclaimed or migrated. + * can be reclaimed or migrated. movablecore=size@base defines a Designated + * Movable Block. */ static int __init cmdline_parse_movablecore(char *p) { - return cmdline_parse_core(p, &required_movablecore, - &required_movablecore_percent); + int ret = -EINVAL; + + while (p) { + char *k = strchr(p, ','); + + if (k) + *k++ = 0; + + ret = cmdline_parse_core(p, &required_movablecore, + &required_movablecore_percent, true); + if (ret) + break; + p = k; + } + + return ret; } early_param("kernelcore", cmdline_parse_kernelcore);