2005-09-02 01:59:11

by Chen, Kenneth W

[permalink] [raw]
Subject: RE: [PATCH 1/1] Implement shared page tables

Dave McCracken wrote on Tuesday, August 30, 2005 3:13 PM
> This patch implements page table sharing for all shared memory regions that
> span an entire page table page. It supports sharing at multiple page
> levels, depending on the architecture.
>
>
> This version of the patch supports i386 and x86_64. I have additional
> patches to support ppc64, but they are not quite ready for public
> consumption.
>
> ....
> + prio_tree_iter_init(&iter, &mapping->i_mmap,
> + vma->vm_start, vma->vm_end);


I think this is a bug. The radix priority tree for address_space->
i_mmap is keyed on vma->vm_pgoff. Your patch uses the vma virtual
address to find a shareable range, Which will always fail a match
even though there is one. The following is a quick hack I did to
make it work.

- Ken

--- linux-2.6.13/mm/ptshare.c.orig 2005-09-01 18:58:12.299321918 -0700
+++ linux-2.6.13/mm/ptshare.c 2005-09-01 18:58:39.846196580 -0700
@@ -26,6 +26,11 @@
#include <asm/pgtable.h>
#include <asm/pgalloc.h>

+#define RADIX_INDEX(vma) ((vma)->vm_pgoff)
+#define VMA_SIZE(vma) (((vma)->vm_end - (vma)->vm_start) >> PAGE_SHIFT)
+/* avoid overflow */
+#define HEAP_INDEX(vma) ((vma)->vm_pgoff + (VMA_SIZE(vma) - 1))
+
#undef PT_DEBUG

#ifndef __PAGETABLE_PMD_FOLDED
@@ -173,7 +178,7 @@ pt_share_pte(struct vm_area_struct *vma,
address);
#endif
prio_tree_iter_init(&iter, &mapping->i_mmap,
- vma->vm_start, vma->vm_end);
+ RADIX_INDEX(vma), HEAP_INDEX(vma));

while ((svma = next_shareable_vma(vma, svma, &iter))) {
spgd = pgd_offset(svma->vm_mm, address);



2005-09-02 16:40:32

by Dave McCracken

[permalink] [raw]
Subject: RE: [PATCH 1/1] Implement shared page tables


--On Thursday, September 01, 2005 18:58:23 -0700 "Chen, Kenneth W"
<[email protected]> wrote:

>> + prio_tree_iter_init(&iter, &mapping->i_mmap,
>> + vma->vm_start, vma->vm_end);
>
>
> I think this is a bug. The radix priority tree for address_space->
> i_mmap is keyed on vma->vm_pgoff. Your patch uses the vma virtual
> address to find a shareable range, Which will always fail a match
> even though there is one.
>
> Do you really have to iterate through all the vma? Can't you just break
> out of the while loop on first successful match and populating the pmd?
> I would think you will find them to be the same pte page. Or did I miss
> some thing?

Man, I spaced that whole search code. I was sure I'd tested to make sure
it was finding matches. I'll fix all that up in my next release.

Dave McCracken