Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4303713ybl; Tue, 21 Jan 2020 17:19:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwcDliwfChW/9fGMPweAv3idPVZGrAKrVbdEdkSLRFA/rxCOyeX7H6ZDyZN0mjWRkwyvtp1 X-Received: by 2002:aca:c494:: with SMTP id u142mr5328891oif.86.1579655997912; Tue, 21 Jan 2020 17:19:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579655997; cv=none; d=google.com; s=arc-20160816; b=gLKBPjF3RQI+EbC3piV+0mnnhgtrg3wIqrRO2GPqZHSZGtL9uKXwHTaq1S3JaGg1GK 8udAWcuYRexGhnqeD+THfQvzIH57ebTvnzWKRXpx+NaX1LE4XyNv69EcfNPjFNf2jatO NYImYACazwNgNRIX9iDvWBTsWsMZT9C6kTc8L3xp8flEio9r6cov3qpcW8JauMnAHsc1 mBhIbYR12anVB3kGG5yWJe3+jvpdoOOH6/AolcMoCLDZlWEs8Yz1WCqXalNfI7TNMB8P LnY9zYq8ojw7xwJ7irMUzPuwPwSDfpK6dHs98rt/uKYAQrwfb8f57kbjh9pjuRwgAJgG yveQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ei/AcEPAP9OGJWWBVUhlNCtbVGfPQ4tU9R5wKM0mDZo=; b=kZW8BVYa257ldtjKi7wrxBX6FIoFiTir8XQR4iGxUO8cARDwIHptbhUYEk1LbBg7SK Io7ORcAfuN8EYM+m2hbIx592nrnO5CrJ7DwaDXWMEPLmJwP0+c/kECaaTlSS/GAGVeWl wCYexOzZtC64TfaAYmOyHqrJtH0w+1ItbXegi/w2sFTaDGynXOnf56oydPH3uEkl+LKb PCnkpgK9H0wGB87f80NlgMBPDyB+HXdzcqj9RlkVzY2JH7TqIwWuxO/MI5E1OnholO/R UIlfq+aoKl2a6Yj7cA/OpoxnOCt/JEv9f1aCVqvalOVaShQLUNue7XMQdY7waZiF7A8k BJMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si20801793otp.184.2020.01.21.17.19.45; Tue, 21 Jan 2020 17:19:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729129AbgAVBRQ (ORCPT + 99 others); Tue, 21 Jan 2020 20:17:16 -0500 Received: from mga06.intel.com ([134.134.136.31]:24737 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729058AbgAVBRL (ORCPT ); Tue, 21 Jan 2020 20:17:11 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2020 17:17:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,347,1574150400"; d="scan'208";a="244885507" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 21 Jan 2020 17:17:09 -0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, mhocko@suse.com, yang.shi@linux.alibaba.com, rientjes@google.com, Wei Yang Subject: [Patch v2 2/4] mm/migrate.c: wrap do_move_pages_to_node() and store_status() Date: Wed, 22 Jan 2020 09:16:45 +0800 Message-Id: <20200122011647.13636-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200122011647.13636-1-richardw.yang@linux.intel.com> References: <20200122011647.13636-1-richardw.yang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Also mentioned by Yang Shi, the handling of do_move_pages_to_node()'s return value is not proper. Now we can fix it in one place. Signed-off-by: Wei Yang Acked-by: Michal Hocko --- mm/migrate.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4c2a21856717..a4d3bd6475e1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1583,6 +1583,19 @@ 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, + int start, int nr) +{ + int err; + + err = do_move_pages_to_node(mm, pagelist, node); + if (err) + return err; + err = store_status(status, start, node, nr); + return err; +} + /* * Migrate an array of page address onto an array of nodes and fill * the corresponding array of status. @@ -1626,10 +1639,8 @@ 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) - goto out; - err = store_status(status, start, current_node, i - start); + err = move_pages_and_store_status(mm, current_node, + &pagelist, status, start, i - start); if (err) goto out; start = i; @@ -1658,10 +1669,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) - goto out; - err = store_status(status, start, current_node, i - start); + err = move_pages_and_store_status(mm, current_node, &pagelist, + status, start, i - start); if (err) goto out; current_node = NUMA_NO_NODE; @@ -1671,9 +1680,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); - if (!err1) - err1 = store_status(status, start, current_node, i - start); + err1 = move_pages_and_store_status(mm, current_node, &pagelist, + status, start, i - start); if (err >= 0) err = err1; out: -- 2.17.1