[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1615952410-36895-6-git-send-email-feng.tang@intel.com>
Date: Wed, 17 Mar 2021 11:40:02 +0800
From: Feng Tang <feng.tang@...el.com>
To: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Michal Hocko <mhocko@...nel.org>,
Andrea Arcangeli <aarcange@...hat.com>,
David Rientjes <rientjes@...gle.com>,
Mel Gorman <mgorman@...hsingularity.net>,
Mike Kravetz <mike.kravetz@...cle.com>,
Randy Dunlap <rdunlap@...radead.org>,
Vlastimil Babka <vbabka@...e.cz>,
Dave Hansen <dave.hansen@...el.com>,
Ben Widawsky <ben.widawsky@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
Dan Williams <dan.j.williams@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Feng Tang <feng.tang@...el.com>
Subject: [PATCH v4 05/13] mm/mempolicy: refactor rebind code for PREFERRED_MANY
From: Dave Hansen <dave.hansen@...ux.intel.com>
Again, this extracts the "only one node must be set" behavior of
MPOL_PREFERRED. It retains virtually all of the existing code so it can
be used by MPOL_PREFERRED_MANY as well.
v2:
Fixed typos in commit message. (Ben)
Merged bits from other patches. (Ben)
annotate mpol_rebind_preferred_many as unused (Ben)
Link: https://lore.kernel.org/r/20200630212517.308045-6-ben.widawsky@intel.com
Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
Signed-off-by: Ben Widawsky <ben.widawsky@...el.com>
Signed-off-by: Feng Tang <feng.tang@...el.com>
---
mm/mempolicy.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 6fb2cab..fbfa3ce 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -363,14 +363,11 @@ static void mpol_rebind_nodemask(struct mempolicy *pol, const nodemask_t *nodes)
pol->v.nodes = tmp;
}
-static void mpol_rebind_preferred(struct mempolicy *pol,
- const nodemask_t *nodes)
+static void mpol_rebind_preferred_common(struct mempolicy *pol,
+ const nodemask_t *preferred_nodes,
+ const nodemask_t *nodes)
{
nodemask_t tmp;
- nodemask_t preferred_node;
-
- /* MPOL_PREFERRED uses only the first node in the mask */
- preferred_node = nodemask_of_node(first_node(*nodes));
if (pol->flags & MPOL_F_STATIC_NODES) {
int node = first_node(pol->w.user_nodemask);
@@ -385,12 +382,30 @@ static void mpol_rebind_preferred(struct mempolicy *pol,
pol->v.preferred_nodes = tmp;
} else if (!(pol->flags & MPOL_F_LOCAL)) {
nodes_remap(tmp, pol->v.preferred_nodes,
- pol->w.cpuset_mems_allowed, preferred_node);
+ pol->w.cpuset_mems_allowed, *preferred_nodes);
pol->v.preferred_nodes = tmp;
pol->w.cpuset_mems_allowed = *nodes;
}
}
+/* MPOL_PREFERRED_MANY allows multiple nodes to be set in 'nodes' */
+static void __maybe_unused mpol_rebind_preferred_many(struct mempolicy *pol,
+ const nodemask_t *nodes)
+{
+ mpol_rebind_preferred_common(pol, nodes, nodes);
+}
+
+static void mpol_rebind_preferred(struct mempolicy *pol,
+ const nodemask_t *nodes)
+{
+ nodemask_t preferred_node;
+
+ /* MPOL_PREFERRED uses only the first node in 'nodes' */
+ preferred_node = nodemask_of_node(first_node(*nodes));
+
+ mpol_rebind_preferred_common(pol, &preferred_node, nodes);
+}
+
/*
* mpol_rebind_policy - Migrate a policy to a different set of nodes
*
--
2.7.4
Powered by blists - more mailing lists