powernv: kvm: make _PAGE_NUMA take effect
Subsystems (3)
PATCH v2 1/1 powernv: kvm: make _PAGE_NUMA take effect
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.
---
v2:
It should be the reply to "[PATCH 2/4] powernv: kvm: make _PAGE_NUMA take effect" And I imporve the changelog according to Aneesh's suggestion.
--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
@@ -232,7 +232,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,/* Look up the Linux PTE for the backing page */ pte_size = psize; pte =lookup_linux_pte (pgdir, hva, writing, &pte_size); -if (pte_present (pte)) { +if (pte_present (pte) && !pte_numa (pte)) {if (writing && !pte_write (pte))/* make the actual HPTE be read-only */ ptel =hpte_make_readonly (ptel);
Signature · 1 line
1.8.1.4
Quoted 5 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult 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 protected]>
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.
Quoted 23 lines
---
v2:
It should be the reply to "[PATCH 2/4] powernv: kvm: make_PAGE_NUMAtake effect" And I imporve the changelog according to Aneesh's suggestion.--- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kvm/book3s_hv_rm_mmu.c +1
-1@@ -232,7 +232,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,/* Look up the Linux PTE for the backing page */ pte_size = psize; pte =lookup_linux_pte (pgdir, hva, writing, &pte_size); -if (pte_present (pte)) { +if (pte_present (pte) && !pte_numa (pte)) {if (writing && !pte_write (pte))/* make the actual HPTE be read-only */ ptel =hpte_make_readonly (ptel);Signature · 1 line
1.8.1.4
Quoted 6 lines · Aneesh Kumar K.V
Quoted 4 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.
Quoted 8 lines
Quoted 1 line
Signed-off-by Liu Ping Fan <[email protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_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?
I might need a crash course in the use of HPTE_V_ABSENT.
Alex
Quoted 12 lines · Alexander Graf
Quoted 10 lines · Aneesh Kumar K.V
Quoted 5 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult 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 protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>
Quoted 8 lines
Quoted 4 lines
When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_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_VALIDset, so the guest will fail to use it. If the guest does anH_READon it it will suddenly turn toV_VALIDthough?
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.
Quoted 2 lines
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
-aneesh
Quoted 19 lines · Aneesh Kumar K.V
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Aneesh Kumar K.V
Quoted 5 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult 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 protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_V_ABSENT. Now we need to do that when we are inserting new guest hpte entries. This patch does that.
Quoted 6 lines
Quoted 3 lines
So what happens next? We insert a page into the HTAB without
HPTE_V_VALIDset, so the guest will fail to use it. If the guest does anH_READon it it will suddenly turn toV_VALIDthough?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.
Quoted 7 lines
Quoted 3 lines
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_faultshould 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?
Alex
Quoted 34 lines · Alexander Graf
Quoted 19 lines · Aneesh Kumar K.V
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Aneesh Kumar K.V
Quoted 5 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult 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 protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_V_ABSENT. Now we need to do that when we are inserting new guest hpte entries. This patch does that.Quoted 6 lines
Quoted 3 lines
So what happens next? We insert a page into the HTAB without
HPTE_V_VALIDset, so the guest will fail to use it. If the guest does anH_READon it it will suddenly turn toV_VALIDthough?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.
Quoted 4 lines
Quoted 3 lines
I might need a crash course in the use of
HPTE_V_ABSENT.
Quoted 8 lines
Quoted 3 lines
When guest tries to access the address, the host will handle the fault.
kvmppc_hpte_hv_faultshould give more infoThanks for the pointer. So we fault it in lazily. Is there any particular reason we can't do that on
h_enteralready? 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
Quoted 13 lines · Alexander Graf
Quoted 10 lines · Aneesh Kumar K.V
Quoted 5 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult 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 protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>
Quoted 8 lines
Quoted 4 lines
When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_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_VALIDset, so the guest will fail to use it. If the guest does anH_READon it it will suddenly turn toV_VALIDthough?I might need a crash course in the use of
HPTE_V_ABSENT.
HPTE_V_ABSENT means present from the point of view of the guest but not present from the host's point of view, so yes H_READ turns HPTE_V_ABSENT into HPTE_V_VALID.
Paul.
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
Thx,
Fan
Quoted 18 lines · Alexander Graf
Quoted 6 lines · Aneesh Kumar K.V
Quoted 4 lines · Liu Ping Fan
To make sure that on host, the pages marked with
_PAGE_NUMAresult in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.Quoted 8 lines
Quoted 1 line
Signed-off-by Liu Ping Fan <[email protected]>Reviewed-by Aneesh Kumar K.V <[email protected]>When we mark pte with
_PAGE_NUMAwe already callmmu_notifier_invalidate_range_startandmmu_notifier_invalidate_range_end, which will mark existing guest hpte entry asHPTE_V_ABSENT. Now we need to do that when we are inserting new guest hpte entries. This patch does that.
Quoted 7 lines
So what happens next? We insert a page into the HTAB without
HPTE_V_VALIDset, so the guest will fail to use it. If the guest does anH_READon it it will suddenly turn toV_VALIDthough?I might need a crash course in the use of
HPTE_V_ABSENT.Alex
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 2 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
I'm trying to figure out whether I need to mark this with a stable tag for 3.14.
Alex
Quoted 8 lines · Alexander Graf
Quoted 2 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
I'm trying to figure out whether I need to mark this with a stable tag for 3.14.
Also, what about the other uses of pre_present()?
Alex
Quoted 4 lines · Alexander Graf
Quoted 2 lines · Alexander Graf
On 03.04.14 04:36, Liu ping fan wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
I'm trying to figure out whether I need to mark this with a stable tag for 3.14.
Also, what about the other uses of
pre_present()?
Oh how I love to reply to myself. The patch doesn't apply to the latest code anymore either. Also please rework the wording of your patch subject and patch description to explain the actual problem at hand.
Alex
Quoted 6 lines · Alexander Graf
Quoted 2 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
Nothing much, we won't be properly accounting the numa access in the host. What we want to achieve is to convert a guest access of the page to a host fault so that we can do proper numa access accounting in the host. This would enable us to migrate the page to the correct numa node.
Quoted 5 lines
I'm trying to figure out whether I need to mark this with a stable tag for 3.14.
-aneesh
Quoted 5 lines · Aneesh Kumar K.V
Quoted 3 lines · Alexander Graf
Quoted 2 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
Quoted 7 lines
Quoted 2 lines
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
Nothing much, we won't be properly accounting the numa access in the host. What we want to achieve is to convert a guest access of the page to a host fault so that we can do proper numa access accounting in the host. This would enable us to migrate the page to the correct numa node.
Ok, so no breakages, just less performance. I wouldn't consider it stable material then :).
Alex
Quoted 20 lines · Alexander Graf
Quoted 8 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 3 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
Quoted 8 lines
Quoted 2 lines
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
Nothing much, we won't be properly accounting the numa access in the host. What we want to achieve is to convert a guest access of the page to a host fault so that we can do proper numa access accounting in the host. This would enable us to migrate the page to the correct numa node.
Quoted 3 lines
Ok, so no breakages, just less performance. I wouldn't consider it stable material then :).
Sorry to reply late, since I am half out of office during this period.
I am puzzling about you reply. Without this patch, the guest can
NOT sense the numa changes and ask host to put the pages in right place. So the pages which is used by guest will be always misplaced. The numa-fault method is inspired by real requirement to improve performance, so we should also consider the performance drop of guest. Right?
Regards,
Fan
Quoted 3 lines
Alex
Quoted 18 lines · Liu ping fan
Quoted 8 lines · Alexander Graf
Quoted 7 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 2 lines · Liu ping fan
Hi Alex, could you help to pick up this patch? since v3.14 kernel can enable numa fault for powerpc.
What bad happens without this patch? We map a page even though it was declared to get NUMA migrated? What happens next?
Quoted 9 lines
Quoted 5 lines
Nothing much, we won't be properly accounting the numa access in the host. What we want to achieve is to convert a guest access of the page to a host fault so that we can do proper numa access accounting in the host. This would enable us to migrate the page to the correct numa node.
Ok, so no breakages, just less performance. I wouldn't consider it stable material then :).
Quoted 7 lines
Sorry to reply late, since I am half out of office during this period.
I am puzzling about you reply. Without this patch, the guest can
NOT sense the numa changes and ask host to put the pages in right place. So the pages which is used by guest will be always misplaced. The numa-fault method is inspired by real requirement to improve performance, so we should also consider the performance drop of guest. Right?
The patch will get into Linux, I just consider a non-working new feature not a regression that warrants us to CC stable@vger :). After all performance shouldn't be worse than without the numa migration feature, correct?
Alex