Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Andi Kleen wrote: so INVLPG makes sense for pagetable fault realated single-address flushes, but they rarely make sense for range flushes. (and that's how Linux uses it) I think it would be an interesting experiment to switch flush_tlb_range() over to INVLPG if the length is below some

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Andi Kleen
On Saturday 26 January 2008 01:11:28 Ingo Molnar wrote: (plus > any add-on TLB miss costs - but those are amortized quite well as long > as the pagetables are well cached - which they usually are on today's > 2MB-ish L2 caches), Did you measure the cost of that amortizing too? My guess is

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote: Now, all of this reminds me of something somewhat messy: if we share the kernel page tables for trampoline page tables, as discussed elsewhere, we HAVE to do a complete, all-tlb-including-global-pages flush after use, since the kernel pages are global and otherwise

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote: Keir Fraser wrote: On 25/1/08 22:54, "Jeremy Fitzhardinge" <[EMAIL PROTECTED]> wrote: The only possibly relevant comment I can find in vol3a is: Older IA-32 processors that implement the PAE mechanism use uncached accesses when loading page-directory-pointer

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Ingo Molnar wrote: * Jeremy Fitzhardinge <[EMAIL PROTECTED]> wrote: Is there any guide about the tradeoff of when to use invlpg vs flushing the whole tlb? 1 page? 10? 90% of the tlb? i made measurements some time ago and INVLPG was quite uniformly slow on all important CPU types - on the

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Keir Fraser wrote: On 25/1/08 22:54, "Jeremy Fitzhardinge" <[EMAIL PROTECTED]> wrote: The only possibly relevant comment I can find in vol3a is: Older IA-32 processors that implement the PAE mechanism use uncached accesses when loading page-directory-pointer table entries. This

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Ingo Molnar
* Jeremy Fitzhardinge <[EMAIL PROTECTED]> wrote: > Is there any guide about the tradeoff of when to use invlpg vs > flushing the whole tlb? 1 page? 10? 90% of the tlb? i made measurements some time ago and INVLPG was quite uniformly slow on all important CPU types - on the order of 100+

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
Keir Fraser wrote: Go read the Intel application note "TLBs, Paging-Structure Caches, and Their Invalidation" at http://www.intel.com/design/processor/applnots/317080.pdf Section 8.1 explains about the PDPTR cache in 32-bit PAE mode, which can only be refreshed by appropriate tickling of CR0,

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Keir Fraser
On 25/1/08 22:54, "Jeremy Fitzhardinge" <[EMAIL PROTECTED]> wrote: > The only possibly relevant comment I can find in vol3a is: > > Older IA-32 processors that implement the PAE mechanism use uncached > accesses when loading page-directory-pointer table entries. This > behavior is >

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote: Jeremy Fitzhardinge wrote: PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we

[PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we want to avoid it where possible. pud_clear() is only

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote: PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we want to avoid it where

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Ingo Molnar
* Jeremy Fitzhardinge [EMAIL PROTECTED] wrote: Is there any guide about the tradeoff of when to use invlpg vs flushing the whole tlb? 1 page? 10? 90% of the tlb? i made measurements some time ago and INVLPG was quite uniformly slow on all important CPU types - on the order of 100+

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Andi Kleen
On Saturday 26 January 2008 01:11:28 Ingo Molnar wrote: (plus any add-on TLB miss costs - but those are amortized quite well as long as the pagetables are well cached - which they usually are on today's 2MB-ish L2 caches), Did you measure the cost of that amortizing too? My guess is that

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
Keir Fraser wrote: Go read the Intel application note TLBs, Paging-Structure Caches, and Their Invalidation at http://www.intel.com/design/processor/applnots/317080.pdf Section 8.1 explains about the PDPTR cache in 32-bit PAE mode, which can only be refreshed by appropriate tickling of CR0, CR3

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Andi Kleen wrote: so INVLPG makes sense for pagetable fault realated single-address flushes, but they rarely make sense for range flushes. (and that's how Linux uses it) I think it would be an interesting experiment to switch flush_tlb_range() over to INVLPG if the length is below some

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Keir Fraser
On 25/1/08 22:54, Jeremy Fitzhardinge [EMAIL PROTECTED] wrote: The only possibly relevant comment I can find in vol3a is: Older IA-32 processors that implement the PAE mechanism use uncached accesses when loading page-directory-pointer table entries. This behavior is model

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Ingo Molnar wrote: * Jeremy Fitzhardinge [EMAIL PROTECTED] wrote: Is there any guide about the tradeoff of when to use invlpg vs flushing the whole tlb? 1 page? 10? 90% of the tlb? i made measurements some time ago and INVLPG was quite uniformly slow on all important CPU types - on the

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
H. Peter Anvin wrote: Jeremy Fitzhardinge wrote: PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote: PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we want to avoid it where

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Keir Fraser wrote: On 25/1/08 22:54, Jeremy Fitzhardinge [EMAIL PROTECTED] wrote: The only possibly relevant comment I can find in vol3a is: Older IA-32 processors that implement the PAE mechanism use uncached accesses when loading page-directory-pointer table entries. This

[PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread Jeremy Fitzhardinge
PAE mode requires that we reload cr3 in order to guarantee that changes to the pgd will be noticed by the processor. This means that in principle pud_clear needs to reload cr3 every time. However, because reloading cr3 implies a tlb flush, we want to avoid it where possible. pud_clear() is only

Re: [PATCH 11 of 11] x86: defer cr3 reload when doing pud_clear()

2008-01-25 Thread H. Peter Anvin
Jeremy Fitzhardinge wrote: Now, all of this reminds me of something somewhat messy: if we share the kernel page tables for trampoline page tables, as discussed elsewhere, we HAVE to do a complete, all-tlb-including-global-pages flush after use, since the kernel pages are global and otherwise