Re: Crash while mapping memory in pagetable_init() (Was: Re: .config)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



H. Peter Anvin wrote:
Jeremy Fitzhardinge wrote:
H. Peter Anvin wrote:
Really (pae ? 2M : 1M), in other words, plus the 128K for bootmem. Note that this is creating page tables for, not erasing. To map 2M,
we will only use 2K of additional memory (meaning there is 50% chance
we end up using an additional 4K page.)

So the solution is simply to change INIT_MAP_BEYOND_END in head.S
appropriately.
Like this?  Should we bother adding some slop pages for allocations
which happen before paging_init()?

Yes, although it really should be sensitive to CONFIG_X86_PAE.

/*
  * This is how much memory *in addition to the memory covered up to
- * and including _end* we need mapped initially.  We need one bit for
- * each possible page, but only in low memory, which means
- * 2^32/4096/8 = 128K worst case (4G/4G split.)
+ * and including _end* we need mapped initially.
+ * We need:
+ * - one bit for each possible page, but only in low memory, which means
+ *     2^32/4096/8 = 128K worst case (4G/4G split.)
+ *  - enough space to map all low memory, which means
+ *     (2^32/4096) / 512 + 4 pages (worst case for PAE)
  *
  * Modulo rounding, each megabyte assigned here requires a kilobyte of
  * memory, which is currently unreclaimed.
  *
  * This should be a multiple of a page.
  */
-#define INIT_MAP_BEYOND_END    (128*1024)
+#define INIT_MAP_BEYOND_END    (128*1024 + (2048 + 4)*4096)

I suggest, for clarity and to minimize bloat:

#ifdef CONFIG_X86_PAE
# define PAGE_TABLE_SIZE    ((2048+4)*4096)
#else
# define PAGE_TABLE_SIZE    ((1024+1)*4096)
#endif

#define BOOTMEM_SIZE        (128*1024)

#define INIT_MAP_BEYOND_END    (BOOTMEM_SIZE+PAGE_TABLE_SIZE)


Actually, better yet; there is no reason for these to be macros:

#ifdef CONFIG_X86_PAE
PAGE_TABLE_SIZE = (2048+4)*4096
#else
PAGE_TABLE_SIZE = (1024+1)*4096
#endif
BOOTMEM_SIZE = 128*1024

INIT_MAP_BEYOND_END = BOOTMEM_SIZE + PAGE_TABLE_SIZE

	-hpa

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux