changing __PAGE_OFFSET on x86?
Subsystems (3)
hi,
i posted a query last week about a problem we're having with some PCI devices. we have a P4 system with 512M of RAM and two PCI cards, each having another 256MB of RAM. we want our device driver to expose the entire memory region for the pci cards.
when adding all this up, we're exceeding the 3G/1G split of the linux kernel. as dan maas pointed out, there should be a way to fix this in the kernel... so, after some grepping and code browsing, my new question is:
to fix this, if we change the __PAGE_OFFSET in include/asm-i386/page.h from 0xc0000000 to 0xb000000, are there any hidden dependencies? is there anything else we need to worry about? (does the __PAGE_OFFSET need to lie on a 1G boundary?)
i haven't seen any, but them i'm not willing to say i understand all the implications from chaging such a fundamental #define ....
thanks,
josh
Quoted 3 lines
to fix this, if we change the
__PAGE_OFFSETininclude/asm-i386/page.hfrom0xc0000000to0xb000000, are there any hidden dependencies? is there anything else we need to worry about?
Change arch/i386/vmlinux.lds as well (or the equiv on your machine).
Quoted 1 line
(does the
__PAGE_OFFSETneed to lie on a 1G boundary?)
Only if you're running PAE (64Gb support).
M.
PS. the -aa tree (Andrea's) has a config option to change this.
Quoted 2 lines · Josh Fryman
to fix this, if we change the
__PAGE_OFFSETininclude/asm-i386/page.hfrom0xc0000000to0xb000000, are there any hidden dependencies?
Yes, you need to edit arch/i386/vmlinux.lds as well. Specifically, this line:
. = 0xC0000000 + 0x100000; /* edit the 0xc0000000 */
to make it easier, there is a patch to let you configure a kernel / user-space memory split at compile-time during configure. It is by Andrea - I have attached it. This is a local copy in which I have added some configure help.
Quoted 1 line
(does the
__PAGE_OFFSETneed to lie on a 1G boundary?)
If you are using PAE, yes - otherwise no.
Robert Love
Documentation/Configure.help +43 -0
@@ -399,6 +399,49 @@ Select this if you have a 32-bit processor and more than 4 gigabytes of physical RAM. +# Choice: address_size +User address space size +CONFIG_1GB + This option allows you to set the partitioning of the logical address + space between user and kernel memory. The Linux address space is 4GB + and the default partition is to give 3GB to user and 1GB to + kernel-space. This is abbreviated "3GB/1GB". + + Some specialized workloads require a larger user or kernel memory + space. For example, specialized network processing often benefits + from a larger kernel address space than default. This options lets + you select: + + 3GB user / 1GB kernel (default) + 2GB user / 2GB kernel + 1GB user / 3GB kernel + 3.5GB user / 0.5GB kernel (non-PAE only) + + Note shrinking the user address space may adversely affect certain + applications that assume the user address space is 3GB or otherwise + that certain regions of memory exist. It is recommended that you + are sure of your system's compatibility with a given partition scheme + before you deploy a system with a partition other than 3GB/1GB. + + If uncertain, select "3GB/1GB". Note this does not affect the amount + of physical memory accessible by Linux but only the addressable + per-process memory space. + +2GB +CONFIG_2GB + Parition the addressable memory space into 2GB user and 2GB kernel. + +3GB +CONFIG_3GB + Partion the addressable memory space into 3GB user and 1GB kernel. + This is the default. + +3.5GB +CONFIG_05GB + Partition the addressable memory space into 3.5GB user and 0.5GB + kernel. This is only valid if PAE (CONFIG_HIGHMEM64G) is not + enabled, since segments under PAE must lie on 1GB boundaries. + Normal floppy disk support CONFIG_BLK_DEV_FD If you want to use the floppy disk drive(s) of your PC under Linux,
Rules.make +17 -0
@@ -214,6 +214,7 @@ # # Added the SMP separator to stop module accidents between uniprocessor # and SMP Intel boxes - AC - from bits by Michael Chastain +# Added separator for different PAGE_OFFSET memory models - Ingo. # ifdef CONFIG_SMP
@@ -222,6 +223,22 @@ genksyms_smp_prefix := endif +ifdef CONFIG_2GB +ifdef CONFIG_SMP + genksyms_smp_prefix := -p smp_2gig_ +else + genksyms_smp_prefix := -p 2gig_ +endif +endif + +ifdef CONFIG_3GB +ifdef CONFIG_SMP + genksyms_smp_prefix := -p smp_3gig_ +else + genksyms_smp_prefix := -p 3gig_ +endif +endif + $(MODINCL)/%.ver: %.c @if [ ! -r $(MODINCL)/$*.stamp -o $(MODINCL)/$*.stamp -ot $< ]; then \ echo '$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $<'; \
arch/i386/Makefile +4 -0
@@ -106,6 +106,9 @@ MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot +arch/i386/vmlinux.lds: arch/i386/vmlinux.lds.S FORCE + $(CPP) -C -P -I$(HPATH) -imacros $(HPATH)/asm-i386/page_offset.h -Ui386 arch/i386/vmlinux.lds.S >arch/i386/vmlinux.lds + vmlinux: arch/i386/vmlinux.lds FORCE: ;
@@ -142,6 +145,7 @@ @$(MAKEBOOT) clean archmrproper: + rm -f arch/i386/vmlinux.lds archdep: @$(MAKEBOOT) dep
arch/i386/config.in +13 -2
@@ -174,12 +174,23 @@ "off CONFIG_NOHIGHMEM \ 4GB CONFIG_HIGHMEM4G \ 64GB CONFIG_HIGHMEM64G" off -if [ "$CONFIG_HIGHMEM4G" = "y" ]; then +if [ "$CONFIG_HIGHMEM4G" = "y" -o "$CONFIG_HIGHMEM64G" = "y" ]; then define_bool CONFIG_HIGHMEM y +else + define_bool CONFIG_HIGHMEM n fi if [ "$CONFIG_HIGHMEM64G" = "y" ]; then - define_bool CONFIG_HIGHMEM y define_bool CONFIG_X86_PAE y + choice 'User address space size' \ + "3GB CONFIG_1GB \ + 2GB CONFIG_2GB \ + 1GB CONFIG_3GB" 3GB +else + choice 'User address space size' \ + "3GB CONFIG_1GB \ + 2GB CONFIG_2GB \ + 1GB CONFIG_3GB \ + 3.5GB CONFIG_05GB" 3GB fi bool 'Math emulation' CONFIG_MATH_EMULATION
arch/i386/vmlinux.lds +0 -82
82 lines not on this page · raw message
arch/i386/vmlinux.lds.S +82 -0
82 lines not on this page · raw message
include/asm-i386/page.h +3 -1
@@ -78,7 +78,9 @@* and CONFIG_HIGHMEM64G options in the kernel configuration. */ -#define __PAGE_OFFSET (0xC0000000) +#include <asm/page_offset.h> + +#define __PAGE_OFFSET (PAGE_OFFSET_RAW)/* * This much address space is reserved for vmalloc() and iomap()
include/asm-i386/page_offset.h +10 -0
@@ -0,0 +1,10 @@ +#include <linux/config.h> +#ifdef CONFIG_05GB +#define PAGE_OFFSET_RAW 0xE0000000 +#elif defined(CONFIG_1GB ) +#define PAGE_OFFSET_RAW 0xC0000000 +#elif defined(CONFIG_2GB ) +#define PAGE_OFFSET_RAW 0x80000000 +#elif defined(CONFIG_3GB ) +#define PAGE_OFFSET_RAW 0x40000000 +#endif
include/asm-i386/processor.h +4 -0
@@ -270,7 +270,11 @@/* This decides where the kernel will search for a free chunk of vm * space during mmap's. */ +#ifndef CONFIG_05GB #define TASK_UNMAPPED_BASE (TASK_SIZE / 3) +#else +#define TASK_UNMAPPED_BASE (TASK_SIZE / 16) +#endif /* * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
mm/memory.c +18 -5
@@ -106,8 +106,7 @@static inline void free_one_pgd (pgd_t * dir) { -int j; -pmd_t * pmd; +pmd_t * pmd, * md, * emd;if (pgd_none (*dir))return ;
@@ -118,9 +117,23 @@ } pmd =pmd_offset (dir,0 );pgd_clear (dir); -for (j =0 ; j <PTRS_PER_PMD ; j++) { -prefetchw (pmd+j+(PREFETCH_STRIDE /16 )); -free_one_pmd (pmd+j); + +/* +* Beware if changing the loop below. It once used int j, +* for (j = 0; j < PTRS_PER_PMD; j++) +* free_one_pmd(pmd+j); +* but some older i386 compilers (e.g. egcs-2.91.66, gcc-2.95.3) +* terminated the loop with a _signed_ address comparison +* using "jle", when configured for HIGHMEM64GB (X86_PAE). +* If also configured for 3GB of kernel virtual address space, +* if page at physical 0x3ffff000 virtual 0x7ffff000 is used as +* a pmd, when that mm exits the loop goes on to free "entries" +* found at 0x80000000 onwards. The loop below compiles instead +* to be terminated by unsigned address comparison using "jb". +*/ +for (md = pmd, emd = pmd +PTRS_PER_PMD ; md < emd; md++) { +prefetchw (md+(PREFETCH_STRIDE /16 )); +free_one_pmd (md); }pmd_free (pmd); }
Quoted 11 lines · Josh Fryman
when adding all this up, we're exceeding the 3G/1G split of the linux kernel. as dan maas pointed out, there should be a way to fix this in the kernel... so, after some grepping and code browsing, my new question is:
to fix this, if we change the
__PAGE_OFFSETininclude/asm-i386/page.hfrom0xc0000000to0xb000000, are there any hidden dependencies? is there anything else we need to worry about? (does the__PAGE_OFFSETneed to lie on a 1G boundary?)i haven't seen any, but them i'm not willing to say i understand all the implications from chaging such a fundamental #define ....
At least at one time, the kernel side had to be a power of 2. So you'd have to go to an even split if that's still the case.