Thread (26 messages) 26 messages, 4 authors, 2023-11-28
STALE944d

[RFC PATCH 08/11] mm/mempolicy: export replace_mempolicy for use by procfs

From: Gregory Price <hidden>
Date: 2023-11-22 21:12:30
Also in: linux-arch, linux-doc, linux-fsdevel, linux-mm, lkml
Subsystem: memory management, memory management - memory policy and migration, the rest · Maintainers: Andrew Morton, David Hildenbrand, Linus Torvalds

We will be adding a /proc/pid/mempolicy entry for use in swapping
the mempolicy of a process at runtime.  Export replace_mempolicy
so that this can be used by that interface.

Signed-off-by: Gregory Price <redacted>
---
 include/linux/mempolicy.h | 9 +++++++++
 mm/mempolicy.c            | 5 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 931b118336f4..b951e96a53ce 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -177,6 +177,8 @@ static inline bool mpol_is_preferred_many(struct mempolicy *pol)
 
 extern bool apply_policy_zone(struct mempolicy *policy, enum zone_type zone);
 
+extern long replace_mempolicy(struct task_struct *task, struct mempolicy *new,
+			      nodemask_t *nodes);
 #else
 
 struct mempolicy {};
@@ -297,5 +299,12 @@ static inline bool mpol_is_preferred_many(struct mempolicy *pol)
 	return  false;
 }
 
+static inline long replace_mempolicy(struct task_struct *task,
+				     struct mempolicy *new,
+				     nodemask_t *nodes)
+{
+	return -ENODEV;
+}
+
 #endif /* CONFIG_NUMA */
 #endif
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index fb295ade8ad7..e0c9127571dd 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -815,9 +815,8 @@ static int mbind_range(struct vma_iterator *vmi, struct vm_area_struct *vma,
 }
 
 /* Attempt to replace mempolicy, release the old one if successful */
-static long replace_mempolicy(struct task_struct *task,
-			      struct mempolicy *new,
-			      nodemask_t *nodes)
+long replace_mempolicy(struct task_struct *task, struct mempolicy *new,
+		       nodemask_t *nodes)
 {
 	struct mempolicy *old = NULL;
 	NODEMASK_SCRATCH(scratch);
-- 
2.39.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help