From patchwork Sat Mar 11 00:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170543 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 AB12BC6FD1F for ; Sat, 11 Mar 2023 00:40:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A8258E0007; Fri, 10 Mar 2023 19:40:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4586F6B0075; Fri, 10 Mar 2023 19:40:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 320628E0007; Fri, 10 Mar 2023 19:40:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 232196B0074 for ; Fri, 10 Mar 2023 19:40:08 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EF9B5803AC for ; Sat, 11 Mar 2023 00:40:07 +0000 (UTC) X-FDA: 80554760454.27.6C81A6C Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf20.hostedemail.com (Postfix) with ESMTP id 285911C0003 for ; Sat, 11 Mar 2023 00:40:05 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gYseOYKW; spf=pass (imf20.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 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=1678495206; a=rsa-sha256; cv=none; b=3VgFE4inh6w2n4PACNqOFDawszmSiGMIo+V8oSgIoO/B99oK2FN5Mhx8/p94wWXLfWLFIb +e9GjSLhkqWYmu/kU3qO7RpQqnZwyqSRp4k4MjVT7ZI3Km9lEGEin88G8IEAaxyTVS5zw4 0cHDK0ulBndld6Qmb9bVv3e9ZHDjsvE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gYseOYKW; spf=pass (imf20.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 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=1678495206; 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=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=pzmOGkN8YLdM1rl26/krjI/ifGHLPbUj6kcMEACRXC00t1mPQmWzi2KGEfkxEsMxBowwD6 qqaVdw+PQyOi5mZku6+ArMFnbik+mtCZE2r36KJc9/7DhjYnAtFk9TD180GhUuJdajX2pr 8Pyq1j1EMFotg1cSlrFnyYzyU+CpxcE= Received: by mail-qt1-f179.google.com with SMTP id cf14so7704117qtb.10 for ; Fri, 10 Mar 2023 16:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495205; 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=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=gYseOYKWDMGUISiNkRcjSjvTTZsw5ZpxUtUzYky9ZIu/8x2vFtu1Ubj2/1NfS4ntqc hX/h/yEUyA2imIDBGlqwTwoMvCjauAQN3YL66devi+3PsmAyF6mABKzTGpk4hMd7icxM YEG/1j8Vk1YoVpNOoeMrCgh/Uo/Rnn3iQf+MpFu+gZkimrhV0E2qnQdFooilVD+K/hHa rndAxQ/V0FYCu+PEVJ8K+hWV4ROJd99Mv7LFTpRov8IlSAc9cA6LofsPSnb+8TjoRVr2 L5hPzI4NrF/E1TKlZrGIJ2bO/Ipsdij7LIspIYw/JuzSHIXAlX+sgOjl322atMjd1034 P2GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495205; 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=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=7QgCm63eD//+QBZN3HeggpMi8EMq8kfCN9XhJIOz/CTSmRJIi2H5V8F52/zvU1H10C zAnSC0MNg/JefJjBfAc1kN10bsmIt2ocebLPuCmy/EJ7utnTNtQPkBCG2EjpDbG7gYz3 cKW88bq2PwELDNdbilHPHk0xI83GuGPoJE+OqnCjSiqfj+Yl4uoddGUp2Ky0K6HaWcQc +qy9H1Q3rKlU34C6EENs1fFxDohnyropfOXnetsrZiACdfZkaUmPHXWl8PhLogqGE1Nz pULyBoTxCv2XggkYDzrlCAUdHBsFfxEU6X4SoZbrRO0jiIEjGNdId0G0KqkVVlXKDIE2 Xitw== X-Gm-Message-State: AO0yUKW9Y7uce+5VXV3Yc/HIiRvW9CNov+IiBXTqjwJWKwW3RP1hzSFc p+ADJxf9l4L3vDs52Js7sEY= X-Google-Smtp-Source: AK7set8ZGDP7wAjGGI9tJbICfiwjsQBTns3pou3iyFBkgtdpeY6NM2VuirqgiTSIHG6uE67a1R8tZQ== X-Received: by 2002:ac8:57cd:0:b0:3bf:d9a9:25f7 with SMTP id w13-20020ac857cd000000b003bfd9a925f7mr12075430qta.6.1678495205288; Fri, 10 Mar 2023 16:40:05 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:04 -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 6/9] memblock: introduce MEMBLOCK_MOVABLE flag Date: Fri, 10 Mar 2023 16:38:52 -0800 Message-Id: <20230311003855.645684-7-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-Queue-Id: 285911C0003 X-Rspamd-Server: rspam01 X-Stat-Signature: nc5jpsqyn1eafunj1jxucyeuxzfu6p3u X-HE-Tag: 1678495205-252445 X-HE-Meta: U2FsdGVkX19oEEW9ewdtKKnHyB6rc7jrNT/a2UtWwC8ivYU7ABIhuwe3oi6XaG3ve04lnfgfrs5GAh8vvJKryNf28paL+tK/zNNTNd20v88yG3aG5VLbV794Ouiu/t+G6UfZsWEnB8uJpDLdnA8dIA/8gH4Lx7ShVOkKo5jyVbCkbQekg8J0z1i1HEeTx5P1aDg2GsgbQ1jbujMR16SDKdLyi/TIXHNSIiZ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WJkuUsLW4uaMIbh0Z82+wDDcicuzuuzj5BFH2lrbSfPP83aoF7aw3MVx8hmOpMltNaCVXQnilFPwBa+3ZiYi58zQpT8rGRU62oNJRWNK+NQs717Mx4aF2HuAKCpkT32BJPLt8n2dYiD1RiUtkvIqpW+g2qvYrfbYKbaR1n/dWUCGeu7hbR+OqTZSvOorvzxOSHInVTuqsE2KdhygfJ2fYfv2AD2t3BiAbatJKu8PBxRkDEPmIPIPA64hqollWHt9IS7GKcK7MVIXkYR8= 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 25fd0626a9e7..794a099ec3e2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -992,6 +992,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)