Skip to contentSkip to conversation

powernv: kvm: make _PAGE_NUMA take effect

PATCH In review Liu Ping Fan 5 participants 15 messages Jan 21, 2014 – Apr 10, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
index 9c51544..af8602d 100644
@@ -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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Liu Ping Fan

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.

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_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
index 9c51544..af8602d 100644
@@ -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
#2 lore raw
Quoted 6 lines · Aneesh Kumar K.V
Quoted 4 lines · Liu Ping Fan

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.

Quoted 8 lines
Quoted 1 line

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?

I might need a crash course in the use of HPTE_V_ABSENT.

Alex

#3 lore raw
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_NUMA result in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.

Quoted 8 lines
Quoted 4 lines

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.

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

#4 lore raw
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_NUMA result in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.

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 6 lines
Quoted 3 lines

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.

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_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?

Alex

#5 lore raw
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_NUMA result in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.

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 6 lines
Quoted 3 lines

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.

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_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

#6 lore raw
In reply to Alexander Graf
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_NUMA result in a fault when guest access them, we should force the checking when guest uses hypercall to setup hpte.

Quoted 8 lines
Quoted 4 lines

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?

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.

#7 lore raw
In reply to Alexander Graf

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_NUMA result 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

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 7 lines

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

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#8 lore raw
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

#9 lore raw
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

#10 lore raw
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

#11 lore raw
In reply to Alexander Graf
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

#12 lore raw
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

#13 lore raw
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

#14 lore raw
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