From patchwork Mon Feb 6 06:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13129356 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 6B45DC05027 for ; Mon, 6 Feb 2023 06:34:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07FCA6B0078; Mon, 6 Feb 2023 01:34:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 02FA36B007E; Mon, 6 Feb 2023 01:34:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E611E6B0080; Mon, 6 Feb 2023 01:34:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D768C6B0078 for ; Mon, 6 Feb 2023 01:34:02 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8B6491403F1 for ; Mon, 6 Feb 2023 06:34:02 +0000 (UTC) X-FDA: 80435901924.15.CDB2292 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf11.hostedemail.com (Postfix) with ESMTP id 862024000F for ; Mon, 6 Feb 2023 06:34:00 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=krZ70lgX; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf11.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675665240; 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=2CRGX/4cvOKQOeDObEC2cncEGX4sAo+G97rWZFVQ56Q=; b=W3UxHLjgOaxWjFFgpkGP3kuUMEL7wye+WUNO8KAYFnEiN7o+fCtHl4bJNLg+Cv27oMvWXL QSQhCgVa1P9a2Jo0eUXdKsY6dPgPEZ17BlPXPeHx/1fNPzaXwbNh6j0Vl6KjtgEvPJUEr6 nTJGs3Ui3SHPK/6bz5coytMXjYyyo5o= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=krZ70lgX; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf11.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675665240; a=rsa-sha256; cv=none; b=Nmi4+m+/KuZxrv0AgZKI7rdVigsmrpaTT7tu/WnTOT21Ynx6rlf59x2y3sG1AtYR9WbXl5 p+ulwRvblUwot5Ql+evxWmaWJV++TcEhpfh5fDm7AFUDySbceT8y9Y5FvDh4pjqCYzTeXr nzY0OWBWR0AsJeZVHRpgxRWEBeTX2VA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675665240; x=1707201240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vDGXAlWxo4PDOnmZT5tL3p2VWp/8kRlkez6JFp7l83o=; b=krZ70lgX3H4P4anNtK2hNV1QRmhqOsDpVn+uhkY7LYTz2jRqXH35/Fuw MVJYVK2vNQ2Jw0BokYIcD0UT+H7eax/HY5G1eryzSgGbNL32Z2Hm1OJPF sn+FMowoq5xYLYnKY2ffLVQvwoBr5CrY7JjLSvOWNOEJ26pPcI+vX7SkJ fuu6vcHis+2IfIc7LHhrb4qkwAOHuXO6skYjNZ+EzOFedHzG8sLyun/5h fExA014/jpiSeogGQD5Lgh7SdO5x5FMm6awpYSFkB7PIHRBONiGNxcdWk dXizeD9OqeEvc5FjqWGdB44GuKXZo9t9ZaH5kcCz3Io7Y+Gj1X2Wd6X8P g==; X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="330432727" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="330432727" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 22:34:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="659744756" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="659744756" Received: from baoyumen-mobl.ccr.corp.intel.com (HELO yhuang6-mobl2.smartont.net) ([10.255.30.227]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 22:33:54 -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 , Minchan Kim , Mike Kravetz , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH -v4 6/9] migrate_pages: move migrate_folio_unmap() Date: Mon, 6 Feb 2023 14:33:10 +0800 Message-Id: <20230206063313.635011-7-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230206063313.635011-1-ying.huang@intel.com> References: <20230206063313.635011-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 862024000F X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: sz1wum5zenqpzqzzop37do9ardp9naii X-HE-Tag: 1675665240-310358 X-HE-Meta: U2FsdGVkX1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Az/YaKf4HA3YjBcuwCk+E9VbUVl+wsP2y5y/xlpm4kRlFHMVq77FrCaoHCS3l9Ssge90JIMOk9cAHcX1p5qoBpQdfkyuU3MgTNRnbff6VqKzEfQJ8emRM61Poy1sCvZHpC6RDf7R8ctiumBHcVEPV6SvNk8BPnMsqfn4zz9QxmSBSsH8G0pGplHzMJ/tX+E6URPlDKtiGIYF7RQ2S3S4SRQleHghv1oqt30L+orJEOVXOivYw/OcFO1D4gcxkdiKUAX2c3u+plGF0se16cYMx+482vLZSeK1QMgASXAkvTy8p5tGkAlz6lLKbkOjedESME2EWWNAt4Rrzouc+m9VXvcyWk+koAhiLAg0MV3kPLZxV8f0iIfJGRzChez3xFntyzfJ7I2s1/LrStiNPBoChpPPthKKmAOgwzgt8ETc3RYqeBCqR7ofkWdg4p9kJ0eiPw3Wcop0iN0ago73D2mZBkU/yswoHwjMKnXeS0abq82OZTSbGmROhkN8cT3MN+luY5RpOny9qazvAhnzDTat6RBS+P+mFG+AcD3rpxGjt+Ao9ovNsTBp5uJRseg== 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 Cc: Minchan Kim Cc: Mike Kravetz Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/migrate.c | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index fa7212330cb6..23eb01cfae4c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1218,6 +1218,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) { @@ -1278,57 +1329,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,