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: 41339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2612027wrt; Mon, 9 Jan 2023 23:57:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/hMJGo0baucj595A4vUhff7DW+XYXPh19v/WgkkDiy7Bj0Q9DZZngNpJZ/XJA9gzGMQDp X-Received: by 2002:a17:90a:b395:b0:226:1531:6be6 with SMTP id e21-20020a17090ab39500b0022615316be6mr49214030pjr.48.1673337464255; Mon, 09 Jan 2023 23:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673337464; cv=none; d=google.com; s=arc-20160816; b=FyOEOLY/rML9k7xNsPrxOzBVjTMxH1hnqShQtgeCv7z7tbqRFjIFusZK6Re0hUcbXE T2ew7M4hIevnZ2upN0dGNtiTNrskX0zDTW3SkDfH977/6u8tXxsncKi3qRBzbTxT1xTD hatAHaYl1UgWCn3W6HErRfxumBcQ+n0BBHEgsPEOJI8upcPJPEzB3Di02sSCZlwTcBHK inhLWefUik+5cOlT9/VhtvhpMCNutTYUejK7JdxCATSG+xLWpqqTjnIGWBROKZId+OvH Jd0xOHR+Ir67G6+Nh2GgZePp7U8eOkK7h7iN1tF0UrT+MHDdLddeHU7zdNf4nQE569yJ BCaA== 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=lLV4TWCZsGHvy8bTmJiNBKRkyzMepfk67LuPaElxASU=; b=LBfthaNN4aqlVoUCt+jRlgkg82SIeUHPnBqFOZcV+puTziIETt0BAzVOCBQIGUFSJi mePKIjLtLon+N0lv0FvukPtTJ4ob+0NmE9hguc/0IntirbunrkG7i52PyM8jfUQDUu2u 6fCDVwA9Js6Jlj53DcdSuU5cKbxHJSheLVSLJ+ArUuVsoFzdjujQJfy5eHHvT94XZz8Q PIYNrd6Ra0hL76lSZogcBYlyKB6EnbLRMjF6M42I+1ojH7XFORNNlj0TB/dsMInEiPgo STqsKT2aXnaB9vArK4tJDW+u5t2JhkbUH4nEZxulNLk7G8uzvvkn1HnaON+xPU6h6z5e cGVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l1iVHLI5; 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 h63-20020a638342000000b004b3bad0c227si4502619pge.195.2023.01.09.23.57.31; Mon, 09 Jan 2023 23:57:44 -0800 (PST) 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=l1iVHLI5; 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 S238026AbjAJHyK (ORCPT + 99 others); Tue, 10 Jan 2023 02:54:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237682AbjAJHxz (ORCPT ); Tue, 10 Jan 2023 02:53:55 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26FAA1ADAC for ; Mon, 9 Jan 2023 23:53:54 -0800 (PST) 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="303449347" X-IronPort-AV: E=Sophos;i="5.96,314,1665471600"; d="scan'208";a="303449347" 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-Spam-Status: No, score=-4.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?1754621504516251082?= X-GMAIL-MSGID: =?utf-8?q?1754621504516251082?= 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,