From patchwork Wed Sep 28 22:32:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993205 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 CF2F4C04A95 for ; Wed, 28 Sep 2022 22:34:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EA736B0081; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 699EA6B0082; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ECD16B0083; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 40BB56B0081 for ; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EA75F40F47 for ; Wed, 28 Sep 2022 22:34:01 +0000 (UTC) X-FDA: 79962948282.04.4444AF2 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 8BF8040009 for ; Wed, 28 Sep 2022 22:34:01 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id gb14so251616qtb.3 for ; Wed, 28 Sep 2022 15:34:01 -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=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=XG34Y6tDaJWwx6DqjTOFzsu9FQfdW30BYf0FXo1qOyK2ddb1gPjKGPuXlnXn7WJbbp 3at5ITh2zqc5ND+psxUlpktCRqb1IAzsURp8laAwU3meMWmslVlJ04PurbIm8TjZW067 nvbJ2vgFDTno5HMU+Gfi0PWAZYLTaVzf8H1Dyc6ZNAhhNr+6tXQhmbbkKh+4XQNl5zF1 K+hxIbMy/hJCcqrK4JjzhlxcdtKPFgihmjVSBLcdQYwclydS6XWbaKLgt1yT+hrAmziP mvTMSR2mIOdkNftizVll21ORt676/ts4LNcVaPrB5p5YHLQb1rddtODGPalGlxkiWHGt FAtg== 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=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=5XlRjAwQml5hy9JnwpQMcjyvM/xRWvf7/+uKGNV2EvFQAWjpmMn4/eThEpOr1Scw6O 5wGbmT8AU6lCOcDvFvTyfzwMxy96UFZc3YwFGQztssskmmAyLgMcQD+qvdgC+ksiS7Wb /XwGVXGx5dyODa0sRpwHdGu75IqgeC7if3BX6ivJKb226UwB7Fqogt4F1nUYqMnk91zV 6i2k3V0wujNCt62sDrbIM8bVWJK19PhQVSKFKEIZtJG2jqSQrBe49U7sK9olKA/Ugki8 O0wnxHqwAczarvHB2tWr05A2Jvxx0f/ZS5PMFiEyYNqZwKKTCp0Mv+1nHIZcaaFKUflE ErRg== X-Gm-Message-State: ACrzQf3Rz7y2+XhqwBnK9LShg9ukHh8YMTMsV2G5+33yO9o60aZWdSOV Huu4S22fxk8ZwhNmB12rcvg= X-Google-Smtp-Source: AMsMyM5hls3k73DLDHwmozK6Fn+6fum9LVyQsQgOKR/Uau82IHif8GbeTAVnzUtgkLXNeRQjKZrgzg== X-Received: by 2002:ac8:584c:0:b0:35c:ceee:197a with SMTP id h12-20020ac8584c000000b0035cceee197amr50280qth.662.1664404440788; Wed, 28 Sep 2022 15:34:00 -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.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:00 -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 6/9] memblock: introduce MEMBLOCK_MOVABLE flag Date: Wed, 28 Sep 2022 15:32:58 -0700 Message-Id: <20220928223301.375229-7-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=1664404441; a=rsa-sha256; cv=none; b=FXl6lawteknIyXvtYfmFv7S9t6vZnkIy13cwhGvT2GdLnpQeog1bzz45pu/VjYdtVGTFo2 pyBUwqkoxnjhkmaA4tEE7KLtFXxXYRO3LZdLBqyoXu/zgBC6M4XbCj6mRYH09Ye4kfp33Y Qhw+H2ZYE8bPo0wcMU+bEkFdUY2Euos= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XG34Y6tD; spf=pass (imf12.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 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=1664404441; 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=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=0Tuc8L97xvfHYlHOlrOjCe5DfwImxYtHvZsdLl0PJAdW/F2RgQzwPfPc+lUlHkQiexMG0Q rFDrpq0c/QGNilZ87gCaJRWungg6hlUpP6wSfseX+koYD3Zmi83ijaXcUGND92BJ3xZAc2 BdNpqaKMXQs/emU9LozMlNFOaSbaKco= X-Stat-Signature: 5y9o6qngb4uda1nx5gqz1nusf71kfu9f X-Rspamd-Queue-Id: 8BF8040009 X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XG34Y6tD; spf=pass (imf12.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1664404441-470294 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: The MEMBLOCK_MOVABLE flag is introduced to designate a memblock as only supporting movable allocations by the page allocator. Signed-off-by: Doug Berger --- include/linux/memblock.h | 8 ++++++++ mm/memblock.c | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 50ad19662a32..8eb3ca32dfa7 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -47,6 +47,7 @@ enum memblock_flags { MEMBLOCK_MIRROR = 0x2, /* mirrored region */ MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ MEMBLOCK_DRIVER_MANAGED = 0x8, /* always detected via a driver */ + MEMBLOCK_MOVABLE = 0x10, /* designated movable block */ }; /** @@ -125,6 +126,8 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); +int memblock_mark_movable(phys_addr_t base, phys_addr_t size); +int memblock_clear_movable(phys_addr_t base, phys_addr_t size); void memblock_free_all(void); void memblock_free(void *ptr, size_t size); @@ -265,6 +268,11 @@ static inline bool memblock_is_driver_managed(struct memblock_region *m) return m->flags & MEMBLOCK_DRIVER_MANAGED; } +static inline bool memblock_is_movable(struct memblock_region *m) +{ + return m->flags & MEMBLOCK_MOVABLE; +} + int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, unsigned long *end_pfn); void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, diff --git a/mm/memblock.c b/mm/memblock.c index b5d3026979fc..5d6a210d98ec 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -979,6 +979,30 @@ int __init_memblock memblock_clear_nomap(phys_addr_t base, phys_addr_t size) return memblock_setclr_flag(base, size, 0, MEMBLOCK_NOMAP); } +/** + * memblock_mark_movable - Mark designated movable block with MEMBLOCK_MOVABLE. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_mark_movable(phys_addr_t base, phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 1, MEMBLOCK_MOVABLE); +} + +/** + * memblock_clear_movable - Clear flag MEMBLOCK_MOVABLE for a specified region. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_clear_movable(phys_addr_t base, phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 0, MEMBLOCK_MOVABLE); +} + static bool should_skip_region(struct memblock_type *type, struct memblock_region *m, int nid, int flags)