From patchwork Wed Mar 10 07:15:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12127153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7FDDC433DB for ; Wed, 10 Mar 2021 07:18:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0414C64F97 for ; Wed, 10 Mar 2021 07:18:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0414C64F97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8A94F8D0177; Wed, 10 Mar 2021 02:18:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8807F8D0148; Wed, 10 Mar 2021 02:18:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7485C8D0177; Wed, 10 Mar 2021 02:18:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 58DF48D0148 for ; Wed, 10 Mar 2021 02:18:51 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 49BF2180ACEE9 for ; Wed, 10 Mar 2021 07:18:50 +0000 (UTC) X-FDA: 77903112420.30.D19D100 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf03.hostedemail.com (Postfix) with ESMTP id BFE4EC0001EE for ; Wed, 10 Mar 2021 07:18:47 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id a24so8016330plm.11 for ; Tue, 09 Mar 2021 23:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pXWkEpHfeuofSvkF2rXCRT+BvK4vU6jK5MQilOA5vKw=; b=Tyud/GHIH0dgt6aYgsfzCiNwIEsV6xRhkJ9Q9Wwvgkm7Bz/m3taQq/EVcILyQlJ4t0 OCRXRuT/ud0hIi5IVpDkkHDNXFwGPjlUxF7P5T96YtJEXiVzicNIZ4KOA2P3iaNm/4fF 0IdJDctkPSkdIYw81XMd5u3CHTEuPPS209H4QPNt12XKGTbejKmt6vIDzvkVXbPmtfr3 xyvSljYHdZwbhybcBw28HeK+A+pALSULAC5gojHPXudQczeanLrNCzSgbktl6A8BGdJF CAj7AvFeI9TihJ42DcRj8ujsYjDnyO3Q5yvBIRg6vQRmBpCrhfabOeWaNykRUnUpAmJ+ 8QXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pXWkEpHfeuofSvkF2rXCRT+BvK4vU6jK5MQilOA5vKw=; b=D7Ih3kxajaq7gYMmZFEx+GjcRygInUpQfy6xnD5s+h3Z0eD5DID2IOwAsc+aqpVsZF h4xLU7an1Mmi7IgBBGbV8OwgP8IkDEiM6dNHk0C5HxLMrQTQz79cLUCihyX1IIkBHYoo iNDTYY48yb1c3t5EhBVhrq2ygH9uaCmg5FVThC/1g3B0fPiDYV6OqfSIRaYrKSUkn1FD w9TeK6PfrIBUQTmWWIKUBqmv78lg6sLgcjPWRHCbjekSg9TkUC7y9D05WZVYkPHlJQnT 9xTzG0+JYTq2xkUjHaoFZKdGK7ElsYBLJWvX7M2adH2vDS023F1+XVnBVIp47nUUb5ji nhDQ== X-Gm-Message-State: AOAM531b9M3nmvZAMPaZHs5UGvkrTCLBt7TouDaV5EBsT/xGJaCNO5Pa oVN33wkP73ip/kb9MRFP/8A7bA== X-Google-Smtp-Source: ABdhPJxyJ/btALuDsu0SeQYdLFebI/E042dTZnHmOxOdJsJ1TP8Y1eFAv0pn/8jZN1lc4hNkZrvUtA== X-Received: by 2002:a17:903:92:b029:e4:bf7c:cbf with SMTP id o18-20020a1709030092b02900e4bf7c0cbfmr1611247pld.55.1615360728977; Tue, 09 Mar 2021 23:18:48 -0800 (PST) Received: from localhost.localdomain ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id h15sm2828868pfo.20.2021.03.09.23.18.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Mar 2021 23:18:48 -0800 (PST) From: Muchun Song To: will@kernel.org, akpm@linux-foundation.org, david@redhat.com, bodeddub@amazon.com, osalvador@suse.de, mike.kravetz@oracle.com, rientjes@google.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH 2/3] mm: hugetlb: introduce arch_free_vmemmap_page Date: Wed, 10 Mar 2021 15:15:34 +0800 Message-Id: <20210310071535.35245-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210310071535.35245-1-songmuchun@bytedance.com> References: <20210310071535.35245-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: s3py6bgz94ciw48i4k55gkhigqa1up1b X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BFE4EC0001EE Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-pl1-f180.google.com; client-ip=209.85.214.180 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615360727-765385 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: We register bootmem info for vmemmap pages when boot on x86-64, so the vmemmap pages must be freed by using free_bootmem_page(). But on some other architectures, we do not need bootmem info. In this case, free_reserved_page() is enough to free vmemmap pages. Currently, only x86-64 need free_bootmem_page(), so introduce a default arch_free_vmemmap_page() which use free_reserved_page() to free vmemmap pages directly. On x86-64, we can implement arch_free_vmemmap_page() to override the default behavior. Signed-off-by: Muchun Song Reported-by: kernel test robot Reported-by: kernel test robot --- arch/x86/mm/init_64.c | 5 +++++ mm/sparse-vmemmap.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 39f88c5faadc..732609dad0ec 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1575,6 +1575,11 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, } #ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE +void arch_free_vmemmap_page(struct page *page) +{ + free_bootmem_page(page); +} + void register_page_bootmem_memmap(unsigned long section_nr, struct page *start_page, unsigned long nr_pages) { diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 60fc6cd6cd23..76f7b52820e3 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -156,16 +156,21 @@ static void vmemmap_remap_range(unsigned long start, unsigned long end, flush_tlb_kernel_range(start + PAGE_SIZE, end); } +void __weak arch_free_vmemmap_page(struct page *page) +{ + free_reserved_page(page); +} + /* * Free a vmemmap page. A vmemmap page can be allocated from the memblock * allocator or buddy allocator. If the PG_reserved flag is set, it means * that it allocated from the memblock allocator, just free it via the - * free_bootmem_page(). Otherwise, use __free_page(). + * arch_free_vmemmap_page(). Otherwise, use __free_page(). */ static inline void free_vmemmap_page(struct page *page) { if (PageReserved(page)) - free_bootmem_page(page); + arch_free_vmemmap_page(page); else __free_page(page); }