From mboxrd@z Thu Jan 1 00:00:00 1970 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 8B107C433FE for ; Wed, 2 Nov 2022 02:12:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2846A8E0001; Tue, 1 Nov 2022 22:12:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 233F76B0073; Tue, 1 Nov 2022 22:12:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FC358E0001; Tue, 1 Nov 2022 22:12:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F252E6B0072 for ; Tue, 1 Nov 2022 22:12:10 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C5A6514020A for ; Wed, 2 Nov 2022 02:12:10 +0000 (UTC) X-FDA: 80086877220.01.AD49904 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf12.hostedemail.com (Postfix) with ESMTP id 449C740002 for ; Wed, 2 Nov 2022 02:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667355129; x=1698891129; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=MI6zhkObRenGpcSUR87/Sz4mYR5sSxARjEOEUywXhME=; b=fqb9FAw7dPqLlUK37b8LvvZkbrckrvw/sQVrGGaK8HpgwZoVwg7Pitem FnZl3z+x5cZT6Dh1essPNQ/rp3igK6X8KfouJ41vY3u65sAF2RbjEmbMn uzMBCAckC5uI6TTnSnir6XqsxOlz5nQkacIKR/v19aFzdwPsGa9J2i40p TfDBKYgnP6ANMWfyD7ymy6GXrpYwloLsDOgpAVWHijhqr8Qo48fF4Ps9V r9DSyTK7TMk/3lezK0GPHy5jYKHaWcF0KronpDlmdahhV3B/bndR9jNN7 tpGX9gQdxk2I+Z7Wa8uOhwg6whooGY88NU3tfax8FvY7KuV0C9JeNi6GX w==; X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="292602653" X-IronPort-AV: E=Sophos;i="5.95,232,1661842800"; d="scan'208";a="292602653" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2022 19:12:07 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="739563098" X-IronPort-AV: E=Sophos;i="5.95,232,1661842800"; d="scan'208";a="739563098" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2022 19:12:05 -0700 From: "Huang, Ying" To: Zi Yan Cc: , Matthew Wilcox , , Andrew Morton , Yang Shi , Baolin Wang , Oscar Salvador Subject: Re: [RFC 1/2] migrate: convert unmap_and_move() to use folios References: <20221101062137.83649-1-ying.huang@intel.com> <20221101062137.83649-2-ying.huang@intel.com> Date: Wed, 02 Nov 2022 10:11:26 +0800 In-Reply-To: (Zi Yan's message of "Tue, 01 Nov 2022 10:54:48 -0400") Message-ID: <87y1suaywh.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667355129; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pUSaZl9JexiY7bbMd8vPWAUar9k+rF0VBJcXeHqF1w8=; b=7q68R++JZse1bl8MrIbGo5NkEtFcQ+6i61tWJPJVMaxE7jsCWfhAgx62YF1sZIv95CpAEO 0wCwg43sqIWDBYUJ5sOjrxu3VK9VmccLM42QfERYUetj855RDXr93Zx8X0JVtbnM4tEaUf gKUmLXC7L1m3PF3E1fvvLU+jT1VAzBE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=fqb9FAw7; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667355129; a=rsa-sha256; cv=none; b=g5uJIT5UxgMGSeAqhDujztO4avfYDHNbp3qIa+6q8wksY5vOPfTL4TF4ByRCeIkyO5qLoL S7KGRWQGiO+oBZ1TMyyRBhEeONR7kZXGqAa1Hq143c56tExUGH3lrWUG0fQLvBe9h0NKeY PeMpqDm70X0ioxeeCXGASYrP4SHmwds= Authentication-Results: imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=fqb9FAw7; spf=pass (imf12.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: zctc9zi9jwio4csfri1fnefj9itx6569 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 449C740002 X-HE-Tag: 1667355129-876621 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: Zi Yan writes: > On 1 Nov 2022, at 2:21, Huang Ying wrote: > >> Quite straightforward, the page functions are converted to >> corresponding folio functions. Same for comments. >> >> Signed-off-by: "Huang, Ying" >> Cc: Andrew Morton >> Cc: Zi Yan >> Cc: Yang Shi >> Cc: Baolin Wang >> Cc: Oscar Salvador >> Cc: Matthew Wilcox >> --- >> mm/migrate.c | 54 ++++++++++++++++++++++++++-------------------------- >> 1 file changed, 27 insertions(+), 27 deletions(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index dff333593a8a..e625fd84b824 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_large(src)) > > folio_test_transhuge() should be used. Sure. Will change. >> 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: >> -- >> 2.35.1 > > Everything else looks good to me. Thanks! Best Regards, Huang, Ying