Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1045998ybl; Wed, 29 Jan 2020 14:19:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwvHDawpSccwT2mw6whNTYQJ7FI4rCzW1WP0G6I4JHHiMpsOyifaUehYZ7sV4Shhrj9eWLG X-Received: by 2002:aca:43c1:: with SMTP id q184mr789307oia.116.1580336352442; Wed, 29 Jan 2020 14:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580336352; cv=none; d=google.com; s=arc-20160816; b=VxaL3lH0bZvF/uOQlAqqFr+UelJRPp6pXSeIC2XSVHlAgNTD5dEluzYwMGD9fqA1G2 aW2PyzmrQN0C8n/GoaAKBuo4fkuxyQ+q7woN7dLgzD/9VX+qBNXNOu7IwvBTyQz9eWkA Wep6s2gVYFVGKJGwALlIcg6t1HN9xY+snIbNGqALsGA1NNlp4cn1URJGkPLEiDks5jjl CrMgbwWsvTV+JR9NvRgH9jj3iuZNAsO3jxNUohaMfBOWiH6Q0XrmlJJ+ZaB0x1Oku0hO pmQMD4vxt4nkDMWThIS2FJsr1d3f/X6H/M1pSvDP0kGaTAxHyi9l9JXc/fsoj5vTuRF9 SbSg== 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=wlZxEzzj54NM4skP2fwJLqTwOG0vtU6s0Pxy3Mnk8Lk=; b=MKsj+BwNfX9qX4MmnXRiqv5V5G369UEFlknxDJYY7Kj0/NVvGfa9OeY+JqcWRgxn12 I9qWgCMi1tp8IDMQvlD+NPaq2zx3Us//TcLYfgjlXRfABWdoUWopaRR7M58e0OK1xReo Y7UFoFc+2dpM+cQnplRcaWvxkK87axvakcHtdegtwCUb2rNMLBsZVQjKq8bFT0aSN4J1 R/Nlfpz/CAm0BS77aYuN0dG4faLbGXbS2h48EmSuvmpdOXacrcE7NDRQNGHBkkJSZggS nwcBW5jram8IL5X0A9YM5qRdmfWdmy3dwS02K97JGQxeLlx0G4ICt8UNpktT5uSv0Vep jqhw== 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 a5si1888338oti.22.2020.01.29.14.19.00; Wed, 29 Jan 2020 14:19:12 -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 S1726821AbgA2WQi (ORCPT + 99 others); Wed, 29 Jan 2020 17:16:38 -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 S1726222AbgA2WQh (ORCPT ); Wed, 29 Jan 2020 17:16:37 -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:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,379,1574150400"; d="scan'208";a="261959958" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 29 Jan 2020 14:16:35 -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 4/4] mm/migrate.c: unify "not queued for migration" handling in do_pages_move() Date: Thu, 30 Jan 2020 06:16:16 +0800 Message-Id: <20200129221616.25432-5-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 It can currently happen that we store the status of a page twice: * Once we detect that it is already on the target node * Once we moved a bunch of pages, and a page that's already on the target node is contained in the current interval. Let's simplify the code and always call do_move_pages_to_node() in case we did not queue a page for migration. Note that pages that are already on the target node are not added to the pagelist and are, therefore, ignored by do_move_pages_to_node() - there is no functional change. The status of such a page is now only stored once. [david@redhat.com rephrase changelog] Signed-off-by: Wei Yang Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- mm/migrate.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 981916007b4f..7c850fe5a1a8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1653,18 +1653,16 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, err = add_page_for_migration(mm, addr, current_node, &pagelist, flags & MPOL_MF_MOVE_ALL); - if (!err) { - /* The page is already on the target node */ - err = store_status(status, i, current_node, 1); - if (err) - goto out_flush; - continue; - } else if (err > 0) { + if (err > 0) { /* The page is successfully queued for migration */ continue; } - err = store_status(status, i, err, 1); + /* + * If the page is already on the target node (!err), store the + * node, otherwise, store the err. + */ + err = store_status(status, i, err ? : current_node, 1); if (err) goto out_flush; -- 2.17.1