From patchwork Mon May 8 07:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13234127 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 93616C7EE24 for ; Mon, 8 May 2023 06:55:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 221B0900005; Mon, 8 May 2023 02:54:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11195280004; Mon, 8 May 2023 02:54:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0E0A900005; Mon, 8 May 2023 02:54:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8547C280001 for ; Mon, 8 May 2023 02:54:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5CBA31C6CFE for ; Mon, 8 May 2023 06:54:58 +0000 (UTC) X-FDA: 80766175476.06.CD9EBFE Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf12.hostedemail.com (Postfix) with ESMTP id A0FEA40006 for ; Mon, 8 May 2023 06:54:55 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=1683528896; 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=xovwDSWexNOB+OkP9L7oBj8y9KD9nnpznld/C1h13bY=; b=sOciEZzOyeNB25T6y7LwXqNCKJ0YpoAeHJljLbE5WBf18R0i6p0tzR7MO6dAS0MoBgKcX5 OC7EJpvGBQhKOCyAGscq+lUMJI1JdLnZ92TR2587kRSM0Tj7VZpy/2PuRh8IrAc/pvA5zL Q3UIc+JcIABDL5al0LZZTtSgTCBxFL0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683528896; a=rsa-sha256; cv=none; b=fzzIcKlHoD9q3NFfr32vBP3i1wL8uSIliqq5blUGfTqbQeKdhHEDx9ndwxoqpbIw+m24CA YI8f2KO2NbUPCAxl0hRB+m8LKeyA65BtkQjmGYHM0bHzkfsaNRYWnDhDs5sU3DyxJPQVyM rbvWuRoD/Sse8pQsP2yH+jSFOyD5Xg0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.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 Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QFBpD6xQ9zpW6Q; Mon, 8 May 2023 14:53:40 +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; Mon, 8 May 2023 14:54:51 +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 09/12] mm: page_alloc: move mark_free_page() into snapshot.c Date: Mon, 8 May 2023 15:11:57 +0800 Message-ID: <20230508071200.123962-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230508071200.123962-1-wangkefeng.wang@huawei.com> References: <20230508071200.123962-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A0FEA40006 X-Stat-Signature: rqb9kxwgpeqmjag1sd7purypu6885jtb X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1683528895-871065 X-HE-Meta: U2FsdGVkX18VJauToiKBKOn4FGKcM5VcgGKgcALPGeHs7mfwJSCuXkvcpzje02UTijizyt6iX5O6ypEJ8sJ5AXqAKUba8xebe/1/HYMeO34LVJaeuDe+MeSS7f6X2egDc5ZcisOpcc5kvCPWCLVZwRF2Zy6FqLG9LeyhiS8lk4qZZQU8nndliPre67H7XBJQpgGe9dJoQuMk51qOP6HPhglIl6ZmmDe4avtWtTnA2JkVvnv3HDdPQU5F2e2GiAALSLW28kvcfmjOwwBtrsfmYXSZZDMoCj6gnlS+XJAFQcHhMF/hYNxQkUVmlhD9TfgoBACj0Js7nfG+OP2WvXGjhamA/I4PlWbKcGhps/GkvzBnGqYaBBLDkV//SqyI36lY1PaYwcrH0mhvK2ESC4dRPksXxVqv1XlwULzlDCp00VspXhyA1vqofbDHlfOe/vnDQzHIZ63evRIpV8R5aKN7RSM+zlYDD1dKUHxiG62vRFWsTdrDV6dphGchQmRWwfxhOIPehuIWRyusF0ElHx1grOX9gQ54XQVkooDh4eiJqoBjqSm/erTPHK5xtKgFXln3JREFFiFF14WCD8Csb/ta2g7gkmDjC1czqrJjJd3P/E0RS6Dy7VaBVwmjT2euuCgPVBGtBjP7JJxXdlZb/tkPm/Ro9iThuhMLvjCJkzjKX4zZoKhwfvdv2cq0zzOd2uSOKpBFChIfev0iC9TRLK3SLTqio1oUNYxcO/v4CAefHPmQwMV+p3U1Uod9BXGE2DeUusoElcA/3ovbca6YBnJ4DbYL5a98OdpdNzu0Tvb5/G8WNWE7hmbAi8R6KXUelVJsAMVR4bgNuDwHODidCNvolc5IlJdWThRHYKdHuTIX8Iiam3puOxExP3ZYcT/Smi/U5cBqzb9jSZ+00EDGp3GAuuMZ8zvN7pI2Z5GJllRbhe4u97oon646F4k36th3DjlsVNvWQcTh08RNgkFODZm +wMqs17+ 1Eh5q/I6Oh8oFUVJL+BfVpGknbdlpnyzh1uQO1SazvHZdDt61ePLrGlItZG2MNXq5v6DEOHdVKO6liXIOgLudbgR2tEzxwC7PGA19MidYjGprkS5b4D4nXsVUNncUWBUnQPG3KP0Xtqn+RtmjdKzsdq9AdhnBMb4k5VYKPdPU7BqUrXBSXwUFQqh0rjbXEmZWFjbNuZNmzlnYfG4= 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 78d8a59f2afa..9284edf0259b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2313,61 +2313,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) {