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: 13170545 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 58AA6C6FA99 for ; Sat, 11 Mar 2023 00:40:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBA378E0008; Fri, 10 Mar 2023 19:40:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6A0F8E0006; Fri, 10 Mar 2023 19:40:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0BFB8E0008; Fri, 10 Mar 2023 19:40:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C162D8E0006 for ; Fri, 10 Mar 2023 19:40:18 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A27111C5E7D for ; Sat, 11 Mar 2023 00:40:18 +0000 (UTC) X-FDA: 80554760916.19.4B295DD Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf01.hostedemail.com (Postfix) with ESMTP id C651240015 for ; Sat, 11 Mar 2023 00:40:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (imf01.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678495216; 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=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=iKpNrUy2pV3YDj1eNN4yY/dqW2Kb6WV8eQeRIQS6sXbiGrbBMgWtycTW2MTJ/EyJrHBQwj 6wgn/E4ZiV2+xBqP2+J+fyMMGAPsU9GKNhAe1V49INj2jeVMNiL2S40etqfghx3NEhCvtn HIQNN9tkmtMToKv6MAu0EVHuzmYqdO4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (imf01.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678495216; a=rsa-sha256; cv=none; b=2xeNsn1RHl0/S0chvuZZUkbQ6inf4kfjxG6Y8uVeANvYzL+4PgjFyedW10RFm50jaU9m6c XaDyUDVBaGnYHPCAxol6nGeu5AUiRm5uoykF50Jes/8xUyqSiIIMGRHkge92BsYjW/jAyV +9MhPyxxu77N4sHXcJ4j98HH7F4L8cg= Received: by mail-qt1-f173.google.com with SMTP id l18so7766700qtp.1 for ; Fri, 10 Mar 2023 16:40:16 -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=UJ1r6trUXF7kYgx379STD8ET5luHz5KnAYY98+D97QTnShP0Dfu+rsmcpOfaAyC4k2 bUhTZSdlwzYsWFJ/Loe1qZihYPuYNphqxYC2HxEfv85nXgmmkoUcH4hNsTkyGMtb1grT 1ILYpkxIAOiFBl4PKJxRfoMzokvpVT3/iDiNQnkgnO14haoIPQZUaFOdRVofbtDAjIbq R43ytFPabNcf4GwkzAAt6BBjeJlfg/gtfjQ0Y+jkskszgJe1FWWidEX9MpXmBIoyI/RV /aiUsCSZ3FWig1JQs1YGaEUe9iasfwWfKDIgEOz2rTlHrrLVDptYnt/vlSu6sZonLq4C 2jlA== X-Gm-Message-State: AO0yUKUTD0gUNuaQqBrioqld72AB5bbUo03q+Pf77l7a+mQSKaP/XBgK QnnPgylexEQ1rv9fw7OC/o0= X-Google-Smtp-Source: AK7set9au5WlIK4MR23yBqVZHrwwWy+PuYch9qrfX49bao0ol0Y+CZl0Oj9zvXShGjOoENldS5rAGQ== 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C651240015 X-Stat-Signature: tks7pygnrpakmqhxq5qpd9izxfx6qth7 X-HE-Tag: 1678495216-135314 X-HE-Meta: U2FsdGVkX19/o16Xi6MzeC2jt0wNWYamjA5zZcHvHWXu4Q3+bPrMn/Vp45RFAW6O3bTiCuGdT04ssiGm83QEfaUxaxf3BD6NyIhGicx1qnWJhQboF50w7bm9EGZZHzMUavP9hDegWtQEN6EFtfk0POqc9e1kmKtN6XwsnyUACq2cpHVunoWXnQ8oqhkBElCYCQtD7auyKzZU96lSrdYOpFz5BvbWLrccFd2VnzAn+JYoBDDaJ+01zxxfsxj477tdC5YC2bM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8QgIJN57O9ja3UQi3+jQOrmzVIhwxnhl5XjJmK+axDKxJh5NQNjthS+n+vckI9GyUhh+kEphuwQrKpaBJc5/2qmdBeLUoHGpT/dGoxmiT4qrpV18+6XTlcjcgMpJXH8LXpDhmeFl8WsvICirTOZLHzQI5AaIaWiOrqM2lGZnpJcal8rVki2wMyKsku51kYmAM7j/FchwLtwafwM7vYQsHP0mcQNcQhvoRjre++w9P4= 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 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);