From patchwork Thu Oct 20 21:53:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13014053 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 2D817C433FE for ; Thu, 20 Oct 2022 21:54:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1AAA8E000A; Thu, 20 Oct 2022 17:54:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCD0D8E0001; Thu, 20 Oct 2022 17:54:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A92EC8E000A; Thu, 20 Oct 2022 17:54:40 -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 9C3AD8E0001 for ; Thu, 20 Oct 2022 17:54:40 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 576831C6C35 for ; Thu, 20 Oct 2022 21:54:40 +0000 (UTC) X-FDA: 80042682720.18.4131AEC Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf02.hostedemail.com (Postfix) with ESMTP id ED9F18003B for ; Thu, 20 Oct 2022 21:54:39 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id h10so614199qvq.7 for ; Thu, 20 Oct 2022 14:54:39 -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 :message-id:reply-to; bh=k0ZvpnVNYZiRg/rCuSdzxC9eb6lzs9TieDFdQySZsn8=; b=SZ1PlrYOPpSqmq/vLnLZafqj76vcgQtuklt87DwVjrckcKo++SoYbWCoXH2RuEmcb6 4y4tJhiFfNsKAYGCDqNldMQv8ggfF9el1/DuGHGyFTTgGJTgBB1ub2t8TJn/8VQ/0njh x9PBzyecXTaH7sPHGenWV53OQv2MF6VIv7XIRqYd6awOmsAXwfizyl7Pvu/dtb12NoEI FmlTxSQ26E38t9VXc438mbDPBM+Nsfx1gqnxiKl0224bwHFJKJ36YENdqiT+aCbkxIGU QeFvaN4zOD3HePcbtw0ZaU1yZSvLexZNzQIPkdE25F5wKPOiXAjcD1OSAUZXG39Xan4S LqVQ== 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:message-id:reply-to; bh=k0ZvpnVNYZiRg/rCuSdzxC9eb6lzs9TieDFdQySZsn8=; b=Bj2Z2A464jSm78VtIVBMPbC+3bMc5U/SBtOhQIjS3BtXWvkMV17NHxK7wM2umqnHWc NbZBP8a23Ledw41jVYERMrkP490fbSgdeQ9rnUE19wJfwuvBSqxHGrT+eEVlnRzFr5yR Z6//KRLMaxZVdM7CxXIQhq1LDm23JeEHT/NEQWNR+4Rt0NbcJBm94d65ayZSct0EzL3q csxRHUHbM6L9xzzcAs7GyFOen1LoghRihNkZdtpV0vCjaXa/lQeW0NnP9p/O/NnyCpEK 8VsetR4O8Eu7nJldoQ8e4QZpXIo9pC8pgleB6/OpfaArazpKjoIiZhLPaXMUf4GaTmMv bXRw== X-Gm-Message-State: ACrzQf2qgTNOQLBnr1WAGdf5KyCJ+fciDP0fJUc79Cr6RGWdnFr+rox3 NdhkuirP/rc8RXANV7s4Uhc= X-Google-Smtp-Source: AMsMyM7a38TE8ilGlotanmpyp3rhbuPFqLEEes3huL7M5Q8qh4Xm+gSlVT2+xpnn07tUAZEUhQLqSA== X-Received: by 2002:a05:6214:29ef:b0:4b4:5d8c:637c with SMTP id jv15-20020a05621429ef00b004b45d8c637cmr13527095qvb.77.1666302879221; Thu, 20 Oct 2022 14:54:39 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id bj41-20020a05620a192900b006bb29d932e1sm8121067qkb.105.2022.10.20.14.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 14:54:38 -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 , Vlastimil Babka , Johannes Weiner , Michal Hocko , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v3 6/9] memblock: introduce MEMBLOCK_MOVABLE flag Date: Thu, 20 Oct 2022 14:53:15 -0700 Message-Id: <20221020215318.4193269-7-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221020215318.4193269-1-opendmb@gmail.com> References: <20221020215318.4193269-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666302880; a=rsa-sha256; cv=none; b=xxac02sI3pf4qGSN0WXcjLpX3uBKY8ie6YII2aW6UqFnVD8NA6h2KRKQJ9TQ4rPxs0P9+d 5yNj/lY1zGvtL1W/0PwPcjZmY17b2Bmmkas4RkB40YAXe9ZLFb9YvvZPXUMahSY9Uekm1o O2ZnV6qpTRATTxtXczzneqRaWRH2bFQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SZ1PlrYO; spf=pass (imf02.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.46 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=1666302880; 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=k0ZvpnVNYZiRg/rCuSdzxC9eb6lzs9TieDFdQySZsn8=; b=Tk9ZpwgPDARDYBaMRBN7J8sycSbVg0fAV9p1Q1ssS+CpJmDsUBGODU3vX79EX/zkdAeFTG JY10Um9WLEZSzfFwk53f1pe8zeAFVaEyLmyvPjva+I75Ex/zuFVLem1B4A7zTSTKn8SYmS Je+diCwl8spUoR6cgwD581QbvLE9K4g= X-Stat-Signature: 1ph413inyid6zmcdpe4ghjfkycxmcesu X-Rspamd-Queue-Id: ED9F18003B Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SZ1PlrYO; spf=pass (imf02.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1666302879-192275 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 511d4783dcf1..46a4deb07d92 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)