Is good to use 4MB pages?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

Is good to use 4MB pages?

Post by AlfaOmega08 »

If I've 1GB of memory and if I use 4MB pages, I can only have 256 tasks (1024 / 4), if each task takes a page. With 4KB pages, I can have 262144 tasks (1024*1024 / 4), if each task takes a page. So why should I use 4MB page?
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

Post by edfed »

it is possible to mix 4k, 2m and 4m pages.

4k for little files.
and 4m for big files

2m pages can be used for V86 modules.
welcome in my dream.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Post by Korona »

You could use 4-MB pages when a task needs much memory and 4-KB pages when it does not need much.
You can also use 4-MB pages for the kernel and 4-KB pages for userspace tasks.
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

Post by AlfaOmega08 »

setting and clearing the bit in CR4 when switching from kernel to user mode?
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Post by Korona »

CR4.PSE just activates PSE it does not force you to use it.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

A reason stated in the Intel Manuals (sorry - I haven't got time to search and quote) is that there are different TLB entries for large and small pages.

This means that if you store you kernel in a 4M global page and everything else using 4K pages, there's no reason why you should get a TLB miss for your kernel.

Cheers,
Adam
Post Reply