On Thu, 20 Mar 2003 16:35:27 +0800 pga...@li... wrote:
> Sorry for monopolising this group.
>
> Mr Stuart Menefy has provided a patch for optimising the tlb miss exception handling.
> I am using the 2.5.13 kernel, downloaded from sourceforge here.
> Changes to the files pgalloc.h and pgtable.h defining pmd_populate_kernel and pmd_page_kernel cause patch rejections.
>
> In short,
> The original pgalloc.h has
>
> #define pmd_populate(mm, pmd, pte) set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
>
> The 2.5.13 version defines pmd_populate_kernel as previously, but change pmd_populate to
>
> set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte)))
>
> The tlb update patch defines pmd_populate to be
>
> set_pmd(pmd, __pmd(pte))
In 2.5, pmd_populate takes a struct page as a parameter, so with my patch
in place it would be something like:
#define pmd_populate(mm, pmd, page) set_pmd(pmd, __pmd(page_address(page)))
meanwhile pmd_populate_kernel still takes a pte_t*, so should be defined
in the same way as pmd_populate used to be in the patch for 2.4.
> similarly, the original pgtable.h has
>
> #define pmd_page(pmd) ( (ul) _va(pmd_val) & PAGE_MASK)
>
> The 2.5.13 changes this to pmd_page_kernel, and redefines pmd_page to be
>
> (phys_to_page(pmd_val(pmd)))
>
> However the tlb update patch redefines pmd_page(pmd) to be ((ul) __va(pmd_val(pmd)))
In 2.5, pmd_page now is used in the generic kernel code, so has to be defined
correctly (returning the corrisponding stuct page*). So with my patch in
place, I would expect it to be defined as something like:
#define pmd_page(pmd) (virt_to_page(pmd_val(pmd)))
however in my patch, I also made use of pmd_page in the new definition of
pmd_bad, so these will need to be changed to pmd_page_kernel in a 2.5 context.
BTW, I've never tried a 2.5 kernel on SH, let alone try my TLB miss
handling patch, so there may well be other changes necessary.
> I wish to know what the TLB patch does to kernel page tables in general and what should happen here. Also would a possibly less efficient implementation that only changes entry.S to do the assembly language equivalent of
There are a couple of changes:
- pmd_t is now simply a pointer to the pte directory, in kernel address
space. Previously it was the physical address of the pte directory,
ORed with _PAGE_TABLE, all cruft which has to be undone in the TLB
miss handler.
- pmd_none is changed to be a specific value: the address of a page
which contains pointers to empty zero page. This allows the miss
handler to always dereference the pmd and pte pointers, without having
to check whether they are valid. If they are not, then the final check
for _PAGE_PRESENT will fail, and the handler calls the C code to fix
up the fault.
So yes this
> pgd_offset(current->mm, address)
> pmd_offset(pdg, address)
> pte_offset(pmd, address)
> update ptel
> ldtlb
> rte
>
> be likely to work?
will work, but it will need to be augmented with checks for pmd_none and
pgd_none, and you need to decide what to do about setting _PAGE_ACCESSED.
Hope this helps
Stuart
|