[RFC 4/8] mm: Accommodate coherent device memory nodes in MPOL_BIND implementation
From: Anshuman Khandual
Date: Mon Oct 24 2016 - 00:34:04 EST
This change is part of the isolation requiring coherent device memory nodes
implementation.
Currently MPOL_MBIND interface simply fails on a coherent device memory
node after the zonelist changes introduced earlier. Without __GFP_THISNODE
flag, the first node of the nodemask will not be selected in the case where
the local node (where the application is executing) is not part of the user
provided nodemask for MPOL_MBIND. This will be the case for coherent memory
nodes which are always CPU less. This changes the mbind() system call
implementation so that memory can be allocated from coherent memory node
through MPOL_MBIND interface.
Signed-off-by: Anshuman Khandual <khandual@xxxxxxxxxxxxxxxxxx>
---
mm/mempolicy.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 0b859af..cb1ba01 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1694,6 +1694,26 @@ static struct zonelist *policy_zonelist(gfp_t gfp, struct mempolicy *policy,
if (unlikely(gfp & __GFP_THISNODE) &&
unlikely(!node_isset(nd, policy->v.nodes)))
nd = first_node(policy->v.nodes);
+
+#ifdef CONFIG_COHERENT_DEVICE
+ /*
+ * Coherent device memory
+ *
+ * In case the local node is not part of the nodemask, test if
+ * the first node in the nodemask is a coherent device memory
+ * node in which case select it.
+ *
+ * FIXME: The check will be restricted to the first node of the
+ * nodemask or scan through the nodemask to select any present
+ * coherent device memory node on it or select the first one if
+ * all of the nodes in the nodemask are coherent device memory.
+ * These are various approaches possible.
+ */
+ if (unlikely(!node_isset(nd, policy->v.nodes))) {
+ if (isolated_cdm_node(first_node(policy->v.nodes)))
+ nd = first_node(policy->v.nodes);
+ }
+#endif
break;
default:
BUG();
--
2.1.0