Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1131605ybv; Thu, 13 Feb 2020 16:32:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzIjiHHWsHH+s2xasAXv0hrZWbDimT+d9SqKmu1RmKBhKbAVxifNawCZuvw5kPIDESWtqVQ X-Received: by 2002:a9d:6b95:: with SMTP id b21mr169914otq.96.1581640342971; Thu, 13 Feb 2020 16:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581640342; cv=none; d=google.com; s=arc-20160816; b=wFU8NK4xNrB0wTpbiM9I5kZXjm9NF5Gim6kmOmGZtgvvapAJrUlO3sBaCKapJDOYWe kHcPgCFmQ5oDSYiv/7uuwF0GmUAYhN6UkZSo796/q79507FWeq9QhsF0OQAjiphF6EVb BmvWGEMbLREHica9uYUK/yEUBqyVcyqNgFyZJwczfOOehlIESwGIDkQ2karVblyyVL2Y Jxos6GURvB3WcTOTvZKpFodiAmN/y5EP2oOZa5eDur5AQCY6+fYqwLQexPiwWCVTwTCA nSgtcePQsFEX9DKY78BaYK+j2JAiperY3Liggll4Sy8fNeUCAdpA7K9r7ZZrju/R+HSt mzZA== 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=ot2E8isL/0YPvi0U9VSy4E33wluBgrA81uc0VyGuZaU=; b=Q2yHWv83OC/Q6+tk8ACwmmlLuSvLJa7k59YsG5K1fhBBcw9knER33edSxAHt45pqhr ziACRzdnbI7yCffQ9wMEXg844oTGipfndOm3aGP6EJXr0QqqmckuvrxRjocYQny4RDpm 02J8BRCz7zbHSwPRIudl8TU/SswsaBOuirQf+zevnRC6u0038at9utbL/PnHNX0tTYBV sey9lKR+ddOd2BC7SDX8E384l2yfeKlNiCDndz+aQG5fgSn/yZKNgCMmZM4/Su1BZ1hz axi0RuWmhdAXcJ1BkreI/HvT1xBKv5w8T5iBD+X/9z5h7i2RmqpMLVab9vQzVTQXam/p QNew== 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 i15si2006947otk.120.2020.02.13.16.32.10; Thu, 13 Feb 2020 16:32:22 -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 S1728176AbgBNAaZ (ORCPT + 99 others); Thu, 13 Feb 2020 19:30:25 -0500 Received: from mga09.intel.com ([134.134.136.24]:25633 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbgBNAaW (ORCPT ); Thu, 13 Feb 2020 19:30:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2020 16:30:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,438,1574150400"; d="scan'208";a="227246085" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga007.fm.intel.com with ESMTP; 13 Feb 2020 16:30:20 -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 v5 4/4] mm/migrate.c: unify "not queued for migration" handling in do_pages_move() Date: Fri, 14 Feb 2020 08:30:17 +0800 Message-Id: <20200214003017.25558-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200214003017.25558-1-richardw.yang@linux.intel.com> References: <20200214003017.25558-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 fe62b96852a3..4a8902a443fd 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1664,18 +1664,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