Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1852723rwi; Tue, 1 Nov 2022 00:10:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5QIHUGTKAKE8SoEaS9qrU6PM001SElVFCdscL/HJ7g3G18AQe8zLTns1zMYuBZpMlRBKcc X-Received: by 2002:a17:907:7fa9:b0:791:a5c2:e25 with SMTP id qk41-20020a1709077fa900b00791a5c20e25mr17110495ejc.444.1667286612665; Tue, 01 Nov 2022 00:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667286612; cv=none; d=google.com; s=arc-20160816; b=mIYKnf31Y6NbtRecfnARm7OKA/ck2Ue9rXKPkwZE0fXIn1R1qIPcroVtCRi3ksGyxN 8ND/vNw7hOsBcNBBl06+30X14jZIT8TdCywMB7V5MTkIu27CbeTzXmyTl+29ci0kDtSz +y/cJ6bMORze9CrFMj29vJdoFaC7VCkf82aB41Fx61ETAbWHH8lK6Q3wwRjb6HoaKep9 kSCzQaLHH89mTK1a2lkrFUzuGFsSDiLf9cBVfyUNmA2wEF8mjrm6523Zp83Xs0T8tLi5 Ic46GOKG8zABVvUs+zdyIPomCrI7KGWKxlJVJW3+9llJYzx37Y774B5J70w4w6ygpTaG lYWg== 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=BneFJhLQm5gXwS1RDXj4vU62X5BCYAPZWATaWIXYKKg=; b=IasFj4OCYusNRVN7i2AGf0TKj/y0s5kYCqPNKeB2s+N+Z0qZTvgfdSapRlDH0Gy7Hq 40PewHEiGmTZZfyEovNgz2rJWxH+UAUJsFARkp1lJBwN2fArPYRyyZJoTs0bwb/3KqU0 x1rI2fh7zrQsHV15c5mhEZ32VqpU/ZGBbkwN4m3oOJcOB/Yl4vTPodJNHpe6nMkmwF+T w9/cyCkQAMgbKdxgXR81+HCLnE9E38I+bMjmSgCITOAX7xyNpFhU1OPZvf5Jlbr/raSu 870qLbMVn+y6fgGl9VtTnbpBWRYwQAm0Zt1YRWxVvaZe5Pwt7yOI+UNp/EB5w+/ObfLG DssQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eWcvcck4; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id og17-20020a1709071dd100b007ad6a0afbd4si9840142ejc.825.2022.11.01.00.09.49; Tue, 01 Nov 2022 00:10:12 -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=@intel.com header.s=Intel header.b=eWcvcck4; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbiKAGWr (ORCPT + 97 others); Tue, 1 Nov 2022 02:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiKAGWo (ORCPT ); Tue, 1 Nov 2022 02:22:44 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F13A15FC8 for ; Mon, 31 Oct 2022 23:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667283763; x=1698819763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1IE+vWLBfJpeLn+8AFQ/vys8pKj5x+HXTg339q6MKpM=; b=eWcvcck4yx6rH2yCL2OsZ+i+V4zn3BnQYwlo7OLOAr6r0uEKmYnf/od4 LiP3ts1MaUurpZ7FHvDIjp7BFwCgORpFWJYviUOemGd8fA+BVp0Ubf1MI 0FKBuGFw4+S/dvXcZZUiHus9dbtlIUbkILIR5Q1DASU2xlJ40e/7DgjXS 6NZmZ9gLPwMu1nb+sjFFG8os93hdnlAsqICb1lcNJhYkvt+6rCmAV3naf +40Aw/jddmkc0NJqBmcJrTVuvmri7qBK+7AcNYNgDMD45gfXQNY93qg77 c6g/YdsvCyjt8WYUMLyX6VXHydgH8YD0ntgZzCE2iqzFaFicvYKwKwfTn A==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="395388686" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="395388686" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 23:22:42 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="878998342" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="878998342" 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; 31 Oct 2022 23:22:40 -0700 From: Huang Ying To: linux-mm@kvack.org Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, Andrew Morton , Huang Ying , Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador Subject: [RFC 1/2] migrate: convert unmap_and_move() to use folios Date: Tue, 1 Nov 2022 14:21:36 +0800 Message-Id: <20221101062137.83649-2-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101062137.83649-1-ying.huang@intel.com> References: <20221101062137.83649-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.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_NONE 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 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)) 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