On Mon, Apr 29, 2013 at 04:47:49PM +0100, Steve Capper wrote: > On Mon, Apr 29, 2013 at 04:26:41PM +0100, Catalin Marinas wrote: > > On Mon, Apr 29, 2013 at 03:55:55PM +0100, Steve Capper wrote: > > > Under x86, multiple puds can be made to reference the same bank of > > > huge pmds provided that they represent a full PUD_SIZE of shared > > > huge memory that is aligned to a PUD_SIZE boundary. > > > > > > The code to share pmds does not require any architecture specific > > > knowledge other than the fact that pmds can be indexed, thus can > > > be beneficial to some other architectures. > > > > > > This patch copies the huge pmd sharing (and unsharing) logic from > > > x86/ to mm/ and introduces a new config option to activate it: > > > CONFIG_ARCH_WANTS_HUGE_PMD_SHARE. > > > > Just wondering whether more of it could be shared. The following look > > pretty close to what you'd write for arm64: > > > > - huge_pte_alloc() > > - huge_pte_offset() (there is a pud_large macro on x86 which checks for > > present & huge, we can replace it with just pud_huge in this function > > as it already checks for present) > > - follow_huge_pud() > > - follow_huge_pmd() > > I did do something like this initially, then reined it back a bit > as it placed implicit restrictions on x86 and arm64. > > If we enable 64K pages on arm64 for instance, we obviate the need > to share pmds (pmd_index doesn't exist for 64K pages). So I have a > slightly different huge_pte_alloc function to account for this. I guess with 64K pages on arm64 (two levels of page tables), you can't share the pmds anyway. pud_none() is defined as 0 in pgtable-nopmd.h. huge_pte_alloc() can probably be the same with 64K pages since pud_alloc always succeeds (pmd/pud/pgd are all the same). So with some #ifdef __PAGETABLE_PMD_FOLDED (not nice but it allows for some more code sharing) you can add empty (NULL-returning) huge_pmd_share/huge_pmd_unshare functions and avoid the compiler error for pmd_index. -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html