From patchwork Mon Jan 16 06:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 13102656 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 3C79FC54EBE for ; Mon, 16 Jan 2023 06:31:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B25566B007B; Mon, 16 Jan 2023 01:31:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD3696B007D; Mon, 16 Jan 2023 01:31:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C2B16B007E; Mon, 16 Jan 2023 01:31:34 -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 8DACE6B007B for ; Mon, 16 Jan 2023 01:31:34 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 56855C06D0 for ; Mon, 16 Jan 2023 06:31:34 +0000 (UTC) X-FDA: 80359690908.11.D7B4CD0 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf04.hostedemail.com (Postfix) with ESMTP id 75B374000A for ; Mon, 16 Jan 2023 06:31:31 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SFWFKENI; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 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=1673850691; 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=B4Ib9iv/tkOqjnr8m1P8kQJ3evZVUAW+mGbms/QMtjs=; b=Otrtik2CnkBQk4IOM5/1utETdI/RoPISryNoSrOHt40Q2+wtFk/YhiH1TluwPV+tS4diSr aDxMEsMXBVY1CiwM3NuOsYd3gQUMboKEu1xarEdVXQEIs+Lbtq2wjJn76lofV0K7tx0KY0 wnM+huTjNArP9sEZMFyMPB6iKF37XZY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SFWFKENI; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673850691; a=rsa-sha256; cv=none; b=ctQ1ct0nGz/cBi4G+YNTmA6CkNpC7OzL9jMDgTSz9jBNKCMGUhKLqDuMJdQ9eO9IU6iy4b 2YRN8sosReYwB561w3eUSOIAmIKLHF8PeyFYIHUzHidJBjsiRaOzblYfyOmRQWn9xrPYCe pS8tor3H+Wm+SR225sdr89w1SgY+4bU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673850691; x=1705386691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IWllhTG0GdPmuukl+DFwxPlkS3OUSn/9WM3n7s2+yfw=; b=SFWFKENIEL3uQKI9o5Fen69fU3t59O6a+kK41TKS/9OrxkD+DI/SnLZW ptVwnxXXD+vQZgtVzOyzfr0Rn5AZiRRgQgtGXNjlcnCva/e4Pe6PEDK54 09QbHXZVi0J81e80unhnp+tRVu7qjHliVtB6xR8EbQJT6qwNoRkY8W+/C W6Qm2ioC6PPLi4zdryhEDHjkL6diN3hqbYfngwoix/LG6qmaah/BECb/J FhFrzI0BUs2uk6SI8Kvmn/B2XoVTTqsBBsPSXUS+GAEcWBRtXzGILeOKo Lw76Y+zOQ50x1xoU4349MPepuqzZLu2ZhFLorV25Tjf30AO7+T6xQpdU4 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10591"; a="388892193" X-IronPort-AV: E=Sophos;i="5.97,220,1669104000"; d="scan'208";a="388892193" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2023 22:31:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10591"; a="801286676" X-IronPort-AV: E=Sophos;i="5.97,220,1669104000"; d="scan'208";a="801286676" Received: from tiangeng-mobl.ccr.corp.intel.com (HELO yhuang6-mobl2.ccr.corp.intel.com) ([10.255.28.220]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2023 22:31:27 -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 Subject: [PATCH -v3 6/9] migrate_pages: move migrate_folio_unmap() Date: Mon, 16 Jan 2023 14:30:54 +0800 Message-Id: <20230116063057.653862-7-ying.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230116063057.653862-1-ying.huang@intel.com> References: <20230116063057.653862-1-ying.huang@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 75B374000A X-Stat-Signature: txas7kc83ksftwq8gegfmdhkqjatb8hq X-HE-Tag: 1673850691-575962 X-HE-Meta: U2FsdGVkX19bPGrm9mD39MOS0uOZexPu+kDw97cdWcPZXaJO1h1hx4QzazajgBr+nP9R7rkDtFxngn6/+tFdqhWuQ3U1s2mD/wj50pEeINzHvyeQ26/QFGpKmdEcEjZg6CCb2zVVgREMbTxPSZQZdxOmHTZCNVvKQ4EVSwPGAIFCfxd3V2xTN7tC0kBlxf44uHwdthrJ40FvfJVXkf+3Yh6DYKVhYpsQKUcfrCo/FR+xes+6mqhsaHtfy15Fs54tdBpKY4I0ti/01x4Sn7t2dfpgV8Hxn4zqKcDjbrnndJto8Evie8ivk5mrv3/HSAzuYAC8QM3SuRc8xKtneyEQWWvOc6szr+uXquN2b4fENatJdqKHsIM7wj2vN6K0PX9twkkeRRFTPKU6db8bPeopdMetDvh2jsaKjp8yMBWMVPGfcnpCHnsxgZgx6BmttDmDAIX4VEu7kU85GaqbvIFwqX5r5Ybg+goSFqMhVhUKc5hF9dqS8VxnqmMetrHE6myT/nsro+rsxKcGhtQ8AXf44eo/omx1mOEsRAh2hav7ekCEzHRP2CTccLgP9n2nHU5v2uhmtRtcCF2oBArJkVbLD1hyH6edRCUTyRTcHcNowuBapGkSFYCHUEzlKRlKXJDYBfUV7Lzyu0LYW4GrrjKss5V1ahYywnMlc4b2+O0PSk6RFbOukIX1HNb/QVb6pGHtVNJwymNdzohsK/H/ZypOwhQCxa1HO8EqUapqfqzUhWcnf/ty/4SyKVRm3giC7SmKYNFwrJHiTd+qf7I+pXG6RA+WhOxwDcbmBDjBdP3YpEVBd3MSi8v07aM8oj+u/WWH+jYJ4tSIsqpDcHZ+vugANRpKSOhbo/rc2FGSKDSR52jNLy1d58yULGkfFJcQKU8wrkDm3GAXaupOYM2fdrWOACHODoltTmj7Nj/1HsdRCc9me6Z8aGfVSRhhefQXL0OVkl9MDlynmfY= 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 --- mm/migrate.c | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 143d96775b4d..a25966233923 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) { @@ -1277,57 +1328,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,