From patchwork Tue Nov 1 06:21:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2769891wru; Mon, 31 Oct 2022 23:27:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rMeIahlnE8v2AfNW95cckXrsyQuSF9lyqyW0mbqHcckDqqCoTlxfi9rCX7OQ97Oth/kAV X-Received: by 2002:a17:90a:ca87:b0:212:d2bd:82f5 with SMTP id y7-20020a17090aca8700b00212d2bd82f5mr18916867pjt.203.1667284022493; Mon, 31 Oct 2022 23:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667284022; cv=none; d=google.com; s=arc-20160816; b=Z0POikoUL/44X9VwH/A526HUM6jhETd2t+ti/GiLz/ozhLQVEwmspT+4mJpoVi2PGT 6d4Kz/yjvDtCBpZyNa0ShSD7BzsxrepYO/ID94Pn2P1ekfVfDBvrhLTO+CjshUSVFXbc li0HcIUn00rKkmTxPmFHbpgb1BjAy87rLR/PNeDj5BTe0jHWQQPHUKRwC4zuBm4FArTr W7LF/D+Ef78cAdDCYfx6cNK8iGSR5XsY5mQuud2gkk8uf8rgFep1YnX3kp7Q3OJDRyQ/ DQGziMmx9QzNR+c5/AOTTXTjzt1T9oC09yoWfxIhQ4qsKg5Y1TuIEJZ3J7cjj74N1tIy ixmg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170902e34c00b00182a9c27a9csi10022263plc.603.2022.10.31.23.26.48; Mon, 31 Oct 2022 23:27:02 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748274011423928159?= X-GMAIL-MSGID: =?utf-8?q?1748274011423928159?= 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: