Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1689397

[PATCH v9 01/10] mm: mempolicy: add queue_pages_required()

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Zi Yan <zi.yan@sent.com>
Newsgroups linux.kernel
Subject [PATCH v9 01/10] mm: mempolicy: add queue_pages_required()
Date Mon, 17 Jul 2017 21:50:01 +0200
Message-ID <u4kbL-Pt-9@gated-at.bofh.it> (permalink)
References <u4kbL-Pt-3@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=T/qgHD Qd3U5qaa9gTpWCC4NYNvnMT9y7rE30Zu5v6mg=; b=VeBhXOI79qODsFxfmvn31J ybYvOBkmMTNWzIae+FlwcXWhrEa/ZIx3gK3bWwm/54m4fuuwdjrcQRhiKeOFIBUX SRlIUDmRS8XAnWyYjGZv54lVMsolAkT+HLPYZ+6ftkPXoE5vpOO1vsvcbUbCLdil Yv5j0kYymeRi7o87LYoiYwyyk++56XroeLPVFg6GOSEoLQmzbdlMG6VxDtmeU5Wl X1vmaU/9dKARlSUqTwYV9XHaJ6y/s+JMlrAxXFwDJCvdZym47mE6LqdUmkBs4Wc2 xYu/Ft40N1pxCaU5QdTE0eknEoFue62CgIoSIC0nJP8Ugo6pQKAz/2plbgj4j98A ==
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=T/qgHDQd3U5qaa9gTpWCC4NYNvnMT9y7rE30Zu5v6 mg=; b=ZenoUINaPZ1VIkHWmk9vHoJOoCcNQLEpKTrzw6THws7hB5a1ckUgCm/Jg XDL7dNc5MB7D9uuhwryiXyIsUURznyStQLFhsYF+BPytTKaj5Q9JTUbMnPY3JRA0 rbhZbSWtdtBYf4yhf8Gi40uDrFo0igvXrPmqnZfTZ8HwqstEpAQyf5E621sIsZOM iet0CNhBm4MXvd4rcB5WJy3eBc4JHAoMvo8b4oZliCogtwuWagYF9cvfjHgoUc8Y iVpdqagy8Edw1ViHt7+vzMO6RKb6KZkY552Lb0hexdlRwY4twoRR8pETjp1X1+t/ 4z+fvA/6hQ0S6Pz/wqIZ3Z7Ectraw==
X-Me-Sender <xms:rBJtWeAjZ2FhSVcDiMGpD0LE7uj-dZfWNPHJ-Hh2fg3zDv1bVv2-Hw>
X-Sasl-Enc USvPPyPsfTe+CuGygxLe8+L7JYlHd+5bibOXqHwzyUxu 1500320427
X-Mailer git-send-email 2.11.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 67
Organization linux.* mail to news gateway
X-Original-Cc kirill.shutemov@linux.intel.com, minchan@kernel.org, vbabka@suse.cz, mgorman@techsingularity.net, mhocko@kernel.org, khandual@linux.vnet.ibm.com, zi.yan@cs.rutgers.edu, dnellans@nvidia.com, dave.hansen@intel.com, n-horiguchi@ah.jp.nec.com
X-Original-Date Mon, 17 Jul 2017 15:39:46 -0400
X-Original-Message-ID <20170717193955.20207-2-zi.yan@sent.com>
X-Original-References <20170717193955.20207-1-zi.yan@sent.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1689397

Show key headers only | View raw


From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>

Introduce a separate check routine related to MPOL_MF_INVERT flag.
This patch just does cleanup, no behavioral change.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu>
---
 mm/mempolicy.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index d911fa5cb2a7..58166bf1d1fd 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -412,6 +412,21 @@ struct queue_pages {
 };
 
 /*
+ * Check if the page's nid is in qp->nmask.
+ *
+ * If MPOL_MF_INVERT is set in qp->flags, check if the nid is
+ * in the invert of qp->nmask.
+ */
+static inline bool queue_pages_required(struct page *page,
+					struct queue_pages *qp)
+{
+	int nid = page_to_nid(page);
+	unsigned long flags = qp->flags;
+
+	return node_isset(nid, *qp->nmask) == !(flags & MPOL_MF_INVERT);
+}
+
+/*
  * Scan through pages checking if pages follow certain conditions,
  * and move them to the pagelist if they do.
  */
@@ -464,8 +479,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
 		 */
 		if (PageReserved(page))
 			continue;
-		nid = page_to_nid(page);
-		if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
+		if (!queue_pages_required(page, qp))
 			continue;
 		if (PageTransCompound(page)) {
 			get_page(page);
@@ -497,7 +511,6 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
 #ifdef CONFIG_HUGETLB_PAGE
 	struct queue_pages *qp = walk->private;
 	unsigned long flags = qp->flags;
-	int nid;
 	struct page *page;
 	spinlock_t *ptl;
 	pte_t entry;
@@ -507,8 +520,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,
 	if (!pte_present(entry))
 		goto unlock;
 	page = pte_page(entry);
-	nid = page_to_nid(page);
-	if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
+	if (!queue_pages_required(page, qp))
 		goto unlock;
 	/* With MPOL_MF_MOVE, we migrate only unshared hugepage. */
 	if (flags & (MPOL_MF_MOVE_ALL) ||
-- 
2.11.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v9 01/10] mm: mempolicy: add queue_pages_required() Zi Yan <zi.yan@sent.com> - 2017-07-17 21:50 +0200

csiph-web