Commit c93fdc3e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] remove __pgd_offset

Patch from Dave Hansen <haveblue@us.ibm.com>

__pgd_offset() and pgd_offset() are completely different functions.
__pgd_offset() is really just a helper to figure out which entry in a
pgd an address would fall into.   pgd_offset() does all the leg work and
actually fetches the real pgd entry.

pgd_index() is a much saner name for what __pgd_offset() does.  In fact,
we do this:
#define __pgd_offset(address) pgd_index(address)

The attached patch removes all instances of __pgd_offset and just
replaces them with pgd_index.

Compiles with and without PAE on x86.
parent b5acedc8
...@@ -232,11 +232,11 @@ do_page_fault(unsigned long address, unsigned long mmcsr, ...@@ -232,11 +232,11 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
else { else {
/* Synchronize this task's top level page-table /* Synchronize this task's top level page-table
with the "reference" page table from init. */ with the "reference" page table from init. */
long offset = __pgd_offset(address); long index = pgd_index(address);
pgd_t *pgd, *pgd_k; pgd_t *pgd, *pgd_k;
pgd = current->active_mm->pgd + offset; pgd = current->active_mm->pgd + index;
pgd_k = swapper_pg_dir + offset; pgd_k = swapper_pg_dir + index;
if (!pgd_present(*pgd) && pgd_present(*pgd_k)) { if (!pgd_present(*pgd) && pgd_present(*pgd_k)) {
pgd_val(*pgd) = pgd_val(*pgd_k); pgd_val(*pgd) = pgd_val(*pgd_k);
return; return;
......
...@@ -342,20 +342,20 @@ int do_translation_fault(unsigned long addr, unsigned int fsr, ...@@ -342,20 +342,20 @@ int do_translation_fault(unsigned long addr, unsigned int fsr,
struct pt_regs *regs) struct pt_regs *regs)
{ {
struct task_struct *tsk; struct task_struct *tsk;
unsigned int offset; unsigned int index;
pgd_t *pgd, *pgd_k; pgd_t *pgd, *pgd_k;
pmd_t *pmd, *pmd_k; pmd_t *pmd, *pmd_k;
if (addr < TASK_SIZE) if (addr < TASK_SIZE)
return do_page_fault(addr, fsr, regs); return do_page_fault(addr, fsr, regs);
offset = __pgd_offset(addr); index = pgd_index(addr);
/* /*
* FIXME: CP15 C1 is write only on ARMv3 architectures. * FIXME: CP15 C1 is write only on ARMv3 architectures.
*/ */
pgd = cpu_get_pgd() + offset; pgd = cpu_get_pgd() + index;
pgd_k = init_mm.pgd + offset; pgd_k = init_mm.pgd + index;
if (pgd_none(*pgd_k)) if (pgd_none(*pgd_k))
goto bad_area; goto bad_area;
......
...@@ -394,14 +394,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -394,14 +394,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
* Do _not_ use "tsk" here. We might be inside * Do _not_ use "tsk" here. We might be inside
* an interrupt in the middle of a task switch.. * an interrupt in the middle of a task switch..
*/ */
int offset = __pgd_offset(address); int index = pgd_index(address);
pgd_t *pgd, *pgd_k; pgd_t *pgd, *pgd_k;
pmd_t *pmd, *pmd_k; pmd_t *pmd, *pmd_k;
pte_t *pte_k; pte_t *pte_k;
asm("movl %%cr3,%0":"=r" (pgd)); asm("movl %%cr3,%0":"=r" (pgd));
pgd = offset + (pgd_t *)__va(pgd); pgd = index + (pgd_t *)__va(pgd);
pgd_k = init_mm.pgd + offset; pgd_k = init_mm.pgd + index;
if (!pgd_present(*pgd_k)) if (!pgd_present(*pgd_k))
goto no_context; goto no_context;
......
...@@ -98,15 +98,15 @@ static void __init page_table_range_init (unsigned long start, unsigned long end ...@@ -98,15 +98,15 @@ static void __init page_table_range_init (unsigned long start, unsigned long end
{ {
pgd_t *pgd; pgd_t *pgd;
pmd_t *pmd; pmd_t *pmd;
int pgd_ofs, pmd_ofs; int pgd_idx, pmd_ofs;
unsigned long vaddr; unsigned long vaddr;
vaddr = start; vaddr = start;
pgd_ofs = __pgd_offset(vaddr); pgd_idx = pgd_index(vaddr);
pmd_ofs = __pmd_offset(vaddr); pmd_ofs = __pmd_offset(vaddr);
pgd = pgd_base + pgd_ofs; pgd = pgd_base + pgd_idx;
for ( ; (pgd_ofs < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_ofs++) { for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
if (pgd_none(*pgd)) if (pgd_none(*pgd))
one_md_table_init(pgd); one_md_table_init(pgd);
...@@ -132,13 +132,13 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base) ...@@ -132,13 +132,13 @@ static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
pgd_t *pgd; pgd_t *pgd;
pmd_t *pmd; pmd_t *pmd;
pte_t *pte; pte_t *pte;
int pgd_ofs, pmd_ofs, pte_ofs; int pgd_idx, pmd_ofs, pte_ofs;
pgd_ofs = __pgd_offset(PAGE_OFFSET); pgd_idx = pgd_index(PAGE_OFFSET);
pgd = pgd_base + pgd_ofs; pgd = pgd_base + pgd_idx;
pfn = 0; pfn = 0;
for (; pgd_ofs < PTRS_PER_PGD; pgd++, pgd_ofs++) { for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
pmd = one_md_table_init(pgd); pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn) if (pfn >= max_low_pfn)
continue; continue;
...@@ -214,7 +214,7 @@ void __init permanent_kmaps_init(pgd_t *pgd_base) ...@@ -214,7 +214,7 @@ void __init permanent_kmaps_init(pgd_t *pgd_base)
vaddr = PKMAP_BASE; vaddr = PKMAP_BASE;
page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
pgd = swapper_pg_dir + __pgd_offset(vaddr); pgd = swapper_pg_dir + pgd_index(vaddr);
pmd = pmd_offset(pgd, vaddr); pmd = pmd_offset(pgd, vaddr);
pte = pte_offset_kernel(pmd, vaddr); pte = pte_offset_kernel(pmd, vaddr);
pkmap_page_table = pte; pkmap_page_table = pte;
......
...@@ -64,7 +64,7 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags) ...@@ -64,7 +64,7 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
pmd_t *pmd; pmd_t *pmd;
pte_t *pte; pte_t *pte;
pgd = swapper_pg_dir + __pgd_offset(vaddr); pgd = swapper_pg_dir + pgd_index(vaddr);
if (pgd_none(*pgd)) { if (pgd_none(*pgd)) {
BUG(); BUG();
return; return;
...@@ -104,7 +104,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags) ...@@ -104,7 +104,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
printk ("set_pmd_pfn: pfn misaligned\n"); printk ("set_pmd_pfn: pfn misaligned\n");
return; /* BUG(); */ return; /* BUG(); */
} }
pgd = swapper_pg_dir + __pgd_offset(vaddr); pgd = swapper_pg_dir + pgd_index(vaddr);
if (pgd_none(*pgd)) { if (pgd_none(*pgd)) {
printk ("set_pmd_pfn: pgd_none\n"); printk ("set_pmd_pfn: pgd_none\n");
return; /* BUG(); */ return; /* BUG(); */
......
...@@ -154,7 +154,7 @@ static void __init fixrange_init(unsigned long start, unsigned long end, ...@@ -154,7 +154,7 @@ static void __init fixrange_init(unsigned long start, unsigned long end,
unsigned long vaddr; unsigned long vaddr;
vaddr = start; vaddr = start;
i = __pgd_offset(vaddr); i = pgd_index(vaddr);
j = __pmd_offset(vaddr); j = __pmd_offset(vaddr);
pgd = pgd_base + i; pgd = pgd_base + i;
...@@ -257,7 +257,7 @@ static void init_highmem(void) ...@@ -257,7 +257,7 @@ static void init_highmem(void)
vaddr = PKMAP_BASE; vaddr = PKMAP_BASE;
fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir); fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir);
pgd = swapper_pg_dir + __pgd_offset(vaddr); pgd = swapper_pg_dir + pgd_index(vaddr);
pmd = pmd_offset(pgd, vaddr); pmd = pmd_offset(pgd, vaddr);
pte = pte_offset_kernel(pmd, vaddr); pte = pte_offset_kernel(pmd, vaddr);
pkmap_page_table = pte; pkmap_page_table = pte;
......
...@@ -273,7 +273,6 @@ extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; retu ...@@ -273,7 +273,6 @@ extern inline pte_t pte_mkyoung(pte_t pte) { pte_val(pte) |= __ACCESS_BITS; retu
/* to find an entry in a page-table-directory. */ /* to find an entry in a page-table-directory. */
#define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
#define __pgd_offset(address) pgd_index(address)
#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
/* Find an entry in the second-level page table.. */ /* Find an entry in the second-level page table.. */
......
...@@ -117,7 +117,6 @@ extern struct page *empty_zero_page; ...@@ -117,7 +117,6 @@ extern struct page *empty_zero_page;
/* to find an entry in a page-table-directory */ /* to find an entry in a page-table-directory */
#define pgd_index(addr) ((addr) >> PGDIR_SHIFT) #define pgd_index(addr) ((addr) >> PGDIR_SHIFT)
#define __pgd_offset(addr) pgd_index(addr)
#define pgd_offset(mm, addr) ((mm)->pgd+pgd_index(addr)) #define pgd_offset(mm, addr) ((mm)->pgd+pgd_index(addr))
......
...@@ -236,8 +236,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) ...@@ -236,8 +236,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
/* to find an entry in a page-table-directory. */ /* to find an entry in a page-table-directory. */
#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
#define __pgd_offset(address) pgd_index(address)
#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
/* to find an entry in a kernel page-table-directory */ /* to find an entry in a kernel page-table-directory */
......
...@@ -274,7 +274,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) ...@@ -274,7 +274,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
/* to find an entry in a page-table-directory. */ /* to find an entry in a page-table-directory. */
#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
#define __pgd_offset(address) pgd_index(address)
#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
/* to find an entry in a kernel page-table-directory */ /* to find an entry in a kernel page-table-directory */
......
...@@ -357,7 +357,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) ...@@ -357,7 +357,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
/* to find an entry in a page-table-directory. */ /* to find an entry in a page-table-directory. */
#define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) #define pgd_index(address) ((address >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
#define __pgd_offset(address) pgd_index(address)
/* to find an entry in a page-table-directory */ /* to find an entry in a page-table-directory */
#define pgd_offset(mm, address) \ #define pgd_offset(mm, address) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment