From patchwork Sun Mar 19 21:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 71900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp893463wrt; Sun, 19 Mar 2023 15:06:31 -0700 (PDT) X-Google-Smtp-Source: AK7set8sWNynA9s1Z/gR3P1jkPXiOd/+RqqaZ6QXYGp4KG7V5+IZ67iQJhYjkE5AjY8f/vnIAGIm X-Received: by 2002:a17:90b:1e09:b0:23f:7d05:8762 with SMTP id pg9-20020a17090b1e0900b0023f7d058762mr6536681pjb.23.1679263590867; Sun, 19 Mar 2023 15:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679263590; cv=none; d=google.com; s=arc-20160816; b=JKj0Wud/jiIJk7orvOq6qXQRwwmCdOaLDpxA61kuGzkGsxNkPL/PRa75kyUUMiuV/9 ejEcofaFVS3KeiTfM9EGx1qTtQ2iQ2bgOly6JyC6xy/lKZVoxefjSJviLn1sO1fSRutF GpiXeQQnlIdyIb3J2h1bSE3hO+wFgNq60M780cL6MOMqVJI6s7aPyEwMW0SGrH5EU13s iCc/LNEyAs6/t77X3KIaKQbJRkj+3ibYpLt1aGCWLgCnlZCwOfh8FmxvjDectE5BHdSS tVzch4qzI5eiXQjiZjF9+LU8L2qISG7qeD/3cssUNpGMo60B1VLrkYcnJ3Vz2JQTIQTK bN/w== 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=26pZEosbU4xGB6qgXEMEJK0JR82wYmZqc6u/6bp3w5o=; b=xP8Lik0KDlWy3SJS1Iv/LO83UVNRlIu/fI+KhUTNCrYXbDcZYBNGiq+mFtYfarJVSP ehlaF9HXI7M2nco/Ry67iete5dNkXI1p5mO5Hgh9G9mM1NFvUavkvwddYEZR+jKF+B+k w34tPir9pzM6MtfJaNPSZc8mVIaZqhbmP7CGmwHgGPRzLee8it0QZ9snsRgWSpxmVPUg nEEvvc4dkrjxD0b3rRl6Nc9QatGlcM0Gs/hdojmRpxP03FoZZUlqkVMlE8WGVf6toDxy FfNUCZBh46tIKv3n1bYGMClOhxQTYbZjo6ctv5KKPplES/EnbOmJFg3PjhXttl7GQd81 h3Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oXkUKnzy; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y37-20020a634965000000b0050b1994efafsi8372884pgk.877.2023.03.19.15.06.16; Sun, 19 Mar 2023 15:06:30 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=oXkUKnzy; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbjCSWAg (ORCPT + 99 others); Sun, 19 Mar 2023 18:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbjCSWAe (ORCPT ); Sun, 19 Mar 2023 18:00:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59AC914E97; Sun, 19 Mar 2023 15:00:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E836A611CD; Sun, 19 Mar 2023 22:00:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C11FC433A0; Sun, 19 Mar 2023 22:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679263229; bh=zekLhry5fbzdsyyFVJESg5+PbdXiqA638EXDFWo0PPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXkUKnzydDJ71mPtZtGDkbDpHakn4+vm9e5hsj9ZXIp26esqmpKA0HKya3tWcGwU9 hHaJ6/V57EkzRpGi8lnjrEYAjO5VItMs/Md0bbdadjwge+a9/WTyHI1abD1pUrKKYQ h9K7yRauBXU7Tw8Mq2jgvBEw9AE21CER4YwrQv5CWjBxfQ9UHdb/tQXfSG95r6LaJQ vBhjliYse44G7HvTmgehhaqQXcvX1kGezbx65UwsYMW0fffJYTYM3h1pRApRzerWw0 c/X95FgbZkXr+iJhGJ6iUvnfoAIV/WrZXrD5FY4iZUFuWW7Tdw/Lw0s9FGHu1TLONU lRE/6FdnqUlYQ== From: Mike Rapoport To: Andrew Morton Cc: David Hildenbrand , Matthew Wilcox , Mel Gorman , Michal Hocko , Mike Rapoport , Thomas Bogendoerfer , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/15] mm/cma: move init_cma_reserved_pages() to cma.c and make it static Date: Sun, 19 Mar 2023 23:59:55 +0200 Message-Id: <20230319220008.2138576-3-rppt@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230319220008.2138576-1-rppt@kernel.org> References: <20230319220008.2138576-1-rppt@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1760835498876283206?= X-GMAIL-MSGID: =?utf-8?q?1760835498876283206?= From: "Mike Rapoport (IBM)" init_cma_reserved_pages() only used in cma.c, no point of having it in page_alloc.c. Move init_cma_reserved_pages() to cma.c and make it static. Signed-off-by: Mike Rapoport (IBM) --- include/linux/gfp.h | 5 ----- mm/cma.c | 21 +++++++++++++++++++++ mm/page_alloc.c | 21 --------------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 65a78773dcca..7c554e4bd49f 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -361,9 +361,4 @@ extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask, #endif void free_contig_range(unsigned long pfn, unsigned long nr_pages); -#ifdef CONFIG_CMA -/* CMA stuff */ -extern void init_cma_reserved_pageblock(struct page *page); -#endif - #endif /* __LINUX_GFP_H */ diff --git a/mm/cma.c b/mm/cma.c index a7263aa02c92..ce08fb9825b4 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -31,8 +31,10 @@ #include #include #include +#include #include +#include "internal.h" #include "cma.h" struct cma cma_areas[MAX_CMA_AREAS]; @@ -93,6 +95,25 @@ static void cma_clear_bitmap(struct cma *cma, unsigned long pfn, spin_unlock_irqrestore(&cma->lock, flags); } +/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ +static void init_cma_reserved_pageblock(struct page *page) +{ + unsigned i = pageblock_nr_pages; + struct page *p = page; + + do { + __ClearPageReserved(p); + set_page_count(p, 0); + } while (++p, --i); + + set_pageblock_migratetype(page, MIGRATE_CMA); + set_page_refcounted(page); + __free_pages(page, pageblock_order); + + adjust_managed_page_count(page, pageblock_nr_pages); + page_zone(page)->cma_pages += pageblock_nr_pages; +} + static void __init cma_activate_area(struct cma *cma) { unsigned long base_pfn = cma->base_pfn, pfn; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 87d760236dba..22e3da842e3f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2280,27 +2280,6 @@ void __init page_alloc_init_late(void) set_zone_contiguous(zone); } -#ifdef CONFIG_CMA -/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ -void __init init_cma_reserved_pageblock(struct page *page) -{ - unsigned i = pageblock_nr_pages; - struct page *p = page; - - do { - __ClearPageReserved(p); - set_page_count(p, 0); - } while (++p, --i); - - set_pageblock_migratetype(page, MIGRATE_CMA); - set_page_refcounted(page); - __free_pages(page, pageblock_order); - - adjust_managed_page_count(page, pageblock_nr_pages); - page_zone(page)->cma_pages += pageblock_nr_pages; -} -#endif - /* * The order of subdivision here is critical for the IO subsystem. * Please do not alter this order without good reasons and regression