* PAGE_SIZE on 64bit and 32bit machines
@ 2007-11-12 14:39 Yoav Artzi
2007-11-12 15:14 ` Jiri Slaby
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Yoav Artzi @ 2007-11-12 14:39 UTC (permalink / raw)
To: linux-kernel
According to my knowledge the PAGE_SIZE on 32bit architectures in 4KB.
Logically, the PAGE_SIZE on 64bit architectures should be 8KB. That's at
least the way I understand it. However, looking at the kernel code of
x86_64, I see the PAGE_SIZE is 4KB.
Can anyone explain to me what am I missing here?
Thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 14:39 PAGE_SIZE on 64bit and 32bit machines Yoav Artzi
@ 2007-11-12 15:14 ` Jiri Slaby
2007-11-12 15:32 ` Yoav Artzi
2007-11-12 17:13 ` Chris Snook
2007-11-13 12:10 ` Helge Hafting
2 siblings, 1 reply; 10+ messages in thread
From: Jiri Slaby @ 2007-11-12 15:14 UTC (permalink / raw)
To: Yoav Artzi; +Cc: linux-kernel
On 11/12/2007 03:39 PM, Yoav Artzi wrote:
> According to my knowledge the PAGE_SIZE on 32bit architectures in 4KB.
> Logically, the PAGE_SIZE on 64bit architectures should be 8KB. That's at
> least the way I understand it. However, looking at the kernel code of
> x86_64, I see the PAGE_SIZE is 4KB.
Yes, it stood unchanged, the only difference is 4-level page tables.
> Can anyone explain to me what am I missing here?
What led you to that it must be 8k?
regards,
--
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 15:14 ` Jiri Slaby
@ 2007-11-12 15:32 ` Yoav Artzi
2007-11-12 15:39 ` Adrian Bunk
0 siblings, 1 reply; 10+ messages in thread
From: Yoav Artzi @ 2007-11-12 15:32 UTC (permalink / raw)
To: Jiri Slaby; +Cc: linux-kernel
Well, since the size of the kernel stack is one page, I figured it will
grow when switching to 64-bit, because some of the types grow and a
similar flow/stack will be bigger in 64-bit in comparison to 32-bit.
Keeping the page size at 4kb and so keeping the stack at 4kb is a bit
dangerous. Isn't it?
I know that using one page for a kernel stack is a optional feature, but:
a) It's a good feature
b) It's already used by major distros, e.g. Red Hat
-------- Original Message --------
Subject: Re: PAGE_SIZE on 64bit and 32bit machines
From: Jiri Slaby <jirislaby@gmail.com>
To: Yoav Artzi <yoavar@checkpoint.com>
Date: Monday, November 12, 2007 5:14:17 PM
> On 11/12/2007 03:39 PM, Yoav Artzi wrote:
>
>> According to my knowledge the PAGE_SIZE on 32bit architectures in 4KB.
>> Logically, the PAGE_SIZE on 64bit architectures should be 8KB. That's at
>> least the way I understand it. However, looking at the kernel code of
>> x86_64, I see the PAGE_SIZE is 4KB.
>>
>
> Yes, it stood unchanged, the only difference is 4-level page tables.
>
>
>> Can anyone explain to me what am I missing here?
>>
>
> What led you to that it must be 8k?
>
> regards,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 15:32 ` Yoav Artzi
@ 2007-11-12 15:39 ` Adrian Bunk
2007-11-12 15:58 ` Yoav Artzi
0 siblings, 1 reply; 10+ messages in thread
From: Adrian Bunk @ 2007-11-12 15:39 UTC (permalink / raw)
To: Yoav Artzi; +Cc: Jiri Slaby, linux-kernel
On Mon, Nov 12, 2007 at 05:32:36PM +0200, Yoav Artzi wrote:
> Well, since the size of the kernel stack is one page,
>...
That's not true.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 15:39 ` Adrian Bunk
@ 2007-11-12 15:58 ` Yoav Artzi
2007-11-12 16:02 ` Jiri Slaby
2007-11-12 16:11 ` Kyle McMartin
0 siblings, 2 replies; 10+ messages in thread
From: Yoav Artzi @ 2007-11-12 15:58 UTC (permalink / raw)
To: Adrian Bunk; +Cc: Jiri Slaby, linux-kernel
Looking at the source, I see:
#ifdef CONFIG_4KSTACKS
#define THREAD_SIZE (4096)
#else
#define THREAD_SIZE (8192)
#endif
So if I configure the option CONFIG_4KSTACK, I will get a 4KB kernel
stack. Am I missing something here?
-------- Original Message --------
Subject: Re: PAGE_SIZE on 64bit and 32bit machines
From: Adrian Bunk <bunk@kernel.org>
To: Yoav Artzi <yoavar@checkpoint.com>
Date: Monday, November 12, 2007 5:39:08 PM
> On Mon, Nov 12, 2007 at 05:32:36PM +0200, Yoav Artzi wrote:
>
>
>> Well, since the size of the kernel stack is one page,
>> ...
>>
>
> That's not true.
>
> cu
> Adrian
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 15:58 ` Yoav Artzi
@ 2007-11-12 16:02 ` Jiri Slaby
2007-11-12 16:11 ` Kyle McMartin
1 sibling, 0 replies; 10+ messages in thread
From: Jiri Slaby @ 2007-11-12 16:02 UTC (permalink / raw)
To: Yoav Artzi; +Cc: Adrian Bunk, linux-kernel
On 11/12/2007 04:58 PM, Yoav Artzi wrote:
> Looking at the source, I see:
>
> #ifdef CONFIG_4KSTACKS
> #define THREAD_SIZE (4096)
> #else
> #define THREAD_SIZE (8192)
> #endif
>
>
> So if I configure the option CONFIG_4KSTACK, I will get a 4KB kernel
> stack. Am I missing something here?
But it's not configurable on x86_64, where the thread size defaults to 8k.
regards,
--
Jiri Slaby (jirislaby@gmail.com)
Faculty of Informatics, Masaryk University
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 15:58 ` Yoav Artzi
2007-11-12 16:02 ` Jiri Slaby
@ 2007-11-12 16:11 ` Kyle McMartin
2007-11-12 16:22 ` Yoav Artzi
1 sibling, 1 reply; 10+ messages in thread
From: Kyle McMartin @ 2007-11-12 16:11 UTC (permalink / raw)
To: Yoav Artzi; +Cc: Adrian Bunk, Jiri Slaby, linux-kernel
On Mon, Nov 12, 2007 at 05:58:08PM +0200, Yoav Artzi wrote:
> Looking at the source, I see:
>
> #ifdef CONFIG_4KSTACKS
> #define THREAD_SIZE (4096)
> #else
> #define THREAD_SIZE (8192)
> #endif
>
>
> So if I configure the option CONFIG_4KSTACK, I will get a 4KB kernel
> stack. Am I missing something here?
>
This is only on i386 (32-bit x86...)[1] On x86-64, we have 8K kernel
stacks (THREAD_ORDER 1), and 16K irqstacks (IRQSTACK_ORDER 2).
The relevant defines are found in <asm-x86/page_64.h> for x86_64, and
<asm-x86/thread_info_32.h> for i386.
Cheers,
Kyle
1. That is, stack size is only configurable on 32bit.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 16:11 ` Kyle McMartin
@ 2007-11-12 16:22 ` Yoav Artzi
0 siblings, 0 replies; 10+ messages in thread
From: Yoav Artzi @ 2007-11-12 16:22 UTC (permalink / raw)
To: Kyle McMartin; +Cc: Adrian Bunk, Jiri Slaby, linux-kernel
I see. Thanks, guys.
-------- Original Message --------
Subject: Re: PAGE_SIZE on 64bit and 32bit machines
From: Kyle McMartin <kyle@mcmartin.ca>
To: Yoav Artzi <yoavar@checkpoint.com>
Date: Monday, November 12, 2007 6:11:06 PM
> On Mon, Nov 12, 2007 at 05:58:08PM +0200, Yoav Artzi wrote:
>
>> Looking at the source, I see:
>>
>> #ifdef CONFIG_4KSTACKS
>> #define THREAD_SIZE (4096)
>> #else
>> #define THREAD_SIZE (8192)
>> #endif
>>
>>
>> So if I configure the option CONFIG_4KSTACK, I will get a 4KB kernel
>> stack. Am I missing something here?
>>
>>
>
> This is only on i386 (32-bit x86...)[1] On x86-64, we have 8K kernel
> stacks (THREAD_ORDER 1), and 16K irqstacks (IRQSTACK_ORDER 2).
>
> The relevant defines are found in <asm-x86/page_64.h> for x86_64, and
> <asm-x86/thread_info_32.h> for i386.
>
> Cheers,
> Kyle
>
> 1. That is, stack size is only configurable on 32bit.
>
> Scanned by Check Point VPN-1 UTM NGX R65 with Messaging Security
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 14:39 PAGE_SIZE on 64bit and 32bit machines Yoav Artzi
2007-11-12 15:14 ` Jiri Slaby
@ 2007-11-12 17:13 ` Chris Snook
2007-11-13 12:10 ` Helge Hafting
2 siblings, 0 replies; 10+ messages in thread
From: Chris Snook @ 2007-11-12 17:13 UTC (permalink / raw)
To: Yoav Artzi; +Cc: linux-kernel
Yoav Artzi wrote:
> According to my knowledge the PAGE_SIZE on 32bit architectures in 4KB.
> Logically, the PAGE_SIZE on 64bit architectures should be 8KB. That's at
> least the way I understand it. However, looking at the kernel code of
> x86_64, I see the PAGE_SIZE is 4KB.
>
>
> Can anyone explain to me what am I missing here?
PAGE_SIZE is highly architecture-dependent. While it is true that 4K pages are
typical on 32-bit architectures, and 64-bit architectures have historically
introduced 8K pages, this is by no means a requirement. x86_64 uses the same
page sizes that are available on i686+PAE, so you get 4K base pages. alpha and
sparc64 typically use 8K base pages, though they have other options as well.
ia64 defaults to 16K, though it can do 4K, 8K, and a bunch of larger base sizes.
ppc64 does 4K and 64K. s390 uses 4K base pages in both 31-bit and 64-bit
kernels. If x86_64 processors are released with TLBs that can handle 8K pages,
it'll be straightforward to add that feature, but otherwise it would require
faking it in software, which has lots of pitfalls and does nothing to improve
TLB efficiency.
-- Chris
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: PAGE_SIZE on 64bit and 32bit machines
2007-11-12 14:39 PAGE_SIZE on 64bit and 32bit machines Yoav Artzi
2007-11-12 15:14 ` Jiri Slaby
2007-11-12 17:13 ` Chris Snook
@ 2007-11-13 12:10 ` Helge Hafting
2 siblings, 0 replies; 10+ messages in thread
From: Helge Hafting @ 2007-11-13 12:10 UTC (permalink / raw)
To: Yoav Artzi; +Cc: linux-kernel
Yoav Artzi wrote:
> According to my knowledge the PAGE_SIZE on 32bit architectures in 4KB.
> Logically, the PAGE_SIZE on 64bit architectures should be 8KB. That's
> at least the way I understand it. However, looking at the kernel code
> of x86_64, I see the PAGE_SIZE is 4KB.
>
>
> Can anyone explain to me what am I missing here?
Only that there are no connection at all between the page size and
the number of bits the processor uses.
The cpu designer simply makes independent decisions for both cases.
So i386 uses 4kB pages because intel designed their processor that way.
And x86_64 uses 4kB pages because AMD designed the architecture that way.
And some processors use 8kB or 16kB pages because that is how they work.
A few processors offer a selection of page sizes, it is then up to the
architecture maintainer to make a choice between them. No such choice
exists for intel/amd, unless you count the unrealistic option
of using generic 2MB pages.
Having said that, it is possible to get a feel of what a 8kB page system
will be like on intel, by always allocating pages in pairs.
Helge Hafting
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-11-13 12:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-12 14:39 PAGE_SIZE on 64bit and 32bit machines Yoav Artzi
2007-11-12 15:14 ` Jiri Slaby
2007-11-12 15:32 ` Yoav Artzi
2007-11-12 15:39 ` Adrian Bunk
2007-11-12 15:58 ` Yoav Artzi
2007-11-12 16:02 ` Jiri Slaby
2007-11-12 16:11 ` Kyle McMartin
2007-11-12 16:22 ` Yoav Artzi
2007-11-12 17:13 ` Chris Snook
2007-11-13 12:10 ` Helge Hafting
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox