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: 12127157 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 E1B15C433DB for ; Wed, 10 Mar 2021 07:22:21 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3532A64F97 for ; Wed, 10 Mar 2021 07:22:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3532A64F97 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NFRPskNlCc+ykrcZuoPqtczGtBQWlYAWz+dHbwjF/0Y=; b=NLaIuaIvk0nOWX9aVKpKKgi3U RF85Zpgu4Bx6lYMn+lKFYTQ8IQMY0fYwQI68vZHTJLqSnl9wAAwnqnqX8EaPB6fVPMXGBTY7E3k6q Dt8DchJ/AT2OGHZzsg4N5szy67OlF0TLwSzCSLsqmW0BTA81Cb2+UlZ32kJDcrTo7OI/xMMn9VEiy e/cgMBrKdLzyxWH2/BenU7/ORg+c2aLr64Yz3o9/7PV8iiEfwWZEt7nahw/roXQEx8n9lBxmxKmxm R8lxFGdgZOKPlEcnllbN6nlkwReHK6O8jRMaEBvuOHwoouSVCN9hZFp5PlG2nyinii/gglEPs5KbD ho74ytkWg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJt7d-006COO-O8; Wed, 10 Mar 2021 07:19:09 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJt7K-006CKV-Ch for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 07:19:04 +0000 Received: by mail-pj1-x1030.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso6980555pjb.3 for ; Tue, 09 Mar 2021 23:18:50 -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=X5PdkZFydsO41l3e+2/kz5wO2rcOXKCe68VNeQkVzotFD5cJ4O3mE67rjHQMuPA5Vd TCfop67VSIXqWXMmlHHnzw5Y69JGhQasR8JKtaBWneKD8AIf6fPBU/+2ttQ4g/rwHAcS Kj20tZYJy2ngo9FJ/1H5ifasYPAQ7XCc9/9TVoGd6di+qFcSb4BzgqBnQQXNSlzdpPYN YVYZ3QiTiCc8o0TR/Hj9BUCXOF2s5hnQJ70PoxieYCuxZMHeKxl+vVChxGvdSYgNWPCu PdclRnsBxHIl5ohn0QXTzlUaEE9HFXXX3GXaxSaSuNFGOA6JVaNfeeQH0YMru0Us29s8 KmrA== X-Gm-Message-State: AOAM533Q1+NEkAfQt99+2ZMJHaYZEC3oWwBVitacercJSI8M+6s1TNcC FzLWHbNAhrBgjATjnToF/qpTpw== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_071859_920376_D228B424 X-CRM114-Status: GOOD ( 15.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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); }