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: 67908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp50289wrd; Fri, 10 Mar 2023 16:46:43 -0800 (PST) X-Google-Smtp-Source: AK7set9RqZw5XjOzPgQnD6Npgc1bWiejpF0r2eh9cihFDNCjaLCDVCRZyqx/uV4b8BW/0qBRstZI X-Received: by 2002:a62:1dc8:0:b0:5a8:a250:bc16 with SMTP id d191-20020a621dc8000000b005a8a250bc16mr20289190pfd.3.1678495602811; Fri, 10 Mar 2023 16:46:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678495602; cv=none; d=google.com; s=arc-20160816; b=WVkIWOMFbG6fmfR8uNZciTn/SKtxT+tozGYD+jozNH3jy2qrBM1BVDLXWe3m8yygv3 EJwowepj6bl3jYI1aq0tRyGq6UwcytmdaLRZ6tTmLe6fFBtaO4/rPUxLSGLxrliSRAdw tFWmh6q/fzLGCLtrHbtOUh8p9di7280PGOxfRct/LgFMfsvlygz0WxjDoJTs7QQrGxIj o7I9uwYICke/vQ6B9/vC4yZXQevYjabsSNvniTJwatR01uEsKcPzAUFsvUuzugw3cf/F PvvONb0aKtUwz1Agm7oQ4Ui9Kwhd2yvpOy5QrjmjOG02KwI/Qb3AlfglESE61NCWguQP ek4A== 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=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=mSlZHq/BjF+//WbhN8+J1ZYafddTSuAGiF7z3TW/z2+0tJ7/Rf4RsV+8uAfUQsSVzZ zDNUAoihcdRC/nE9QN9/UubPDE9jk8Rsg2ET+1QzbkLOcRPvJXl43zVHM61kjtFfjnai IMOnTjIbEkp036qzC62xzBPBbUSK+nb3+R4lHaa4dkEa80hvLrh9rXDzTjRo7FXCC2Ty p6YF3CAXipJ4rSHe7BMCkjeyZ91HYnzjFlUOC6RTTK70JurEA+Tytl70aQJzw9AyoaEf PahbJ4aZsibV+tkTasETNr/Mplm2oDJYPftdPyu2diGfY5RSZJwey8JreGfJNlqTJbk3 RLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gYseOYKW; 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 b2-20020aa79502000000b005cd33628c0fsi878432pfp.177.2023.03.10.16.46.27; Fri, 10 Mar 2023 16:46:42 -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=gYseOYKW; 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 S230192AbjCKAkf (ORCPT + 99 others); Fri, 10 Mar 2023 19:40:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjCKAkU (ORCPT ); Fri, 10 Mar 2023 19:40:20 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71ACA139D3F; Fri, 10 Mar 2023 16:40:06 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id l13so7747881qtv.3; Fri, 10 Mar 2023 16:40:06 -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=WhVlndF5Bb4OF7zrC0OZQ3hQ92G6RMhm6JunaDo1YU81XrU41IxDquIEbfpXtbTJul Ojim18CbCSWswyP2qfRPClo1Eakt+y6fO2C/eK+TKb2f2sDYPRgxrOXpCnNtiDVPjHRf eNTABcX8cK9HIbudURmOn+jzik3o3jioO6tIgWevKmdEk8ZLsVQQoR/ESZj4AuPs2y7F kPLNiTLDVaOmRm9LKWLMfaqwhORShC8b0zi0qe4E2DY7gF7AOWYVNYJdRsznVS9LzWXC rKDWEwdN4RSIC38bnuSucty/2Ni3W1FIxQwUKnvOHrNYJTG9x6wth/G5GvmzMg8ulNbL o3bA== X-Gm-Message-State: AO0yUKXmv0tRq5J5L5owNNn7SzYIBJjz282U80sXaDlSGw+yctR57PXF HHl9MzhRQhdcZUCu3B8/j0s= 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-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?1760030205332034225?= X-GMAIL-MSGID: =?utf-8?q?1760030205332034225?= 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)