* [PATCH] Simplify pte_offset_{map,map_nested}() on 32 bits [try #2]
@ 2007-05-04 10:57 Franck Bui-Huu
2007-05-11 11:36 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Franck Bui-Huu @ 2007-05-04 10:57 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
From: Franck Bui-Huu <fbuihuu@gmail.com>
Since both kernel and process page tables are never allocated in
highmem these 2 macros were doing unnecessary extra works for getting
a pte from a pmd.
This patch also clean up pte allocation functions by passing
__GFP_ZERO to alloc_pages() and by removing a useless local variable.
With this patch the size of the kernel is slighly reduced.
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
Hi Ralf,
Maybe I'm missing something but it seems that page tables are
never allocated from highmem. Please correct me if I'm wrong.
This patch boot fine on a 32-bits platform without highmem
though.
This patch does not include any modifications for 64-bits
platforms since I can't test them but this assertion
should be more true since there's no highmem on these
platforms. I can make another patch for such platforms if
you think it makes sense.
Please consider,
Franck
include/asm-mips/pgalloc.h | 22 ++++++----------------
include/asm-mips/pgtable-32.h | 13 +++++--------
2 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/include/asm-mips/pgalloc.h b/include/asm-mips/pgalloc.h
index 5685d4f..a3b9953 100644
--- a/include/asm-mips/pgalloc.h
+++ b/include/asm-mips/pgalloc.h
@@ -62,26 +62,16 @@ static inline void pgd_free(pgd_t *pgd)
free_pages((unsigned long)pgd, PGD_ORDER);
}
-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
- unsigned long address)
+static inline pte_t *
+pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
{
- pte_t *pte;
-
- pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
-
- return pte;
+ return (pte_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
}
-static inline struct page *pte_alloc_one(struct mm_struct *mm,
- unsigned long address)
+static inline struct page *
+pte_alloc_one(struct mm_struct *mm, unsigned long address)
{
- struct page *pte;
-
- pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
- if (pte)
- clear_highpage(pte);
-
- return pte;
+ return alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
}
static inline void pte_free_kernel(pte_t *pte)
diff --git a/include/asm-mips/pgtable-32.h b/include/asm-mips/pgtable-32.h
index 2fbd47e..9e0a8c7 100644
--- a/include/asm-mips/pgtable-32.h
+++ b/include/asm-mips/pgtable-32.h
@@ -143,6 +143,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
#define __pgd_offset(address) pgd_index(address)
#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+#define __pte_offset(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
/* to find an entry in a kernel page-table-directory */
#define pgd_offset_k(address) pgd_offset(&init_mm, address)
@@ -153,19 +154,15 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
#define pgd_offset(mm,addr) ((mm)->pgd + pgd_index(addr))
/* Find an entry in the third-level page table.. */
-#define __pte_offset(address) \
- (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
#define pte_offset(dir, address) \
((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
#define pte_offset_kernel(dir, address) \
((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_map(dir, address) \
- ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address) \
- ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-#define pte_unmap_nested(pte) ((void)(pte))
+#define pte_offset_map(dir, address) pte_offset_kernel(dir,address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir,address)
+#define pte_unmap(pte) ((void)(pte))
+#define pte_unmap_nested(pte) ((void)(pte))
#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
--
1.5.1.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Simplify pte_offset_{map,map_nested}() on 32 bits [try #2]
2007-05-04 10:57 [PATCH] Simplify pte_offset_{map,map_nested}() on 32 bits [try #2] Franck Bui-Huu
@ 2007-05-11 11:36 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2007-05-11 11:36 UTC (permalink / raw)
To: Franck Bui-Huu; +Cc: linux-mips
On Fri, May 04, 2007 at 12:57:03PM +0200, Franck Bui-Huu wrote:
> From: Franck Bui-Huu <fbuihuu@gmail.com>
>
> Since both kernel and process page tables are never allocated in
> highmem these 2 macros were doing unnecessary extra works for getting
> a pte from a pmd.
>
> This patch also clean up pte allocation functions by passing
> __GFP_ZERO to alloc_pages() and by removing a useless local variable.
>
> With this patch the size of the kernel is slighly reduced.
These hook allows general mapping of pagetables, not just highmem. On MIPS
that's useful because fancy mapping stuff allows a faster implementation of
TLB exception handlers. That was more or less the official strategy for
the R2000. Then the R4000 came and broke this scheme with virtual aliases
which was hard to fix back then so I had to switch to the current
pagetable and TLB reload mechanism. If you care about the details,
take a look at Linux/MIPS 2.1.1.
The fact that getting this to work again would also allow putting pagetables
into highmem at virtually no extra effort is a nice side effect, of course.
Ralf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-11 11:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-04 10:57 [PATCH] Simplify pte_offset_{map,map_nested}() on 32 bits [try #2] Franck Bui-Huu
2007-05-11 11:36 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox