Subject: Re: [PATCH v2] powernv: kvm: make _PAGE_NUMA take effect

From: "Aneesh Kumar K.V" <[email-masked]>
Date: Mon, 27 Jan 2014 21:27:08 +0530

Alexander Graf <[email-masked]> writes:

> On 27.01.2014, at 11:28, Aneesh Kumar K.V <[email-masked]> wrote:
>
>> Alexander Graf <[email-masked]> writes:
>> 
>>> On 21.01.2014, at 10:42, Aneesh Kumar K.V <[email-masked]> wrote:
>>> 
>>>> Liu Ping Fan <[email-masked]> writes:
>>>> 
>>>>> To make sure that on host, the pages marked with _PAGE_NUMA result in a fault
>>>>> when guest access them, we should force the checking when guest uses hypercall
>>>>> to setup hpte.
>>>>> 
>>>>> Signed-off-by: Liu Ping Fan <[email-masked]>
>>>> 
>>>> Reviewed-by: Aneesh Kumar K.V <[email-masked]>
>>>> 
>>>> When we mark pte with _PAGE_NUMA we already call mmu_notifier_invalidate_range_start and
>>>> mmu_notifier_invalidate_range_end, which will mark existing guest hpte
>>>> entry as HPTE_V_ABSENT. Now we need to do that when we are inserting new
>>>> guest hpte entries. This patch does that. 
>>> 
>>> So what happens next? We insert a page into the HTAB without
>>> HPTE_V_VALID set, so the guest will fail to use it. If the guest does
>>> an H_READ on it it will suddenly turn to V_VALID though?
>> 
>> As per the guest the entry is valid, so yes an hread should return a
>> valid entry. But in real hpte we would mark it not valid.
>
> Ah, yes.
>
>> 
>>> 
>>> I might need a crash course in the use of HPTE_V_ABSENT.
>> 
>> When guest tries to access the address, the host will handle the fault.
>> 
>> kvmppc_hpte_hv_fault should give more info
>
> Thanks for the pointer. So we fault it in lazily. Is there any
> particular reason we can't do that on h_enter already? After all this
> just means an additional roundtrip because the guest is pretty likely
> to use the page it just entered, no?

We could get wrong numa fault information if we didn't do h_enter from
the right node from which we faulted.

-aneesh