Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1045437ybl; Wed, 29 Jan 2020 14:18:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzL9do0krt4j5TaABtRy7sfNqz/7dsLh9R6EqYX3vQHap2kMVMZLzSn0cWkW/5ZRe4b3zEa X-Received: by 2002:a9d:6c9a:: with SMTP id c26mr1101300otr.279.1580336316726; Wed, 29 Jan 2020 14:18:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580336316; cv=none; d=google.com; s=arc-20160816; b=ukzWNF0Uw1mdG/d4d5pVcW+1ykc3EbsB+EsW2zv4pGIGG9ZUAGlj4944DX8n8jDL+L L26+m1+yJeY7VnzXCFQYvPqdOvqRunXosgirL66Sfh4uynEy464h1Mf2ApAMq0QhBlRT tz+0VOqPcYl3K1XnCY4kAvG+TC6J9E4kKpMvzsDbvUKGOj4gqTjSeOkoIzYa/PA/VoZd LSqhuBUXE3ememAfn8bZ5cG4jHNY/22hFaMU4sSoGRS6nWrx4a3GC4hUf5tjZKQ+QUD5 HzYMlms2Ns3Cpe9CmH6/qy9D4ISHChjksqNjshi1If5iFVJA617TJwGUG8c0gpmFU3K/ sE+A== 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=bejvFK7OLJvwd0qRxEfBUxq9MDa7+vqOeQKCWCzv0ww=; b=p94wd0HJIP6PiyeLFiSkiulvSmyLnzFynyAwYm/YGNPp1E4od7IdASRtDox+lQdmiE wKTpuxO5CCD7rQswank3eBveCXsLBfMHhccYuO0278SBwcAA9Oxv1iKX71oQ9ksTtDyo YiiQpMNCRYHlIjDUdDomY5H4Y1j/6ZIZO9/bm7WsPjLmNTNu537V7TangRd4J00lr2Xx 1o36NhA61/Y3SE4Mnc44C4fh76YAl2/49/pNZ2kfhZPihShR4K/lVZfjaArZa1esSYoX 3J+tempM56yMISMlC9a6mv32TXTt3gIUFHbsLqHiAbEOXM6j8zH72aRVwuv9EdEkQ3sQ KS3Q== 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 m4si1943919otr.268.2020.01.29.14.18.24; Wed, 29 Jan 2020 14:18:36 -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 S1726841AbgA2WQm (ORCPT + 99 others); Wed, 29 Jan 2020 17:16:42 -0500 Received: from mga02.intel.com ([134.134.136.20]:4886 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgA2WQd (ORCPT ); Wed, 29 Jan 2020 17:16:33 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2020 14:16:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,379,1574150400"; d="scan'208";a="261959927" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 29 Jan 2020 14:16:31 -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, david@redhat.com, Wei Yang Subject: [Patch v4 2/4] mm/migrate.c: wrap do_move_pages_to_node() and store_status() Date: Thu, 30 Jan 2020 06:16:14 +0800 Message-Id: <20200129221616.25432-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200129221616.25432-1-richardw.yang@linux.intel.com> References: <20200129221616.25432-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() are used in combination. We have three similar call sites. Let's provide a wrapper for both function calls - move_pages_and_store_status - to make the calling code easier to maintain and fix (as noted by Yang Shi, the return value handling of do_move_pages_to_node() has a flaw). [david@redhat.com rephrase changelog] Signed-off-by: Wei Yang Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- mm/migrate.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4c2a21856717..92e8c9396368 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1583,6 +1583,18 @@ 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; + return store_status(status, start, node, nr); +} + /* * Migrate an array of page address onto an array of nodes and fill * the corresponding array of status. @@ -1626,10 +1638,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 +1668,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 +1679,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