[PATCH RFC v7 2/8] mm/mempolicy: Export memory policy symbols

From: Shivank Garg
Date: Tue Apr 08 2025 - 07:26:49 EST


KVM guest_memfd wants to implement support for NUMA policies just like
shmem already does using the shared policy infrastructure. As
guest_memfd currently resides in KVM module code, we have to export the
relevant symbols.

In the future, guest_memfd might be moved to core-mm, at which point the
symbols no longer would have to be exported. When/if that happens is
still unclear.

Acked-by: David Hildenbrand <david@xxxxxxxxxx>
Acked-by: Vlastimil Babka <vbabka@xxxxxxx>
Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
---
mm/mempolicy.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index b28a1e6ae096..18182dd38fc1 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -245,6 +245,7 @@ struct mempolicy *get_task_policy(struct task_struct *p)

return &default_policy;
}
+EXPORT_SYMBOL_GPL(get_task_policy);

static const struct mempolicy_operations {
int (*create)(struct mempolicy *pol, const nodemask_t *nodes);
@@ -378,6 +379,7 @@ void __mpol_put(struct mempolicy *pol)
return;
kmem_cache_free(policy_cache, pol);
}
+EXPORT_SYMBOL_GPL(__mpol_put);

static void mpol_rebind_default(struct mempolicy *pol, const nodemask_t *nodes)
{
@@ -2767,6 +2769,7 @@ struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
read_unlock(&sp->lock);
return pol;
}
+EXPORT_SYMBOL_GPL(mpol_shared_policy_lookup);

static void sp_free(struct sp_node *n)
{
@@ -3052,6 +3055,7 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
mpol_put(mpol); /* drop our incoming ref on sb mpol */
}
}
+EXPORT_SYMBOL_GPL(mpol_shared_policy_init);

int mpol_set_shared_policy(struct shared_policy *sp,
struct vm_area_struct *vma, struct mempolicy *pol)
@@ -3070,6 +3074,7 @@ int mpol_set_shared_policy(struct shared_policy *sp,
sp_free(new);
return err;
}
+EXPORT_SYMBOL_GPL(mpol_set_shared_policy);

/* Free a backing policy store on inode delete. */
void mpol_free_shared_policy(struct shared_policy *sp)
@@ -3088,6 +3093,7 @@ void mpol_free_shared_policy(struct shared_policy *sp)
}
write_unlock(&sp->lock);
}
+EXPORT_SYMBOL_GPL(mpol_free_shared_policy);

#ifdef CONFIG_NUMA_BALANCING
static int __initdata numabalancing_override;
--
2.34.1