From patchwork Sun Jan 26 10:26:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11351807 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC0B513A4 for ; Sun, 26 Jan 2020 10:27:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3088214AF for ; Sun, 26 Jan 2020 10:27:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3088214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C6146B0007; Sun, 26 Jan 2020 05:27:23 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 779136B0008; Sun, 26 Jan 2020 05:27:23 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C9DE6B000A; Sun, 26 Jan 2020 05:27:23 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 477936B0007 for ; Sun, 26 Jan 2020 05:27:23 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id CE10940FB for ; Sun, 26 Jan 2020 10:27:22 +0000 (UTC) X-FDA: 76419408324.18.crate38_405649c1a6c14 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org:mhocko@suse.com:yang.shi@linux.alibaba.com:rientjes@google.com::linux-kernel@vger.kernel.org:richardw.yang@linux.intel.com,RULES_HIT:30003:30034:30046:30051:30054:30070,0,RBL:192.55.52.43:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: crate38_405649c1a6c14 X-Filterd-Recvd-Size: 4802 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Sun, 26 Jan 2020 10:27:21 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2020 02:27:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,365,1574150400"; d="scan'208";a="223002739" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga008.fm.intel.com with ESMTP; 26 Jan 2020 02:27:19 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: mhocko@suse.com, yang.shi@linux.alibaba.com, rientjes@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [Patch v3 2/4] mm/migrate.c: wrap do_move_pages_to_node() and store_status() Date: Sun, 26 Jan 2020 18:26:21 +0800 Message-Id: <20200126102623.9616-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200126102623.9616-1-richardw.yang@linux.intel.com> References: <20200126102623.9616-1-richardw.yang@linux.intel.com> 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: Usually do_move_pages_to_node() and store_status() is a pair. There are three places call this pair of functions with almost the same form. This patch just wrap it to make it friendly to audience and also consolidate the move and store action into one place. Signed-off-by: Wei Yang Acked-by: Michal Hocko --- mm/migrate.c | 61 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index ae3db45c6a42..e816c8990296 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1583,6 +1583,29 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr, return err; } +static int move_pages_and_store_status(struct mm_struct *mm, int node, + struct list_head *pagelist, int __user *status, + unsigned long nr_pages, int start, int i) +{ + int err; + + err = do_move_pages_to_node(mm, pagelist, node); + if (err) { + /* + * Positive err means the number of failed + * pages to migrate. Since we are going to + * abort and return the number of non-migrated + * pages, so need incude the rest of the + * nr_pages that have not attempted as well. + */ + if (err > 0) + err += nr_pages - i - 1; + return err; + } + err = store_status(status, start, node, i - start); + return err; +} + /* * Migrate an array of page address onto an array of nodes and fill * the corresponding array of status. @@ -1626,20 +1649,9 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, current_node = node; start = i; } else if (node != current_node) { - err = do_move_pages_to_node(mm, &pagelist, current_node); - if (err) { - /* - * Positive err means the number of failed - * pages to migrate. Since we are going to - * abort and return the number of non-migrated - * pages, so need incude the rest of the - * nr_pages that have not attempted as well. - */ - if (err > 0) - err += nr_pages - i - 1; - goto out; - } - err = store_status(status, start, current_node, i - start); + err = move_pages_and_store_status(mm, current_node, + &pagelist, status, nr_pages, + start, i); if (err) goto out; start = i; @@ -1668,13 +1680,8 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, if (err) goto out_flush; - err = do_move_pages_to_node(mm, &pagelist, current_node); - if (err) { - if (err > 0) - err += nr_pages - i - 1; - goto out; - } - err = store_status(status, start, current_node, i - start); + err = move_pages_and_store_status(mm, current_node, &pagelist, + status, nr_pages, start, i); if (err) goto out; current_node = NUMA_NO_NODE; @@ -1684,16 +1691,8 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, return err; /* Make sure we do not overwrite the existing error */ - err1 = do_move_pages_to_node(mm, &pagelist, current_node); - /* - * Don't have to report non-attempted pages here since: - * - If the above loop is done gracefully there is not non-attempted - * page. - * - If the above loop is aborted to it means more fatal error - * happened, should return err. - */ - if (!err1) - err1 = store_status(status, start, current_node, i - start); + err1 = move_pages_and_store_status(mm, current_node, &pagelist, + status, nr_pages, start, i); if (err >= 0) err = err1; out: