* why does the macro "ZERO_PAGE" take an argument?
@ 2007-06-07 11:17 Robert P. J. Day
2007-06-07 11:29 ` Nick Piggin
0 siblings, 1 reply; 13+ messages in thread
From: Robert P. J. Day @ 2007-06-07 11:17 UTC (permalink / raw)
To: Linux Kernel Mailing List
probably making a fool of myself here, but what is the purpose of
that single argument to the macro "ZERO_PAGE"?
$ grep -r "define ZERO_PAGE" include
include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) ({ BUG(); NULL; })
include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
include/asm-v850/pgtable.h:#define ZERO_PAGE(vaddr) ((void *)0x87654321)
include/asm-mips/pgtable.h:#define ZERO_PAGE(vaddr) \
include/asm-blackfin/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(0))
include/asm-parisc/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
include/asm-alpha/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(ZERO_PGE))
...
AFAICT, there are no definitions of that macro that actually use
that argument. is that some kind of historical cruft?
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:17 why does the macro "ZERO_PAGE" take an argument? Robert P. J. Day @ 2007-06-07 11:29 ` Nick Piggin 2007-06-07 11:34 ` Robert P. J. Day 0 siblings, 1 reply; 13+ messages in thread From: Nick Piggin @ 2007-06-07 11:29 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Linux Kernel Mailing List Robert P. J. Day wrote: > probably making a fool of myself here, but what is the purpose of > that single argument to the macro "ZERO_PAGE"? > > $ grep -r "define ZERO_PAGE" include > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) ({ BUG(); NULL; }) > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page) > include/asm-v850/pgtable.h:#define ZERO_PAGE(vaddr) ((void *)0x87654321) > include/asm-mips/pgtable.h:#define ZERO_PAGE(vaddr) \ > include/asm-blackfin/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(0)) > include/asm-parisc/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) > include/asm-alpha/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(ZERO_PGE)) > ... > > AFAICT, there are no definitions of that macro that actually use > that argument. is that some kind of historical cruft? MIPS? -- SUSE Labs, Novell Inc. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:29 ` Nick Piggin @ 2007-06-07 11:34 ` Robert P. J. Day 2007-06-07 11:39 ` Satyam Sharma 0 siblings, 1 reply; 13+ messages in thread From: Robert P. J. Day @ 2007-06-07 11:34 UTC (permalink / raw) To: Nick Piggin; +Cc: Linux Kernel Mailing List On Thu, 7 Jun 2007, Nick Piggin wrote: > Robert P. J. Day wrote: > > probably making a fool of myself here, but what is the purpose of > > that single argument to the macro "ZERO_PAGE"? > > > > $ grep -r "define ZERO_PAGE" include > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) ({ BUG(); NULL; }) > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) > > virt_to_page(empty_zero_page) > > include/asm-v850/pgtable.h:#define ZERO_PAGE(vaddr) ((void *)0x87654321) > > include/asm-mips/pgtable.h:#define ZERO_PAGE(vaddr) \ > > include/asm-blackfin/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(0)) > > include/asm-parisc/pgtable.h:#define ZERO_PAGE(vaddr) > > (virt_to_page(empty_zero_page)) > > include/asm-alpha/pgtable.h:#define ZERO_PAGE(vaddr) > > (virt_to_page(ZERO_PGE)) > > ... > > > > AFAICT, there are no definitions of that macro that actually use > > that argument. is that some kind of historical cruft? > > MIPS? argh. that would be the *one* definition whose output got chopped because of line continuation, and it would be only one that actually uses the argument: #define ZERO_PAGE(vaddr) \ (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) but it still leaves the question -- if ZERO_PAGE is meant to represent a single, global shared page that is always zero, why would it *ever* need to take an argument? and what's so special about MIPS that it differs from all the rest? rday -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ======================================================================== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:34 ` Robert P. J. Day @ 2007-06-07 11:39 ` Satyam Sharma 2007-06-07 11:53 ` Robert P. J. Day 0 siblings, 1 reply; 13+ messages in thread From: Satyam Sharma @ 2007-06-07 11:39 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Nick Piggin, Linux Kernel Mailing List On 6/7/07, Robert P. J. Day <rpjday@mindspring.com> wrote: > On Thu, 7 Jun 2007, Nick Piggin wrote: > > > Robert P. J. Day wrote: > > > probably making a fool of myself here, but what is the purpose of > > > that single argument to the macro "ZERO_PAGE"? > > > > > > $ grep -r "define ZERO_PAGE" include > > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) ({ BUG(); NULL; }) > > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) > > > virt_to_page(empty_zero_page) > > > include/asm-v850/pgtable.h:#define ZERO_PAGE(vaddr) ((void *)0x87654321) > > > include/asm-mips/pgtable.h:#define ZERO_PAGE(vaddr) \ > > > include/asm-blackfin/pgtable.h:#define ZERO_PAGE(vaddr) (virt_to_page(0)) > > > include/asm-parisc/pgtable.h:#define ZERO_PAGE(vaddr) > > > (virt_to_page(empty_zero_page)) > > > include/asm-alpha/pgtable.h:#define ZERO_PAGE(vaddr) > > > (virt_to_page(ZERO_PGE)) > > > ... > > > > > > AFAICT, there are no definitions of that macro that actually use > > > that argument. is that some kind of historical cruft? > > > > MIPS? > > argh. that would be the *one* definition whose output got chopped > because of line continuation, and it would be only one that actually > uses the argument: > > #define ZERO_PAGE(vaddr) \ > (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask)))) > > > but it still leaves the question -- if ZERO_PAGE is meant to represent > a single, global shared page that is always zero, why would it *ever* > need to take an argument? and what's so special about MIPS that it > differs from all the rest? The comment above empty_zero_page and zero_page_mask declarations at arch/mips/mm/init.c:508 sheds light on this ... ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:39 ` Satyam Sharma @ 2007-06-07 11:53 ` Robert P. J. Day 2007-06-07 16:37 ` Ralf Baechle 2007-06-07 17:32 ` H. Peter Anvin 0 siblings, 2 replies; 13+ messages in thread From: Robert P. J. Day @ 2007-06-07 11:53 UTC (permalink / raw) To: Satyam Sharma; +Cc: Nick Piggin, Linux Kernel Mailing List, Ralf Baechle On Thu, 7 Jun 2007, Satyam Sharma wrote: > On 6/7/07, Robert P. J. Day <rpjday@mindspring.com> wrote: > > On Thu, 7 Jun 2007, Nick Piggin wrote: > > > > > Robert P. J. Day wrote: > > > > probably making a fool of myself here, but what is the purpose of > > > > that single argument to the macro "ZERO_PAGE"? > > > > > > > > $ grep -r "define ZERO_PAGE" include > > > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) ({ BUG(); NULL; > > }) > > > > include/asm-frv/pgtable.h:#define ZERO_PAGE(vaddr) > > > > virt_to_page(empty_zero_page) > > > > include/asm-v850/pgtable.h:#define ZERO_PAGE(vaddr) ((void > > *)0x87654321) > > > > include/asm-mips/pgtable.h:#define ZERO_PAGE(vaddr) \ > > > > include/asm-blackfin/pgtable.h:#define ZERO_PAGE(vaddr) > > (virt_to_page(0)) > > > > include/asm-parisc/pgtable.h:#define ZERO_PAGE(vaddr) > > > > (virt_to_page(empty_zero_page)) > > > > include/asm-alpha/pgtable.h:#define ZERO_PAGE(vaddr) > > > > (virt_to_page(ZERO_PGE)) > > > > ... > > > > > > > > AFAICT, there are no definitions of that macro that actually use > > > > that argument. is that some kind of historical cruft? > > > > > > MIPS? > > > > argh. that would be the *one* definition whose output got chopped > > because of line continuation, and it would be only one that actually > > uses the argument: > > > > #define ZERO_PAGE(vaddr) \ > > (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & > > zero_page_mask)))) > > > > > > but it still leaves the question -- if ZERO_PAGE is meant to represent > > a single, global shared page that is always zero, why would it *ever* > > need to take an argument? and what's so special about MIPS that it > > differs from all the rest? > > The comment above empty_zero_page and zero_page_mask > declarations at arch/mips/mm/init.c:508 sheds light on this ... well, it *sort of* does. at line 64 of that file: /* * We have up to 8 empty zeroed pages so we can map one of the right colour * when needed. This is necessary only on R4000 / R4400 SC and MC versions * where we have to avoid VCED / VECI exceptions for good performance at * any price. Since page is never written to after the initialization we * don't have to care about aliases on other CPUs. */ although it's not clear where in the source tree are the invocations that would actually make a difference to a MIPS system, which is why i've CC'ed ralf on this. i'm sure he can clear this up. :-) rday -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ======================================================================== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:53 ` Robert P. J. Day @ 2007-06-07 16:37 ` Ralf Baechle 2007-06-07 18:04 ` H. Peter Anvin 2007-06-07 17:32 ` H. Peter Anvin 1 sibling, 1 reply; 13+ messages in thread From: Ralf Baechle @ 2007-06-07 16:37 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Satyam Sharma, Nick Piggin, Linux Kernel Mailing List On Thu, Jun 07, 2007 at 07:53:08AM -0400, Robert P. J. Day wrote: > > > > MIPS? > > > > > > argh. that would be the *one* definition whose output got chopped > > > because of line continuation, and it would be only one that actually > > > uses the argument: > > > > > > #define ZERO_PAGE(vaddr) \ > > > (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & > > > zero_page_mask)))) > > > > > > > > > but it still leaves the question -- if ZERO_PAGE is meant to represent > > > a single, global shared page that is always zero, why would it *ever* > > > need to take an argument? and what's so special about MIPS that it > > > differs from all the rest? > > > > The comment above empty_zero_page and zero_page_mask > > declarations at arch/mips/mm/init.c:508 sheds light on this ... > > well, it *sort of* does. at line 64 of that file: > > /* > * We have up to 8 empty zeroed pages so we can map one of the right colour > * when needed. This is necessary only on R4000 / R4400 SC and MC versions > * where we have to avoid VCED / VECI exceptions for good performance at > * any price. Since page is never written to after the initialization we > * don't have to care about aliases on other CPUs. > */ > > although it's not clear where in the source tree are the invocations > that would actually make a difference to a MIPS system, which is why > i've CC'ed ralf on this. i'm sure he can clear this up. :-) Cache aliases. When the same page of physical memory is mapped twice to user space, let's say at address addr and addr + PAGE_SIZE this is normally harmless although wasteful on processors with virtually indexed caches as long as the page is mapped read-only such as in case of ZERO_PAGE. If the same thing happens with a writable page there is the chance of severe data corruption. Some members of the R4000 family are now trying to be helpful by throwing the kernel a "virtual coherency" exception. The bad news about this exception is there might be thousands (the theoretical worst case would be millions) of it in a single second, so servicing can be very expensive. For the ZERO page this can be avoided by using several pages mapped in a way such that their addresses don't conflict. Ralf ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 16:37 ` Ralf Baechle @ 2007-06-07 18:04 ` H. Peter Anvin 0 siblings, 0 replies; 13+ messages in thread From: H. Peter Anvin @ 2007-06-07 18:04 UTC (permalink / raw) To: Ralf Baechle Cc: Robert P. J. Day, Satyam Sharma, Nick Piggin, Linux Kernel Mailing List Ralf Baechle wrote: > Cache aliases. When the same page of physical memory is mapped twice to > user space, let's say at address addr and addr + PAGE_SIZE this is normally > harmless although wasteful on processors with virtually indexed caches as > long as the page is mapped read-only such as in case of ZERO_PAGE. > > If the same thing happens with a writable page there is the chance of > severe data corruption. Some members of the R4000 family are now trying > to be helpful by throwing the kernel a "virtual coherency" exception. The > bad news about this exception is there might be thousands (the theoretical > worst case would be millions) of it in a single second, so servicing can be > very expensive. For the ZERO page this can be avoided by using several > pages mapped in a way such that their addresses don't conflict. Note that it can be a *very expensive* waste even on machines that do this in hardware. Colouring the zeropage can have sizable performance advantages for virtually no cost. -hpa ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 11:53 ` Robert P. J. Day 2007-06-07 16:37 ` Ralf Baechle @ 2007-06-07 17:32 ` H. Peter Anvin 2007-06-07 19:29 ` William Lee Irwin III 1 sibling, 1 reply; 13+ messages in thread From: H. Peter Anvin @ 2007-06-07 17:32 UTC (permalink / raw) To: Robert P. J. Day Cc: Satyam Sharma, Nick Piggin, Linux Kernel Mailing List, Ralf Baechle Robert P. J. Day wrote: >> The comment above empty_zero_page and zero_page_mask >> declarations at arch/mips/mm/init.c:508 sheds light on this ... > > well, it *sort of* does. at line 64 of that file: > > /* > * We have up to 8 empty zeroed pages so we can map one of the right colour > * when needed. This is necessary only on R4000 / R4400 SC and MC versions > * where we have to avoid VCED / VECI exceptions for good performance at > * any price. Since page is never written to after the initialization we > * don't have to care about aliases on other CPUs. > */ > > although it's not clear where in the source tree are the invocations > that would actually make a difference to a MIPS system, which is why > i've CC'ed ralf on this. i'm sure he can clear this up. :-) x86 could also benefit from coloured zeropages. In fact, I thought it already had them (K8 wants as many as 8.) -hpa ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 17:32 ` H. Peter Anvin @ 2007-06-07 19:29 ` William Lee Irwin III 2007-06-07 21:16 ` H. Peter Anvin 0 siblings, 1 reply; 13+ messages in thread From: William Lee Irwin III @ 2007-06-07 19:29 UTC (permalink / raw) To: H. Peter Anvin Cc: Robert P. J. Day, Satyam Sharma, Nick Piggin, Linux Kernel Mailing List, Ralf Baechle Robert P. J. Day wrote: >> although it's not clear where in the source tree are the invocations >> that would actually make a difference to a MIPS system, which is why >> i've CC'ed ralf on this. i'm sure he can clear this up. :-) On Thu, Jun 07, 2007 at 10:32:29AM -0700, H. Peter Anvin wrote: > x86 could also benefit from coloured zeropages. In fact, I thought it > already had them (K8 wants as many as 8.) How would one demonstrate the beneficial effect of such? -- wli ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 19:29 ` William Lee Irwin III @ 2007-06-07 21:16 ` H. Peter Anvin 2007-06-08 7:25 ` Robert P. J. Day 2007-06-12 2:18 ` Nick Piggin 0 siblings, 2 replies; 13+ messages in thread From: H. Peter Anvin @ 2007-06-07 21:16 UTC (permalink / raw) To: William Lee Irwin III Cc: Robert P. J. Day, Satyam Sharma, Nick Piggin, Linux Kernel Mailing List, Ralf Baechle William Lee Irwin III wrote: > Robert P. J. Day wrote: >>> although it's not clear where in the source tree are the invocations >>> that would actually make a difference to a MIPS system, which is why >>> i've CC'ed ralf on this. i'm sure he can clear this up. :-) > > On Thu, Jun 07, 2007 at 10:32:29AM -0700, H. Peter Anvin wrote: >> x86 could also benefit from coloured zeropages. In fact, I thought it >> already had them (K8 wants as many as 8.) > > How would one demonstrate the beneficial effect of such? Dean Gaudet at Transmeta did some benchmarking using SPEC. If I recall his numbers correctly (this is from memory, mind you) on Transmeta Efficeon, which has 2-way virtual cache tagging with hardware recovery, zeropage coloring was a 1.5% performance improvement. -hpa ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 21:16 ` H. Peter Anvin @ 2007-06-08 7:25 ` Robert P. J. Day 2007-06-09 0:49 ` H. Peter Anvin 2007-06-12 2:18 ` Nick Piggin 1 sibling, 1 reply; 13+ messages in thread From: Robert P. J. Day @ 2007-06-08 7:25 UTC (permalink / raw) To: H. Peter Anvin Cc: William Lee Irwin III, Satyam Sharma, Nick Piggin, Linux Kernel Mailing List, Ralf Baechle On Thu, 7 Jun 2007, H. Peter Anvin wrote: > William Lee Irwin III wrote: > > Robert P. J. Day wrote: > >>> although it's not clear where in the source tree are the invocations > >>> that would actually make a difference to a MIPS system, which is why > >>> i've CC'ed ralf on this. i'm sure he can clear this up. :-) > > > > On Thu, Jun 07, 2007 at 10:32:29AM -0700, H. Peter Anvin wrote: > >> x86 could also benefit from coloured zeropages. In fact, I thought it > >> already had them (K8 wants as many as 8.) > > > > How would one demonstrate the beneficial effect of such? > > Dean Gaudet at Transmeta did some benchmarking using SPEC. If I > recall his numbers correctly (this is from memory, mind you) on > Transmeta Efficeon, which has 2-way virtual cache tagging with > hardware recovery, zeropage coloring was a 1.5% performance > improvement. and once again, an initially innocuous question quickly leaves me behind. no, no, i'm getting used to it. :-P rday -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ======================================================================== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-08 7:25 ` Robert P. J. Day @ 2007-06-09 0:49 ` H. Peter Anvin 0 siblings, 0 replies; 13+ messages in thread From: H. Peter Anvin @ 2007-06-09 0:49 UTC (permalink / raw) To: Robert P. J. Day Cc: William Lee Irwin III, Satyam Sharma, Nick Piggin, Linux Kernel Mailing List, Ralf Baechle Robert P. J. Day wrote: > > and once again, an initially innocuous question quickly leaves me > behind. no, no, i'm getting used to it. :-P > This is what happens when you stir the muck on the bottom. This is probably a good thing. -hpa ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: why does the macro "ZERO_PAGE" take an argument? 2007-06-07 21:16 ` H. Peter Anvin 2007-06-08 7:25 ` Robert P. J. Day @ 2007-06-12 2:18 ` Nick Piggin 1 sibling, 0 replies; 13+ messages in thread From: Nick Piggin @ 2007-06-12 2:18 UTC (permalink / raw) To: H. Peter Anvin Cc: William Lee Irwin III, Robert P. J. Day, Satyam Sharma, Linux Kernel Mailing List, Ralf Baechle H. Peter Anvin wrote: > William Lee Irwin III wrote: > >>Robert P. J. Day wrote: >> >>>>although it's not clear where in the source tree are the invocations >>>>that would actually make a difference to a MIPS system, which is why >>>>i've CC'ed ralf on this. i'm sure he can clear this up. :-) >> >>On Thu, Jun 07, 2007 at 10:32:29AM -0700, H. Peter Anvin wrote: >> >>>x86 could also benefit from coloured zeropages. In fact, I thought it >>>already had them (K8 wants as many as 8.) >> >>How would one demonstrate the beneficial effect of such? > > > Dean Gaudet at Transmeta did some benchmarking using SPEC. If I recall > his numbers correctly (this is from memory, mind you) on Transmeta > Efficeon, which has 2-way virtual cache tagging with hardware recovery, > zeropage coloring was a 1.5% performance improvement. I'm surprised that the benchmark made such use of zero pages so as to be worthwhile. I'm sitting on a patch which removes the zero page from the page fault fastpath completely which I'd like to try out in -mm... -- SUSE Labs, Novell Inc. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-06-12 2:18 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-06-07 11:17 why does the macro "ZERO_PAGE" take an argument? Robert P. J. Day 2007-06-07 11:29 ` Nick Piggin 2007-06-07 11:34 ` Robert P. J. Day 2007-06-07 11:39 ` Satyam Sharma 2007-06-07 11:53 ` Robert P. J. Day 2007-06-07 16:37 ` Ralf Baechle 2007-06-07 18:04 ` H. Peter Anvin 2007-06-07 17:32 ` H. Peter Anvin 2007-06-07 19:29 ` William Lee Irwin III 2007-06-07 21:16 ` H. Peter Anvin 2007-06-08 7:25 ` Robert P. J. Day 2007-06-09 0:49 ` H. Peter Anvin 2007-06-12 2:18 ` Nick Piggin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox