Skip to contentSkip to conversation

Calculate exactly how many ptr is needed for pgd

RFC In review Songmao Tian 2 participants 2 messages Jul 31, 2007 – Aug 2, 2007 1 message not in the archive MIPS

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Calculate exactly how many ptr is needed for pgd

Under 32-bit kernel with 4k page, a page is needed for a pgd, but when page size > 4k, a page will be too much.

include/asm-mips/pgtable-32.h +0 -0
index 2fbd47e..2a16240 100644
@@ -67,7 +67,8 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,

#define PTE_ORDER 0
#endif

-#define PTRS_PER_PGD ((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
+/* Using a page for pgd will be a waste when page size > 4k */
+#define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT))
#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))

#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

It works well. If I start xorg+xfce, it can save 2.5MB memory in my system.

Thanks, songmao.

2007/7/31, Songmao Tian <[email protected]>:

Quoted 20 lines

Under 32-bit kernel with 4k page, a page is needed for a pgd, but when page size > 4k, a page will be too much.

include/asm-mips/pgtable-32.h +2 -1
index 2fbd47e..2a16240 100644
@@ -67,7 +67,8 @@ extern int add_temporary_entry(unsigned long entrylo0,
 unsigned long entrylo1,
 #define PTE_ORDER    0
 #endif
 
-#define PTRS_PER_PGD    ((PAGE_SIZE << PGD_ORDER) / sizeof(pgd_t))
+/* Using a page for pgd will be a waste when page size > 4k */
+#define PTRS_PER_PGD    (1 << (32 - PGDIR_SHIFT))
 #define PTRS_PER_PTE    ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
 

#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)

Signature · 4 lines
为天地立心
为生民立命
为往圣继绝学
为万世开太平