[PATCH v12 05/12] KVM: guest_memfd: Enforce NUMA mempolicy using shared policy
Garg, Shivank
shivankg at amd.com
Fri Oct 10 00:57:47 PDT 2025
>>
>> @@ -112,6 +114,19 @@ static int kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot,
>> return r;
>> }
>>
>> +static struct mempolicy *kvm_gmem_get_folio_policy(struct gmem_inode *gi,
>> + pgoff_t index)
>
> How about kvm_gmem_get_index_policy() instead, since the policy is keyed
> by index?
>
>> +{
>> +#ifdef CONFIG_NUMA
>> + struct mempolicy *mpol;
>> +
>> + mpol = mpol_shared_policy_lookup(&gi->policy, index);
>> + return mpol ? mpol : get_task_policy(current);
>
> Should we be returning NULL if no shared policy was defined?
>
> By returning NULL, __filemap_get_folio_mpol() can handle the case where
> cpuset_do_page_mem_spread().
>
> If we always return current's task policy, what if the user wants to use
> cpuset_do_page_mem_spread()?
>
I initially followed shmem's approach here.
I agree that returning NULL maintains consistency with the current default
behavior of cpuset_do_page_mem_spread(), regardless of CONFIG_NUMA.
I'm curious what could be the practical implications of cpuset_do_page_mem_spread()
v/s get_task_policy() as the fallback?
Which is more appropriate for guest_memfd when no policy is explicitly set via mbind()?
More information about the linux-arm-kernel
mailing list