From patchwork Mon Feb 13 12:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13138387 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 D1561C64EC7 for ; Mon, 13 Feb 2023 12:35:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AF366B0071; Mon, 13 Feb 2023 07:35:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 639096B0080; Mon, 13 Feb 2023 07:35:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B1DB6B0081; Mon, 13 Feb 2023 07:35:42 -0500 (EST) 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 3A7826B0071 for ; Mon, 13 Feb 2023 07:35:42 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0B9B81608A4 for ; Mon, 13 Feb 2023 12:35:41 +0000 (UTC) X-FDA: 80462214924.02.6853765 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf22.hostedemail.com (Postfix) with ESMTP id D6639C0015 for ; Mon, 13 Feb 2023 12:35:39 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Z5IL4tn+; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 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=1676291740; 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=WjTzw4PSTBXrymmqX83J4G/fs1zgCKHC1Xe1yoEujwM=; b=QnjSHNVIlbAbj3QGLRS1UTp+dBUDJ+dgOhrDa4YCRzj8e64JFKS9hmfJSFYNSwN6H5azul QjV22teVoNmgJHgWdJrapGKEhUQfBHzn9SqCVQ1hsCKcYd2H296FyAbNL8D6p/olgewMdk re4Uqpt21qZlKhuCycwhxengzRSlkNQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Z5IL4tn+; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.136 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=1676291740; a=rsa-sha256; cv=none; b=cKSOn/isfpIZC+mhbc5wEgbpgnA/WeFBgkUmKhnsR0RmQdRw1NGFSYzpx7JcNAYq61iAY1 UVz344Od8KijEYcHCkRbR8/1Z5xhHy41Xv+huudOggU9w7OtdWQZtF2I1GKB0Iqc37JqgP PFgKxBhPD2SnOShxnIp/MdgVHAAJQsI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676291739; x=1707827739; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K4XDKropeMr7/ju8eX1ZAYnD0sjioz6DP3VREqBtsko=; b=Z5IL4tn+SAjmtk9Cb0hGD6JeBSGVeCuX3kdGF92hkdMoza6R3npUTXiO vVeb47nCxQsa01C4PK8xprXf/wR0pAsmDXVbnD5XUllFhoFVe8up2b1I3 eoQgDARSTFARF2f2XdMVlBzWyRkTM7S2XVXGHBBLjJs05EcweBaVT05Zt xteyeli2vK/1s9slGqlE+i5tgrgj+MpUx1qpWP2M6Tr+PMkdJbIzAOf+n oHlxMv03DHs0dC64lQR6wZXJ7QCkbDZB475ohgAkAp8RgTUMwGNMTlwbc h47bqVIvdxK8jKJzfNMUhvCUX0Ax2TyQMrDSG5fST2I9UsiqD+HEo6Xx1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="310513272" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="310513272" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 04:35:39 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="646366651" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="646366651" Received: from changxin-mobl2.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.171]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 04:35:35 -0800 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Zi Yan , Yang Shi , Baolin Wang , Oscar Salvador , Matthew Wilcox , Bharata B Rao , Alistair Popple , Xin Hao , Minchan Kim , Mike Kravetz , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH -v5 6/9] migrate_pages: move migrate_folio_unmap() Date: Mon, 13 Feb 2023 20:34:41 +0800 Message-Id: <20230213123444.155149-7-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230213123444.155149-1-ying.huang@intel.com> References: <20230213123444.155149-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D6639C0015 X-Stat-Signature: sdiiymkcrpzoxke8mjybir8is4gairot X-HE-Tag: 1676291739-512490 X-HE-Meta: U2FsdGVkX19UB+X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vcBujvqrRsnFJ7PdvsZQg+0GHxs73HMotfHIwljasRRG+pLYqhyL6HbnZ6VjWzPH2a/Hg1vC84DoS5PHqVrKhhD7Ryux899i3t+0f4WmgrXdsKf2ofXLU3Lao+zYtckuJbwzJInyIdIaImxF8ga1tr92dz1NoayjQznCqQAgQhXE64pEkoji+ngL0YFa5Lc0J4szmMQHC0k/oDqw5mbIGDOLC4XXCplvkV7KOsig1oaZcOl2C1xmz5YIfAO5dZ9WHIq3XGGuwOMCCexGIgCmgCT6IBzxWy5Sljb7waC+9aPIpJcUaXfRghzfGx86vFLiJNaM9bSIW4NoHeLSVO9cGjWitK4orozFabtrxEbcoXWmTD4IJt0RNiKSFywGg8SqCMBo97bKez+xXXSKJab6NXj6LJqFPncfJIeSUP5MLvLQ== 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: Just move the position of the functions. There's no any functionality change. This is to make it easier to review the next patch via putting code near its position in the next patch. Signed-off-by: "Huang, Ying" Reviewed-by: Zi Yan Cc: Yang Shi Cc: Baolin Wang Cc: Oscar Salvador Cc: Matthew Wilcox Cc: Bharata B Rao Cc: Alistair Popple Cc: Xin Hao Cc: Minchan Kim Cc: Mike Kravetz Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/migrate.c | 100 +++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index ee3e21f1061c..0c7488ebe248 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1236,6 +1236,56 @@ static int __migrate_folio_unmap(struct folio *src, struct folio *dst, int force return rc; } +/* Obtain the lock on page, remove all ptes. */ +static int migrate_folio_unmap(new_page_t get_new_page, free_page_t put_new_page, + unsigned long private, struct folio *src, + struct folio **dstp, int force, bool avoid_force_lock, + enum migrate_mode mode, enum migrate_reason reason, + struct list_head *ret) +{ + struct folio *dst; + int rc = MIGRATEPAGE_UNMAP; + struct page *newpage = NULL; + + if (!thp_migration_supported() && folio_test_transhuge(src)) + return -ENOSYS; + + 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. */ + list_del(&src->lru); + migrate_folio_done(src, reason); + return MIGRATEPAGE_SUCCESS; + } + + newpage = get_new_page(&src->page, private); + if (!newpage) + return -ENOMEM; + dst = page_folio(newpage); + *dstp = dst; + + dst->private = NULL; + rc = __migrate_folio_unmap(src, dst, force, avoid_force_lock, mode); + if (rc == MIGRATEPAGE_UNMAP) + return rc; + + /* + * A folio that has not been unmapped will be restored to + * right list unless we want to retry. + */ + if (rc != -EAGAIN && rc != -EDEADLOCK) + list_move_tail(&src->lru, ret); + + if (put_new_page) + put_new_page(&dst->page, private); + else + folio_put(dst); + + return rc; +} + static int __migrate_folio_move(struct folio *src, struct folio *dst, enum migrate_mode mode) { @@ -1296,56 +1346,6 @@ static int __migrate_folio_move(struct folio *src, struct folio *dst, return rc; } -/* Obtain the lock on page, remove all ptes. */ -static int migrate_folio_unmap(new_page_t get_new_page, free_page_t put_new_page, - unsigned long private, struct folio *src, - struct folio **dstp, int force, bool avoid_force_lock, - enum migrate_mode mode, enum migrate_reason reason, - struct list_head *ret) -{ - struct folio *dst; - int rc = MIGRATEPAGE_UNMAP; - struct page *newpage = NULL; - - if (!thp_migration_supported() && folio_test_transhuge(src)) - return -ENOSYS; - - 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. */ - list_del(&src->lru); - migrate_folio_done(src, reason); - return MIGRATEPAGE_SUCCESS; - } - - newpage = get_new_page(&src->page, private); - if (!newpage) - return -ENOMEM; - dst = page_folio(newpage); - *dstp = dst; - - dst->private = NULL; - rc = __migrate_folio_unmap(src, dst, force, avoid_force_lock, mode); - if (rc == MIGRATEPAGE_UNMAP) - return rc; - - /* - * A folio that has not been unmapped will be restored to - * right list unless we want to retry. - */ - if (rc != -EAGAIN && rc != -EDEADLOCK) - list_move_tail(&src->lru, ret); - - if (put_new_page) - put_new_page(&dst->page, private); - else - folio_put(dst); - - return rc; -} - /* Migrate the folio to the newly allocated folio in dst. */ static int migrate_folio_move(free_page_t put_new_page, unsigned long private, struct folio *src, struct folio *dst,