From patchwork Tue May 16 06:38:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13242583 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 87F54C7EE2C for ; Tue, 16 May 2023 06:21:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C31BE280007; Tue, 16 May 2023 02:21:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8E96280008; Tue, 16 May 2023 02:21:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D984280007; Tue, 16 May 2023 02:21:42 -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 1A7A8280008 for ; Tue, 16 May 2023 02:21:42 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E59404143D for ; Tue, 16 May 2023 06:21:41 +0000 (UTC) X-FDA: 80795122002.21.E54ED17 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf17.hostedemail.com (Postfix) with ESMTP id 6947F40006 for ; Tue, 16 May 2023 06:21:38 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684218100; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1iOwkSLnWEdCnxBRNGxTN2XwpQQBOKaFg8d13A7UZM0=; b=zf1Om5VlewfrolnAzOCqx3HuZh6P4nSuMog3ZwCsbiuAloOEYpM6GAc8XFsBb3IG+QGDuk o8xBpxWgQw/r6V8Mkp8E2ovjiyjPrL9WZBQZ3nmEEKiv1l1OqWpGTs2ZKyqEx/G0Chopmr 7ELKo24nzAnZGDPW8VjbbfvZI1Lu8oE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684218100; a=rsa-sha256; cv=none; b=Le0MTsxoZlwD1yDHcNasmU474XdtmUsFkqCsy0x5dOCAN9+Gk2OaS6zHwLcKrR7B30Ridy NGpxDg9MsS/saD+OzLe44hszFbYlpBt2RpEYi8MeDGifWfI/d8EnLdHSZS1SbJJLL3RcP7 IlMpNjI/WZCmljNA3uMd9XM//UO/aCQ= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QL5h00Tw4zLmCd; Tue, 16 May 2023 14:20:16 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 16 May 2023 14:21:34 +0800 From: Kefeng Wang To: Andrew Morton , Mike Rapoport , CC: David Hildenbrand , Oscar Salvador , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Luis Chamberlain , Kees Cook , Iurii Zaikin , , , , , Kefeng Wang Subject: [PATCH v2 09/13] mm: page_alloc: move mark_free_page() into snapshot.c Date: Tue, 16 May 2023 14:38:17 +0800 Message-ID: <20230516063821.121844-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230516063821.121844-1-wangkefeng.wang@huawei.com> References: <20230516063821.121844-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6947F40006 X-Stat-Signature: 5on7ni1x89u11fmkpgtph198tojsnqkz X-HE-Tag: 1684218098-830879 X-HE-Meta: U2FsdGVkX18myByktYR96kb3iMvbrI22qiZOBoSy/juBl36AkreXwLqbkfNa/R3bxUSWTWaTgoNPWKJAFqnT9YYks4JTVNukuXgfIlR1chPT56SCsqfuITPRdq2o55As9qMyplleL9ANThVWa3U8G/OLAqiPbL6Lr1ivf9HFUNGswvffRiI6eK3SHNCOdeKeA2t6BGP1HYDi1gN8CSssoipqiL/y+iaKLvAEJBg0izTz//CoTZi/gJssftI/T1NKXf6wvWV42206eSQOKDjd0ud/ljLvnYQR8A8Qjw6xoTDAAuYatfe+PHDFl+gFbmcHpkQLnJPcRRwMHb44bMOib+K0ltfqIxLDAP/r7j0R6ntD6QGaN1d13X9cABGOlhoaLmPXkmzunrWUJvVsosGFFTqGe4vfElSZbNRl2Lyz6bcIEPzS+7geddMjF4smxzFkW9vYLJ7S6qEg5ruan+K4QGiV80fsDq83tPqIAec5/PAZ4kCO5DtWtRdXD/D1rleIXEm4L5yqU23D3q1jrF1NGZYnFhf6hhO1PSLOpyJEtGRb+zZJUTT1CWpdCrIJ/eGlweOyYbxTagXSS89jfCiaf8YiCZYtYirhAC8uBTEEk3teCFT2eUjhwguTvD2Oj6f+AplIEicmjgBnN824SQv42QbcWkP7MG5MYVFY+3ZMll6K2rZwJK8P5BQC8dHeBTJ7BElZygK13+su4MVpB7ggGXG4GG0ldKIHuFceNHxtuAsYRG9AD2jZLNg2+Rdpo7JR4Yfuxnf1VQ35/shUDfBTYVVuoLCSU9oLRRrvi2yOD7iO/rYd557UWEW4j8Ey5U5sUsmgrMgniZCbFtr97IyGYl2+ngu7T/BT6xhDXN4/c8cHrtWvhO19pVRUwV0Te1kiRK1hqvGHxc1lKjg+IEq9XgpmJoalur7Wjp2ozeoueICoz+qlyDrq/EYtvTSxKMBd7zqxmvaF4OxEST/RhHX ddu6C7AM pIMWnVamOQGTMJI7LvwUHqZ/nxVvvWSSHkBEU0c2c6zcv+lDiskjjacKrYWOSMJrvrQqbAZWMf83FVk73nhEiV47H6EzVVsd7d6PveVk6j4kW0x7mHJzxHw4sqWqpTv/tz00B6gJ4UVm2XJpM/JjDJUGNtpEFMM4nIWYUm9rJYuHKQb/UylqzURvkzxrWKKZNU1wGw2XHeK7sKsE= 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 mark_free_page() is only used in kernel/power/snapshot.c, move it out to reduce a bit of page_alloc.c Signed-off-by: Kefeng Wang --- include/linux/suspend.h | 3 --- kernel/power/snapshot.c | 52 ++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 55 ----------------------------------------- 3 files changed, 52 insertions(+), 58 deletions(-) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index d0d4598a7b3f..3950a7bf33ae 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -364,9 +364,6 @@ struct pbe { struct pbe *next; }; -/* mm/page_alloc.c */ -extern void mark_free_pages(struct zone *zone); - /** * struct platform_hibernation_ops - hibernation platform support * diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index cd8b7b35f1e8..45ef0bf81c85 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -1228,6 +1228,58 @@ unsigned int snapshot_additional_pages(struct zone *zone) return 2 * rtree; } +/* + * Touch the watchdog for every WD_PAGE_COUNT pages. + */ +#define WD_PAGE_COUNT (128*1024) + +static void mark_free_pages(struct zone *zone) +{ + unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT; + unsigned long flags; + unsigned int order, t; + struct page *page; + + if (zone_is_empty(zone)) + return; + + spin_lock_irqsave(&zone->lock, flags); + + max_zone_pfn = zone_end_pfn(zone); + for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) + if (pfn_valid(pfn)) { + page = pfn_to_page(pfn); + + if (!--page_count) { + touch_nmi_watchdog(); + page_count = WD_PAGE_COUNT; + } + + if (page_zone(page) != zone) + continue; + + if (!swsusp_page_is_forbidden(page)) + swsusp_unset_page_free(page); + } + + for_each_migratetype_order(order, t) { + list_for_each_entry(page, + &zone->free_area[order].free_list[t], buddy_list) { + unsigned long i; + + pfn = page_to_pfn(page); + for (i = 0; i < (1UL << order); i++) { + if (!--page_count) { + touch_nmi_watchdog(); + page_count = WD_PAGE_COUNT; + } + swsusp_set_page_free(pfn_to_page(pfn + i)); + } + } + } + spin_unlock_irqrestore(&zone->lock, flags); +} + #ifdef CONFIG_HIGHMEM /** * count_free_highmem_pages - Compute the total number of free highmem pages. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index dc9820466377..71bfe72be045 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2401,61 +2401,6 @@ void drain_all_pages(struct zone *zone) __drain_all_pages(zone, false); } -#ifdef CONFIG_HIBERNATION - -/* - * Touch the watchdog for every WD_PAGE_COUNT pages. - */ -#define WD_PAGE_COUNT (128*1024) - -void mark_free_pages(struct zone *zone) -{ - unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT; - unsigned long flags; - unsigned int order, t; - struct page *page; - - if (zone_is_empty(zone)) - return; - - spin_lock_irqsave(&zone->lock, flags); - - max_zone_pfn = zone_end_pfn(zone); - for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) - if (pfn_valid(pfn)) { - page = pfn_to_page(pfn); - - if (!--page_count) { - touch_nmi_watchdog(); - page_count = WD_PAGE_COUNT; - } - - if (page_zone(page) != zone) - continue; - - if (!swsusp_page_is_forbidden(page)) - swsusp_unset_page_free(page); - } - - for_each_migratetype_order(order, t) { - list_for_each_entry(page, - &zone->free_area[order].free_list[t], buddy_list) { - unsigned long i; - - pfn = page_to_pfn(page); - for (i = 0; i < (1UL << order); i++) { - if (!--page_count) { - touch_nmi_watchdog(); - page_count = WD_PAGE_COUNT; - } - swsusp_set_page_free(pfn_to_page(pfn + i)); - } - } - } - spin_unlock_irqrestore(&zone->lock, flags); -} -#endif /* CONFIG_PM */ - static bool free_unref_page_prepare(struct page *page, unsigned long pfn, unsigned int order) {