From patchwork Sat Mar 11 00:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 67909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp50428wrd; Fri, 10 Mar 2023 16:47:07 -0800 (PST) X-Google-Smtp-Source: AK7set96olGof9a7G16be6gjXQ/uB2cxbeIuLnQb4NR+X1XdtApjhQB4FPfBHQe0bG7e66RCwhvG X-Received: by 2002:a05:6a21:6d81:b0:cb:2a12:c5d3 with SMTP id wl1-20020a056a216d8100b000cb2a12c5d3mr31630821pzb.10.1678495627493; Fri, 10 Mar 2023 16:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678495627; cv=none; d=google.com; s=arc-20160816; b=O+/xaNtBw0uJBOe8vpS+99YGHza8Rpv+gGcYMfhevs+TK2EekiiVje5ZxWrdB3t12L 57sTgcnUmnPgMIdRvb/Ek5HyD+ezCP1lY+pYonMDtGgw9NYWIFOJhK0+kzg8LEht/5hi uFFXfcjJD+ut6MwoSX59iNpSufeJb5/eoNeXtvXYUS/IeFLATlJ8rJ4dl2Fr7qpBmOi3 IfGWRBmQvPsSMF/e17dqt1IbumMxslQn+IWs9IRZfHDN4LnF5CeXeZh2olY0bbU6+uaM f1tjR4rdwgqZDcj0U85IC4qcdBdDFY0SSz1tkuCnarFlBSEkbJNT27s3rNvdiMQxNiDF A7ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=k420FBXfSOkZfPbK6CTCgVzVsyCiPCfwaW2ot3JYIjfMmOB19IHyFfdSqxTYgItUBI 3eQ3THg1aZNHEAOwq9DXmg53Jq2PvBh6R4m3bMEUsXg3gf9/FVtpM9n2KUKs8HGk15jL qu5EBLaUAWzcZ6Z5N8kjEUTBp4CVPuOfpNRgolJvBR7AcqXiPRuLszFONqHoK6GmienT ZxL+ABPw1Z4XzKRhnWN9GhLzPdm0EYLvr63sMITHXyToC1JEbMNUzvItCXrSSowjKlr5 59miliEmOBOfLCrW/2m0Y0GSIjF25CUoZM88vkS8dfwJGd6Mxc9/U3CInl0ege5TulVs 6t1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a632601000000b004774a024588si1037215pgm.719.2023.03.10.16.46.51; Fri, 10 Mar 2023 16:47:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230520AbjCKAlN (ORCPT + 99 others); Fri, 10 Mar 2023 19:41:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjCKAkr (ORCPT ); Fri, 10 Mar 2023 19:40:47 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1FC13B28B; Fri, 10 Mar 2023 16:40:20 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id l13so7748197qtv.3; Fri, 10 Mar 2023 16:40:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=b8xlkMmx2Va+LMTaL4tjD8wYbm4UC16eGq/CrQTHkbnm9E2UfknGNDOooRPnWFHGH6 HXTiYXZS1Z4zgkWMhxH4u7I5AbqAc5eeOZhtfDX036xKJJ+55cFVd3c276/H96DePLC8 NxCS1PwmJLpvBg7BPQFk06uiCf28nVWffj5kbhUi3KznMOjevla6Bq8op4cw4ED6lVfx 6utHCbAoUN93i+J0xNphYV6jvsuIXhNDDr9S6CzOTcNB+n/aroO0U+CSERlTywJM50e6 ZLL4BiS8iPRnwj68gAb4ZS7lToep1wKzor8UHnBFdOyaf37GDfSlrp6Wutseal3QZY+N YWAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495216; 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:message-id:reply-to; bh=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=WcEJQl+74H0HBoFCpm3XER4uC5sPOXs4186zlVu3VSTM9EW7KkCbA1B3ktiGA2yb37 JZHxceZjQ7w9F1FKz1qZpo4mHp+WVLmdfvoFQZJggOSyr+t+Gvo9t9LEm02jYPuCzxbN E9UHZKIaZK//oh4dHIIT6hxk24lUNG+ofEopxB+RniiaA52Ime8yPJK1uvuPFpTAA6K9 jks2nxAqEI8H6NdexDCurGy60W7StygFTW4hB647bS3Vip+kw/0GSeHtCQ5xe1UcIEFa NK5YEpsI1+pwCFpIVJEPYww3AlXTW9pPDkqNvR/C8WO74nW6zIX9x7c9KjgXdNUb+8v4 uZyg== X-Gm-Message-State: AO0yUKWf1++j8yWycFvI/mYawxngxhllT0WaC5Dt+EVgbWf1D3ye5z/H QlG6SQppFAFHZCztQkULKMA= X-Received: by 2002:a05:622a:5c9:b0:3bf:d366:50d5 with SMTP id d9-20020a05622a05c900b003bfd36650d5mr42637917qtb.56.1678495215959; Fri, 10 Mar 2023 16:40:15 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:15 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 9/9] mm/page_alloc: allow base for movablecore Date: Fri, 10 Mar 2023 16:38:55 -0800 Message-Id: <20230311003855.645684-10-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760030231291506816?= X-GMAIL-MSGID: =?utf-8?q?1760030231291506816?= 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 6221a1d057dd..5e3bf6e0a264 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3353,7 +3353,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 @@ -3363,6 +3363,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 d4358d19d5a1..cb3c55acf7de 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8504,9 +8504,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) @@ -8521,6 +8521,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); @@ -8543,17 +8554,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);