From patchwork Wed Nov 9 01:23:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13037030 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 D5444C4332F for ; Wed, 9 Nov 2022 01:24:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32D3D8E0001; Tue, 8 Nov 2022 20:24:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B5BC6B0072; Tue, 8 Nov 2022 20:24:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 157FC8E0001; Tue, 8 Nov 2022 20:24:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 038526B0071 for ; Tue, 8 Nov 2022 20:24:52 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C2B01120735 for ; Wed, 9 Nov 2022 01:24:51 +0000 (UTC) X-FDA: 80112159582.09.6B1B110 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf15.hostedemail.com (Postfix) with ESMTP id 54A57A000D for ; Wed, 9 Nov 2022 01:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667957086; x=1699493086; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yoCjLY5a568iSDEpolTlkW/LjTBOESOZ2uhJ1D8VbnI=; b=gJr3gwVhyi74JYT26fL3kgsXQ2PT1PIesuY+m3Fsr2VmFf3wiKxtvQGs 3y5VUYQnkKDt3h/pxFMun6mNaCXNboYaN5xCsNhzL9VvrIZ8LnFlJRTYy FK2bgX3/C3fG/kTVLjyKU1spQkTWouRqgdJFEh+s7rPf7XJx2b4Lij5ee zbZXuOyOzVYsF88k+yHEU1u/3KFmvoeDbqTemcDVSlrNy/p1n0bIThbx4 /xqzTiAm6uk4ogVOSqBsMXu14gb8nUlaVw2mDh8gXpcA96VkmmshNup6H Qm9x19CC/zLXdiMv90dvTJFsu2MQmDDABCiLAXSiYmu5BCb2MXkimJQj1 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="337587347" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="337587347" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 17:24:01 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="881731723" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="881731723" Received: from yhuang6-mobl2.sh.intel.com ([10.238.6.69]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 17:23:58 -0800 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Yang Shi , Zi Yan , Matthew Wilcox , Baolin Wang , Oscar Salvador Subject: [PATCH -V2 1/2] migrate: convert unmap_and_move() to use folios Date: Wed, 9 Nov 2022 09:23:47 +0800 Message-Id: <20221109012348.93849-2-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221109012348.93849-1-ying.huang@intel.com> References: <20221109012348.93849-1-ying.huang@intel.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667957087; a=rsa-sha256; cv=none; b=Z15lmCYvWzEcaGVFbTgCLpEHusHZmnfZKiVPLseixFX1nX3l6vKGq56PUXZZk6mnm1jfzR 6KRbwch42DLjXPYDvIs4+mVr4oPYC0ZZkYcgpygaVunnkL8ts4X0Qx7anB1AqlrmHvoG1I ybj8CRmPXhb9PPAhKQOISzuTibitKQc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=gJr3gwVh; spf=pass (imf15.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667957087; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CBLC+SqCx7ZsTil+7GtwHtGMMzbj+OEzoriZkFFJwyE=; b=Qmnl9lQQLl2/AUtplB3vg64emtnjQ66DwQch7qiHYaGItk4qQXzXeTrgx5AuavJ8iXN0ce hxzi9fJ3TVKPmM/LIIfCtsNsJMhutibx6zq5D/q+uyI8rfpqDqrPZp8HxQwvbgPvoGfXMP wVPddpdl8w5N2tj1dZlOk+e4jufCiHI= Authentication-Results: imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=gJr3gwVh; spf=pass (imf15.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: df4jpq7mj4dx5kuqig6mbg3fi5759a5u X-Rspamd-Queue-Id: 54A57A000D X-HE-Tag: 1667957086-898563 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: Quite straightforward, the page functions are converted to corresponding folio functions. Same for comments. Signed-off-by: "Huang, Ying" Reviewed-by: Yang Shi Reviewed-by: Zi Yan Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Baolin Wang Cc: Oscar Salvador --- mm/migrate.c | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4aea647a0180..eed8082664f2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1150,79 +1150,79 @@ static int __unmap_and_move(struct folio *src, struct folio *dst, } /* - * Obtain the lock on page, remove all ptes and migrate the page - * to the newly allocated page in newpage. + * Obtain the lock on folio, remove all ptes and migrate the folio + * to the newly allocated folio in dst. */ static int unmap_and_move(new_page_t get_new_page, free_page_t put_new_page, - unsigned long private, struct page *page, + unsigned long private, struct folio *src, int force, enum migrate_mode mode, enum migrate_reason reason, struct list_head *ret) { - struct folio *dst, *src = page_folio(page); + struct folio *dst; int rc = MIGRATEPAGE_SUCCESS; struct page *newpage = NULL; - if (!thp_migration_supported() && PageTransHuge(page)) + if (!thp_migration_supported() && folio_test_transhuge(src)) return -ENOSYS; - if (page_count(page) == 1) { - /* Page was freed from under us. So we are done. */ - ClearPageActive(page); - ClearPageUnevictable(page); + if (folio_ref_count(src) == 1) { + /* Folio was freed from under us. So we are done. */ + folio_clear_active(src); + folio_clear_unevictable(src); /* free_pages_prepare() will clear PG_isolated. */ goto out; } - newpage = get_new_page(page, private); + newpage = get_new_page(&src->page, private); if (!newpage) return -ENOMEM; dst = page_folio(newpage); - newpage->private = 0; + dst->private = 0; rc = __unmap_and_move(src, dst, force, mode); if (rc == MIGRATEPAGE_SUCCESS) - set_page_owner_migrate_reason(newpage, reason); + set_page_owner_migrate_reason(&dst->page, reason); out: if (rc != -EAGAIN) { /* - * A page that has been migrated has all references - * removed and will be freed. A page that has not been + * A folio that has been migrated has all references + * removed and will be freed. A folio that has not been * migrated will have kept its references and be restored. */ - list_del(&page->lru); + list_del(&src->lru); } /* * If migration is successful, releases reference grabbed during - * isolation. Otherwise, restore the page to right list unless + * isolation. Otherwise, restore the folio to right list unless * we want to retry. */ if (rc == MIGRATEPAGE_SUCCESS) { /* - * Compaction can migrate also non-LRU pages which are + * Compaction can migrate also non-LRU folios which are * not accounted to NR_ISOLATED_*. They can be recognized - * as __PageMovable + * as __folio_test_movable */ - if (likely(!__PageMovable(page))) - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + - page_is_file_lru(page), -thp_nr_pages(page)); + if (likely(!__folio_test_movable(src))) + mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + + folio_is_file_lru(src), -folio_nr_pages(src)); if (reason != MR_MEMORY_FAILURE) /* - * We release the page in page_handle_poison. + * We release the folio in page_handle_poison. */ - put_page(page); + folio_put(src); } else { if (rc != -EAGAIN) - list_add_tail(&page->lru, ret); + list_add_tail(&src->lru, ret); if (put_new_page) - put_new_page(newpage, private); + put_new_page(&dst->page, private); else - put_page(newpage); + folio_put(dst); } return rc; @@ -1459,7 +1459,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, &ret_pages); else rc = unmap_and_move(get_new_page, put_new_page, - private, page, pass > 2, mode, + private, page_folio(page), pass > 2, mode, reason, &ret_pages); /* * The rules are: