From patchwork Tue Jan 10 07:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13094781 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 E35A6C54EBE for ; Tue, 10 Jan 2023 07:53:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AE8E8E0009; Tue, 10 Jan 2023 02:53:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7374F8E0001; Tue, 10 Jan 2023 02:53:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B0C68E0009; Tue, 10 Jan 2023 02:53:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 421728E0001 for ; Tue, 10 Jan 2023 02:53:56 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1023540BCC for ; Tue, 10 Jan 2023 07:53:56 +0000 (UTC) X-FDA: 80338125672.23.0FD4E2C Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf22.hostedemail.com (Postfix) with ESMTP id 3248BC000C for ; Tue, 10 Jan 2023 07:53:54 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=l1iVHLI5; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 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=1673337234; 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=lLV4TWCZsGHvy8bTmJiNBKRkyzMepfk67LuPaElxASU=; b=RQ0JPWUyXYV13fpAXqSZD/L9qaVBfn2lnSCgSbxfQq0ocyXjanLCUKRltMtedq7rDykk66 cDCY0468joKzk08MVzFG/ptts/tjFI+p7qeU2CXB1sSQSxXHfMZUXbgzdG1G1xXpKhsvRv yvA3WhlR6iryw/JZb8eymrMFKsWhICs= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=l1iVHLI5; spf=pass (imf22.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 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=1673337234; a=rsa-sha256; cv=none; b=oB5XfP+SqX3TzR6UVB8ahX/v1dP39cS0fRXLA1jRLPpRVy8vAffHiwObUs4MeAtWm7Bmk9 vT1WYWhFd5C7oL6JuMSSMe8AWY6A+ircWnTEw9g/qYwJqp0sMpaP0w1YujE91Dp3vzkw9v PsQvpTHunhUnFLufaYj8yCmrZX7pCmg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673337234; x=1704873234; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1seMGdAxQCuDtz4CTF8kF1CgdzVLCUmbg8rfqSN0s20=; b=l1iVHLI5CbCht401ANL+Sp2UcdI4O8fmBxNMGShPiWQLS5iV7sHq8ieY GakfrU8LUTrQ5tO+CZ7ViNIJfNqItFS1IGj3P2S5VUl9f7CLVa53bdbHJ /ZVN6TVyedfak6r8Jj5lwaDY1kygWITgHlK6z1YiRTHq/vIxYkyC0mncv 6p15yg0OXr7iiaj1oDvGu2kjm3YsEd3r94sRuUYkTcoDprrnnyUuu5L4b fa5fJOrbfu8x5CwnKFMKrcer3KxVEsC71IOUBTSNE/fZ8Zrjzlq1K+LPa P6EhFCrK1sJ2rBXe+FZj3iFqj+mlQDfHmP9fU7q3oniHXC+aT60Yp9wOj A==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="303449349" X-IronPort-AV: E=Sophos;i="5.96,314,1665471600"; d="scan'208";a="303449349" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 23:53:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="902287160" X-IronPort-AV: E=Sophos;i="5.96,314,1665471600"; d="scan'208";a="902287160" Received: from juxinli-mobl.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.254.214.35]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 23:53:50 -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 , haoxin Subject: [PATCH -v2 6/9] migrate_pages: move migrate_folio_unmap() Date: Tue, 10 Jan 2023 15:53:24 +0800 Message-Id: <20230110075327.590514-7-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230110075327.590514-1-ying.huang@intel.com> References: <20230110075327.590514-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3248BC000C X-Stat-Signature: hdah58wrbnxe4ezikqbhdkoqw8r1kzqr X-HE-Tag: 1673337234-496250 X-HE-Meta: U2FsdGVkX19CTzJLEVLXuwni1rfZBx7cn/uYs+15DijdrkBIvjv97HzbG90JOwPQR+qLjpDGxQ4u3GhbNCTOY1ro/LN2gEcnnkQCZFN2nYTPKKoJj0mlSckm9DEwbhTs4G8L11WO6/ey1EgQYj/gWBBnyvwEcOZvy38LWMkRpeeVrODdw9WyuYzhsQC03iY8TdRkbiZ1ihMd2JSzdRXbZHCjYujLdVyyvqRrUytbwAbc0gioCHXYZQ77VQEtgenbanmI5Q5IJR+xxGJwgn+aXwIN53BhUxSsXfBPKdEULRRvwtPevWTrDLHOrmDLHk7o51HblzmTZfFvhwwv5SxfOBL28nXCjHeyvuGavXKzFE8Y9TaTpjkDTpyLypFTGwU7azpZl/SSotAZehO6ZQBSIPpiEjgnNxu7BlTbE9ARz5x1F2Hy5da+plDy3DqD3euOzhUqZ+2+uG0Q/6A+BVZFrkXsiuU5hmHTFM6bUYsdJAypgtaOV2FRRmqXskq1W5V0LZdhYeA9daDzeINnQD4M/VQ4jK/BO/+j7jyt5X76ZnfJqvN6TriwC9BG1ibT+Sr+g5/UDaSI78O308psmZxx8tvoddjppCVG9zYvRv1ffJqgxaZvyemaINDe6vHr73Kdi7aO2TB3PVoi+oevTGlyQWBI1xQyBSN2JcZOzMT11hixu04bLg1wZSQKtU89KZE9707Kw+pDXoV9dULnAvYkEjw93lhf08HXxosAAkgD9MUtMZwtofl9anoCXa4hlSlcXAPx3TLQW746ruQeZzaYzD1EVpuNKUh+qyxNgSDsiN0tzdEMBrxSMDigmf6XJZMj2z6ZseZJrZePnrt454kCN2NI/rppkwVwVmncR1fr6P2fHYSgW09y07M6ic8pG1Yl1Cz5z8aTBJsT7QLk3IlrT3/Po1/VvYBJd6eSBxHofW/W9DaOzsYZcjfKMIQz/tNHLml5GXgXm0o= 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" Cc: Zi Yan Cc: Yang Shi Cc: Baolin Wang Cc: Oscar Salvador Cc: Matthew Wilcox Cc: Bharata B Rao Cc: Alistair Popple Cc: haoxin --- mm/migrate.c | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 2983662cff75..08ce68ba5085 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1219,6 +1219,57 @@ static int __migrate_folio_unmap(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 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, force_lock, mode); + if (rc == MIGRATEPAGE_UNMAP) + return rc; + + /* + * A page that has not been migrated will have kept its + * references and be restored. + */ + /* restore the folio to right list. */ + 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) { @@ -1272,57 +1323,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 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, force_lock, mode); - if (rc == MIGRATEPAGE_UNMAP) - return rc; - - /* - * A page that has not been migrated will have kept its - * references and be restored. - */ - /* restore the folio to right list. */ - 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,