lkml.org 
[lkml]   [2008]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 06 of 11] x86: unify PAE/non-PAE pgd_ctor
    Date
    From
    The constructors for PAE and non-PAE pgd_ctors are more or less
    identical, and can be made into the same function.

    Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
    Cc: William Irwin <wli@holomorphy.com>

    ---
    arch/x86/mm/pgtable_32.c | 43 +++++++++++--------------------------------
    1 file changed, 11 insertions(+), 32 deletions(-)

    diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
    --- a/arch/x86/mm/pgtable_32.c
    +++ b/arch/x86/mm/pgtable_32.c
    @@ -224,50 +224,32 @@ static inline void pgd_list_del(pgd_t *p
    list_del(&page->lru);
    }

    +#define UNSHARED_PTRS_PER_PGD \
    + (SHARED_KERNEL_PMD ? USER_PTRS_PER_PGD : PTRS_PER_PGD)

    -
    -#if (PTRS_PER_PMD == 1)
    -/* Non-PAE pgd constructor */
    static void pgd_ctor(void *pgd)
    {
    unsigned long flags;

    - /* !PAE, no pagetable sharing */
    + /* Clear usermode parts of PGD */
    memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));

    spin_lock_irqsave(&pgd_lock, flags);

    - /* must happen under lock */
    - clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    - swapper_pg_dir + USER_PTRS_PER_PGD,
    - KERNEL_PGD_PTRS);
    - paravirt_alloc_pd_clone(__pa(pgd) >> PAGE_SHIFT,
    - __pa(swapper_pg_dir) >> PAGE_SHIFT,
    - USER_PTRS_PER_PGD,
    - KERNEL_PGD_PTRS);
    - pgd_list_add(pgd);
    - spin_unlock_irqrestore(&pgd_lock, flags);
    -}
    -#else /* PTRS_PER_PMD > 1 */
    -/* PAE pgd constructor */
    -static void pgd_ctor(void *pgd)
    -{
    - /* PAE, kernel PMD may be shared */
    -
    if (SHARED_KERNEL_PMD) {
    + /* must happen under lock */
    clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
    swapper_pg_dir + USER_PTRS_PER_PGD,
    KERNEL_PGD_PTRS);
    - } else {
    - unsigned long flags;
    + paravirt_alloc_pd_clone(__pa(pgd) >> PAGE_SHIFT,
    + __pa(swapper_pg_dir) >> PAGE_SHIFT,
    + USER_PTRS_PER_PGD,
    + KERNEL_PGD_PTRS);
    + } else
    + pgd_list_add(pgd);

    - memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
    - spin_lock_irqsave(&pgd_lock, flags);
    - pgd_list_add(pgd);
    - spin_unlock_irqrestore(&pgd_lock, flags);
    - }
    + spin_unlock_irqrestore(&pgd_lock, flags);
    }
    -#endif /* PTRS_PER_PMD */

    static void pgd_dtor(void *pgd)
    {
    @@ -281,9 +263,6 @@ static void pgd_dtor(void *pgd)
    pgd_list_del(pgd);
    spin_unlock_irqrestore(&pgd_lock, flags);
    }
    -
    -#define UNSHARED_PTRS_PER_PGD \
    - (SHARED_KERNEL_PMD ? USER_PTRS_PER_PGD : PTRS_PER_PGD)

    /* If we allocate a pmd for part of the kernel address space, then
    make sure its initialized with the appropriate kernel mappings.



    \
     
     \ /
      Last update: 2008-01-25 22:51    [W:0.080 / U:0.012 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site