Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1115383ybl; Sat, 18 Jan 2020 19:09:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwHmnjYPMmpTJRgXEByD8cLrgKOQJW/dzrWyWKkrvwUFncDj8G7uADFzTrfJSzsCpgQHAnd X-Received: by 2002:a9d:21f4:: with SMTP id s107mr11973567otb.102.1579403367631; Sat, 18 Jan 2020 19:09:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579403367; cv=none; d=google.com; s=arc-20160816; b=jlCoyrF4Ens+CcrbQNvm/nBC4WHUZ/zEOtLnRmYfUhdQhyWd/iGyTqyzmh4P4WKMwl UZ3EvccPRPc0K6mpW68nFqqgMuRmtji4TIZUeHQTXbD+8dIF/rsFlElsbUfnoNdy1fcv 19nulFvUqBqzsdrrDxdgE7qC4j/vl+K3RMSY6pRW/PLUcvsnVDJnA33gNVzBfYKPmjxE rjZzugljeetdkoIE/sgww+SioNHmJR+qO55VfBeltkKBrc4Ulf2RvqHoNVG7T17K/SbV GHiwIVcdGiqtoTH8xZVWMWMiTcYrt8WYwg8x3ynd29zDpGeoe6zpF7Mh5t/gJOMYNqgK Rwpw== 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=pIXOYH8qghXKzzwIi9DpqPSmFtSrUI58rxeiWZK6Iwc=; b=TKK6Xq8PMHyLMCRaku47XI7h+RLslG7H0WnFtP2kJFvLMFG8rGlYTgPuH9Xh+nC+Fa 6gOt9XFbMb7T+SQ046YFIhQ6I7y8gL16tW0og3stdmOocXatXGyJfNq+aR5Z3sT8A7eZ 6OsuCX4ShrFLc8Q3RB2fNoSMX8PtCfC+0yxQoIaKOSQIXYcGpdKMxBFkmf8wDp74QXjX 9gaS5HdVIeaIW67Sre0ZognUyk/WVZ2Anyvzm2miXniqWpvP2ae6Yl6IvGKSD67M5DZS k4LxOD/ogl+PY8mOXHIBqLgRzi3GAiJ/1r4/o1TN8NrZC0gRHlGVenI5CppX30kbJkSo wnJw== 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 y18si16557448oix.27.2020.01.18.19.09.16; Sat, 18 Jan 2020 19:09:27 -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 S1729211AbgASDHt (ORCPT + 99 others); Sat, 18 Jan 2020 22:07:49 -0500 Received: from mga07.intel.com ([134.134.136.100]:14153 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbgASDHZ (ORCPT ); Sat, 18 Jan 2020 22:07:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2020 19:07:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,336,1574150400"; d="scan'208";a="258308782" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 18 Jan 2020 19:07:24 -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, Wei Yang Subject: [PATCH 4/8] mm/migrate.c: wrap do_move_pages_to_node() and store_status() Date: Sun, 19 Jan 2020 11:06:32 +0800 Message-Id: <20200119030636.11899-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200119030636.11899-1-richardw.yang@linux.intel.com> References: <20200119030636.11899-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 --- mm/migrate.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4a63fb8fbb6d..dec147d3a4dd 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. @@ -1629,10 +1642,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; @@ -1661,10 +1672,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; @@ -1674,13 +1683,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) { - if (err >= 0) - err = err1; - goto out; - } - 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