large page patch
Subsystems (6)
This is a large-page support patch from Rohit Seth, forwarded with his permission (thanks!).
Quoted 43 lines
Attached is the
large_pagesupport for IA-32. For most part there are no changes over IA-64 patch. System calls and their semantics remain the same. Though there are still some little parts of code that are arch specfic (like for IA-64 there is seperate region forlarge_pageswhereas on IA-32 it is the same linear address space etc.) I will appreciate if you all could provide your input and any issues that you think we need to resolve.Attached is the
large_pagepatch including the following support: 1- Private and Shared Anonymous largepages(This is the earlier patch + Anonymous share Large_page support). Private Anonymouslarge_pagesstay with the particular process and vm segments corresponding to these getVM_DONTCOPYattribute. Shared Anonymous pages get shared by children. (Children share the same physicallarge_pageswith parent.) Allocation and deallocation of this is done using the following two system calls:
sys_get_large_pages(unsigned long addr, unsigned long len, int prot, int flags)
where prot could bePROT_READ,PROT_WRITE,PROT_EXECand flags isMAP_PRIVATEorMAP_SHARE
sys_free_large_pages(unsigned long addr)2- Shared Large Pages across different processes. Allocation and deallocation of
large_pagesthat a process can share and unshare across different procecess is using follwoign two systm calls:
sys_share_large_pages(int key, unsigned long addr, unsigned long len, int prot, int flag)where key is the system wide unique identifier that processes use to share pages. This should be non-zero positive number. prot is identical as in above cases. flag could be set to
IPC_CREATso that if the segment corresponding to key is not already there then it is created (Else-ENOENTis returned if there is no existing segment).
sys_unshare_large_pages(unsigned long addr)is used to unshare the
large_pagesfrom process's address space. Thelarge_pagesare put onlpage_freelistonly when the last user has sent the request for unsharing it (kind ofSHM_DESTattribute).Most of the support needed for above two cases (Anonymous and Sharing across processes) is quite similar in kernel except for binding of
large_pagesto key and temporary inode structure.
Quoted 7 lines
3) Currently the
large_pagememory is dynamically configurable through/proc/sys/kernel/numlargepagesUser can specify the number (negative meaning shrink) that the number oflarge_pagepages need to change. For e.g. a value of -2 will reduce the number oflarge_pagepages currently configured in system by 2. Note that this change will depend on the availability of freelarge_pages. If none is available then the value remains same. (Any cleaner suggestions?)
Some observations which have been made thus far:
- Minimal impact on the VM and MM layers
- Delegates most of it to the arch layer
- Generic code is not tied to pagetables so (for example) PPC could implement the system calls with BAT registers
- The change to MAX_ORDER is unneeded
- swapping of large pages and making them pagecache-coherent is unpopular.
- may be better to implement the shm API with fd's, not keys.
- an ia64 implementation is available
arch/i386/config.in +2 -1
@@ -184,6 +184,8 @@ bool 'Math emulation' CONFIG_MATH_EMULATION bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR +bool 'IA-32 Large Page Support (if available on processor)' CONFIG_LARGE_PAGE + bool 'Symmetric multi-processing support' CONFIG_SMP if [ "$CONFIG_SMP" != "y" ]; then bool 'Local APIC support on uniprocessors' CONFIG_X86_UP_APIC
@@ -205,7 +207,6 @@ mainmenu_option next_comment comment 'General setup' - bool 'Networking support' CONFIG_NET # Visual Workstation support is utterly broken.
arch/i386/kernel/entry.S +4 -0
@@ -634,6 +634,10 @@ .long SYMBOL_NAME(sys_ni_syscall) /* 235 reserved for removexattr */ .long SYMBOL_NAME(sys_ni_syscall) /* reserved for lremovexattr */ .long SYMBOL_NAME(sys_ni_syscall) /* reserved for fremovexattr */ + .long SYMBOL_NAME(sys_get_large_pages) /* Get large_page pages */ + .long SYMBOL_NAME(sys_free_large_pages) /* Free large_page pages */ + .long SYMBOL_NAME(sys_share_large_pages)/* Share large_page pages */ + .long SYMBOL_NAME(sys_unshare_large_pages)/* UnShare large_page pages */ .rept NR_syscalls-(.-sys_call_table)/4 .long SYMBOL_NAME(sys_ni_syscall)
arch/i386/kernel/sys_i386.c +123 -0
126 lines not on this page · raw message
arch/i386/mm/Makefile +1 -0
@@ -10,5 +10,6 @@ O_TARGET := mm.o obj-y := init.o fault.o ioremap.o extable.o +obj-$(CONFIG_LARGE_PAGE) += lpage.o include $(TOPDIR)/Rules.make
arch/i386/mm/init.c +32 -0
@@ -447,6 +447,12 @@return 0 ; } +#ifdef CONFIG_LARGE_PAGE +long lpagemem =0 ; +int lp_max; +long lpzone_pages; +extern struct list_head lpage_freelist; +#endif void __init mem_init (void ) {extern int ppro_with_ram_bug (void );
@@ -532,6 +538,32 @@zap_low_mappings ();#endif +#ifdef CONFIG_LARGE_PAGE + { +long i; +long j; +struct page *page, *map; + +/*For now reserve quarter for large_pages.*/ + lpzone_pages = (max_low_pfn >> ((LPAGE_SHIFT -PAGE_SHIFT ) +2 )) ; +/*Will make this kernel command line. */ +INIT_LIST_HEAD (&lpage_freelist); +for (i=0 ; i<lpzone_pages; i++) { + page =alloc_pages (GFP_ATOMIC ,LARGE_PAGE_ORDER ); +if (page ==NULL ) +break ; + map = page; +for (j=0 ; j<(LPAGE_SIZE /PAGE_SIZE ); j++) { +SetPageReserved (map); + map++; + } +list_add (&page->list, &lpage_freelist); + } +printk ("Total Large_page memory pages allocated %ld\n" , i); + lpzone_pages = lpagemem = i; + lp_max = i; + } +#endif }/* Put this after the callers, so that it cannot be inlined */
arch/i386/mm/lpage.c +475 -0
475 lines not on this page · raw message
fs/proc/array.c +11 -0
@@ -486,6 +486,17 @@pgd_t *pgd =pgd_offset (mm, vma->vm_start);int pages =0 , shared =0 , dirty =0 , total =0 ; +if (is_vm_large_page (vma)) { +int num_pages = ((vma->vm_end - vma->vm_start)/PAGE_SIZE ); + resident += num_pages; +if ((vma->vm_flags &VM_DONTCOPY )) + share += num_pages; +if (vma->vm_flags &VM_WRITE ) + dt += num_pages; + drs += num_pages; + vma = vma->vm_next; +continue ; + }statm_pgd_range (pgd, vma->vm_start, vma->vm_end, &pages, &shared, &dirty, &total); resident += pages; share += shared;
fs/proc/proc_misc.c +8 -0
@@ -151,6 +151,14 @@B (i.sharedram),B (i.bufferram),B (pg_size),B (i.totalswap), B(i.totalswap-i.freeswap), B(i.freeswap)); +#ifdef CONFIG_LARGE_PAGE + { +extern unsigned long lpagemem, lpzone_pages; + len +=sprintf (page+len,"Total # of LargePages: %8lu\t\tAvailable: %8lu\n" +"LargePageSize: %8lu(0x%xKB)\n" , + lpzone_pages, lpagemem,LPAGE_SIZE , (LPAGE_SIZE /1024 )); + } +#endif /* * Tagged format, for easy grepping and expansion. * The above will go away eventually, once the tools
include/asm-i386/page.h +8 -0
@@ -41,14 +41,22 @@typedef struct {unsigned long long pmd; }pmd_t ;typedef struct {unsigned long long pgd; }pgd_t ;#define pte_val (x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) +#define LPAGE_SHIFT 21#else typedef struct {unsigned long pte_low; }pte_t ;typedef struct {unsigned long pmd; }pmd_t ;typedef struct {unsigned long pgd; }pgd_t ;#define pte_val (x) ((x).pte_low) +#define LPAGE_SHIFT 22#endif #define PTE_MASK PAGE_MASK +#ifdef CONFIG_LARGE_PAGE +#define LPAGE_SIZE ((1UL) << LPAGE_SHIFT) +#define LPAGE_MASK (~(LPAGE_SIZE - 1)) +#define LARGE_PAGE_ORDER (LPAGE_SHIFT - PAGE_SHIFT) +#endif +typedef struct {unsigned long pgprot; }pgprot_t ;#define pmd_val (x) ((x).pmd)
include/linux/mm.h +11 -0
@@ -103,6 +103,7 @@#define VM_DONTEXPAND 0x00040000/* Cannot expand with mremap() */ #define VM_RESERVED 0x00080000/* Don't unmap it from swap_out */ +#define VM_LARGEPAGE 0x00400000/* Large_Page mapping. */ #define VM_STACK_FLAGS 0x00000177#define VM_READHINTMASK (VM_SEQ_READ | VM_RAND_READ)
@@ -425,6 +426,16 @@int get_user_pages (struct task_struct *tsk,struct mm_struct *mm,unsigned long start,int len,int write,int force,struct page **pages,struct vm_area_struct **vmas); +#ifdef CONFIG_LARGE_PAGE +#define is_vm_large_page (vma) (vma->vm_flags & VM_LARGEPAGE) +extern int copy_large_page (struct mm_struct *,struct mm_struct *,struct vm_area_struct *); +extern int follow_large_page (struct mm_struct *,struct vm_area_struct *,struct page **,struct vm_area_struct **,unsigned long *,int *,int ); +#else +#define is_vm_large_page (vma) (0) +#define follow_large_page(mm, vma, pages, vmas, &start, &len, i) (0) +#define copy_large_page (dst, src, vma) (0) +#endif +/* * On a two-level page table, this ends up being trivial. Thus the * inlining and the symmetry break with pte_alloc() that does all
include/linux/mmzone.h +1 -1
@@ -13,7 +13,7 @@*/ #ifndef CONFIG_FORCE_MAX_ZONEORDER -#define MAX_ORDER 10 +#define MAX_ORDER 15#else #define MAX_ORDER CONFIG_FORCE_MAX_ZONEORDER#endif
include/linux/sysctl.h +1 -0
@@ -124,6 +124,7 @@KERN_CORE_USES_PID =52 ,/* int: use core or core.%pid */ KERN_TAINTED =53 ,/* int: various kernel tainted flags */ KERN_CADPID =54 ,/* int: PID of the process to notify on CAD */ + KERN_LARGE_PAGE_MEM=55, /* Number of large_page pages configured */ };
kernel/sysctl.c +12 -0
@@ -96,6 +96,10 @@extern int acct_parm[];#endif +#ifdef CONFIG_LARGE_PAGE +extern int lp_max; +extern int change_large_page_mem_size (int ); +#endif extern int pgt_cache_water[]; static int parse_table(int *, int, void *, size_t *, void *, size_t,
@@ -256,6 +260,10 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif +#ifdef CONFIG_LARGE_PAGE + {KERN_LARGE_PAGE_MEM, "numlargepages", &lp_max, sizeof(int), 0644, NULL, + &proc_dointvec}, +#endif {0} };
@@ -866,6 +874,10 @@ val = -val; buffer += len; left -= len; +#if CONFIG_LARGE_PAGE +if (i == &lp_max) + val =change_large_page_mem_size (val); +#endif switch (op) {case OP_SET : *i = val;break ;case OP_AND : *i &= val;break ;
mm/memory.c +9 -0
@@ -179,6 +179,9 @@unsigned long end = vma->vm_end;unsigned long cow = (vma->vm_flags & (VM_SHARED |VM_MAYWRITE )) ==VM_MAYWRITE ; +if (is_vm_large_page (vma) ) +return copy_lpage_range (dst, src, vma); + src_pgd =pgd_offset (src, address)-1 ; dst_pgd =pgd_offset (dst, address)-1 ;
@@ -471,6 +474,10 @@if ( !vma || (pages && vma->vm_flags &VM_IO ) || !(flags & vma->vm_flags) )return i ? : -EFAULT ; +if (is_vm_large_page (vma)) { + i +=follow_large_page (mm, vma, pages, vmas, &start, &len, i); +continue ; + }spin_lock (&mm->page_table_lock); do { struct page *map;
@@ -1360,6 +1367,8 @@ {pgd_t *pgd;pmd_t *pmd; +if (is_vm_large_page (vma) ) +return -1 ; current->state =TASK_RUNNING ; pgd =pgd_offset (mm, address);
mm/mmap.c +3 -0
@@ -917,6 +917,9 @@if (mpnt->vm_start >= addr+len)return 0 ; +if (is_vm_large_page (mpnt))/*Large pages can not be unmapped like this. */ +return -EINVAL ; +/* If we'll make "hole", check the vm areas limit */ if ((mpnt->vm_start < addr && mpnt->vm_end > addr+len) && mm->map_count >=MAX_MAP_COUNT )
mm/mprotect.c +2 -0
@@ -287,6 +287,8 @@ error = -EFAULT ;if (!vma || vma->vm_start > start) goto out; +if (is_vm_large_page (vma)) +return -EINVAL ;/* Cann't change protections on large_page mappings. */ for (nstart = start ; ; ) {unsigned int newflags;
mm/mremap.c +4 -0
@@ -267,6 +267,10 @@ vma =find_vma (current->mm, addr);if (!vma || vma->vm_start > addr) goto out; +if (is_vm_large_page (vma)) { + ret = -EINVAL ;/* Cann't remap large_page mappings. */ + goto out; + }/* We can't remap across vm area boundaries */ if (old_len > vma->vm_end - addr) goto out;
Some observations which have been made thus far:
- Minimal impact on the VM and MM layers
Well the downside of this is that it means it isn't transparent to userspace. For example, specfp2000 results aren't going to improve after installing these changes. Some of the other large page implementations would.
- The change to MAX_ORDER is unneeded
This is probably done to increase the likelyhood that 4MB page orders are available. If we collapse 4MB pages deeper, they are less likely to be broken up because smaller orders would be selected first.
Maybe it doesn't make a difference....
- swapping of large pages and making them pagecache-coherent is unpopular.
Swapping them is easy, any time you hit a large PTE you unlarge it. This is what some of other large page implementations do. Basically the implementation is that set_pte() breaks apart large ptes when necessary.
I agree on the pagecache side.
Actually to be honest the other implementations seemed less intrusive and easier to add support for. The downside is that handling of weird cases like x86 using pmd's for 4MB pages was not complete last time I checked.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 1 line
- The change to
MAX_ORDERis unneeded
It's not only unneeded, it's detrimental. Not only will we spend more time merging stuff up and down to no effect, it also makes the config_nonlinear stuff harder (or we have to #ifdef it, which just causes more unnecessary differentiation). Please don't do that little bit ....
M.
Quoted 3 lines · David S. Miller
This is probably done to increase the likelyhood that 4MB page orders are available. If we collapse 4MB pages deeper, they are less likely to be broken up because smaller orders would be selected first.
This is leakage from ia64, which supports up to 256k pages.
Ummm, 4MB > 256K and even with a 4K PAGE_SIZE MAX_ORDER coalesces up to 4MB already :-)
Apparently a page-table based representation could not be used by PPC.
The page-table is just an abstraction, there is no reason dummy "large" ptes could not be used which are just ignored by the HW TLB reload code.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 13 lines · David S. Miller
From: Andrew Morton <[email protected]>
Date: Thu, 01 Aug 2002 17:37:46 -0700Some observations which have been made thus far:
- Minimal impact on the VM and MM layers
Well the downside of this is that it means it isn't transparent to userspace. For example, specfp2000 results aren't going to improve after installing these changes. Some of the other large page implementations would.
Quoted 5 lines
- The change to
MAX_ORDERis unneededThis is probably done to increase the likelyhood that 4MB page orders are available. If we collapse 4MB pages deeper, they are less likely to be broken up because smaller orders would be selected first.
This is leakage from ia64, which supports up to 256k pages.
Quoted 9 lines
Maybe it doesn't make a difference....
- swapping of large pages and making them pagecache-coherent is unpopular.
Swapping them is easy, any time you hit a large PTE you unlarge it. This is what some of other large page implementations do. Basically the implementation is that
set_pte()breaks apart large ptes when necessary.
As far as mm/*.c is concerned, there is no pte. It's just a vma which is marked "don't touch" These pages aren't on the LRU, nothing knows about them.
Apparently a page-table based representation could not be used by PPC.
Merged up to 2.5.30. It compiles.
http://www.zip.com.au/~akpm/linux/patches/2.5/2.5.30/lpp.patch
IMHO we shouldn't blindly decide for (or against!) this patch but also carefully look at the large page patch from RHAS (which got added to -aa recently) and the large page patch which IBM is working on.
And the one from Naohiko Shimizu which is my personal favorite because sparc64 support is there :)
http://shimizu-lab.dt.u-tokai.ac.jp/lsp.html
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 8 lines · David S. Miller
From: Andrew Morton <[email protected]>
- Minimal impact on the VM and MM layers
Well the downside of this is that it means it isn't transparent to userspace. For example, specfp2000 results aren't going to improve after installing these changes. Some of the other large page implementations would.
It also means we can't automatically switch to large pages for SHM segments, which is the number one area where we need large pages...
We should also take into account that the main application that needs large pages for its SHM segments is Oracle, which we don't have the source code for so we can't recompile it to use the new syscalls introduced by this patch ...
IMHO we shouldn't blindly decide for (or against!) this patch but also carefully look at the large page patch from RHAS (which got added to -aa recently) and the large page patch which IBM is working on.
kind regards,
Rik
Signature · 3 lines
Bravely reimplemented by the knights who say "NIH". http://www.surriel.com/ http://distro.conectiva.com/
other memory piggish apps (e.g. think scientific) would benefit
There are example "benchmark'ish" example on Naohiko Shimizu's large page project page.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
In message <[email protected]>, >
Quoted 10 lines · : Rik van Riel writes:
Quoted 8 lines · David S. Miller
From: Andrew Morton <[email protected]>
- Minimal impact on the VM and MM layers
Well the downside of this is that it means it isn't transparent to userspace. For example, specfp2000 results aren't going to improve after installing these changes. Some of the other large page implementations would.
Quoted 4 lines
We should also take into account that the main application that needs large pages for its SHM segments is Oracle, which we don't have the source code for so we can't recompile it to use the new syscalls introduced by this patch ...
There are quite a few other applications that can benefit from large page support. IBM Watson Research published JVM and some scientific workload results using large pages which showed substantial benefits. Also, we believe DB2, Domino, other memory piggish apps (e.g. think scientific) would benefit equally on many architectures.
It would sure be nice if the interface wasn't some kludgey back door but more integrated with things like mmap() or shm*(), with semantics and behaviors that were roughly more predictable. Other than that, no comments as yet on the patch internals...
gerrit
In message <[email protected]>, > : "David S. Miller" w rites:
Quoted 7 lines
From: Gerrit Huizenga <[email protected]>
Date: Thu, 01 Aug 2002 19:29:52 -0700other memory piggish apps (e.g. think scientific) would benefit
There are example "benchmark'ish" example on Naohiko Shimizu's large page project page.
No 2.5 code, though. :( But there *is* 2.2.16 code!
gerrit
In article <[email protected]>,
Quoted 4 lines · David S. Miller
From: Andrew Morton <[email protected]>
Date: Thu, 01 Aug 2002 18:26:40 -0700"David S. Miller" wrote:
Quoted 8 lines
Quoted 3 lines
This is probably done to increase the likelyhood that 4MB page orders are available. If we collapse 4MB pages deeper, they are less likely to be broken up because smaller orders would be selected first.
This is leakage from ia64, which supports up to 256k pages.
Ummm, 4MB > 256K and even with a 4K
PAGE_SIZEMAX_ORDERcoalesces up to 4MB already :-)
That should be 256_M_ pages (13 bits of page size + 15 bits of MAX_ORDER gives you 256MB max).
Linus
Quoted 2 lines · Andrew Morton
This is a large-page support patch from Rohit Seth, forwarded with his permission (thanks!).
Overall, the code looks very clean.
(1) So there are now 4 of these things. How do they compare to each other? Where are the comparison benchmarks? How do their features compare? Which one(s) do users want?
(2) The allocation policies for pagetables mapping the things may as well do some kind of lookup, sharing, and cacheing; it's likely a significant number of the users of the shm segment will be mapping them more or less the same way given database usage patterns. It's not a significant amount of space, but kernels should be frugal about space, and with many tasks as is typical of databases, the savings may well add up to a small but respectable chunk of ZONE_NORMAL.
(3) As long as the interface is explicit, it might as well drop flags
into shm and mmap. There isn't even C library support for these things as they are... time to int $0x80 again so I can test.
(4) Requiring app awareness of page alignment looks like an irritating porting issue, which doesn't sound as trivial as it would otherwise be in already extremely cramped 32-bit virtual address spaces.
(5) What's in it for the average user? It's doubtful GNOME will be registering memory blocks with these syscalls anytime soon. Granted, the opportunities for reducing TLB load this way are small on desktop systems, but it doesn't feel quite right to just throw mappings of magic physical memory into the hands of a few enlightened apps on machines with memory to burn and leave all others in the cold.
By several accounts "scalability" is defined as "performing as well on large machines as it does on small ones" ... but this seems to be a method of circumventing the kernel's own memory management as opposed to a method of improving it in all cases.
(6) As far as reconfiguring, I'm slightly concerned about the robustness of change_large_page_mem_size() in terms of how likely it is to succeed. Some on-demand defragmentation looks like it should be implemented to make it more reliable (now possible thanks to rmap). In general, the sysctl seems to lack some adaptivity. Granting root privileges to the workload vs. perpetual monitoring to find the ideal pool size sounds like a headache.
(7) I'm a little worried by the following:
zone(0): 4096 pages.
zone(1): 225280 pages.
BUG: wrong zone alignment, it will crash
zone(2): 3964928 pages.
My machine doesn't seem to care, but others' might.
Cheers,
Bill
In article <737220000.1028250590@flay>,
Quoted 4 lines · Martin J. Bligh
Quoted 1 line
- The change to
MAX_ORDERis unneededIt's not only unneeded, it's detrimental. Not only will we spend more time merging stuff up and down to no effect
I doubt that. At least the naive math says that it should get exponentially less likely(*) to merge up/down for each level, so by the time you've reached order-10, any merging is already in the noise and totally unmeasurable.
And the memory footprint of the bitmaps etc should be basically zero (since they too shrink exponentially for each order).
((*) The "exponentially less likely" simply comes from doing the trivial experiment of what would happen if you allocated all pages in-order one at a time, and then free'd them one at a time. Obviously not a realistic test, but on the other hand a realistic kernel load tends to keep a fairly fixed fraction of memory free, which makes it sound extremely unlikely to me that you'd get sudden collpses/buildups either. Th elikelihood of being at just the right border for that to happens _also_ happens to be decreasins as 2**-n)
Of course, if you can actually measure it, that would be interesting. Naive math gives you a guess for the order of magnitude effect, but nothing beats real numbers ;)
Quoted 2 lines
It also makes the
config_nonlinearstuff harder (or we have to #ifdef it, which just causes more unnecessary differentiation).
Hmm.. This sounds like a good point, but I thought we already did all the math relative to the start of the zone, so that the alignment thing implied by MAX_ORDER shouldn't be an issue.
Or were you thinking of some other effect?
Linus
From: [email protected] (Linus Torvalds)
Date: Fri, 2 Aug 2002 04:07:10 +0000 (UTC)
Of course, if you can actually measure it, that would be interesting. Naive math gives you a guess for the order of magnitude effect, but nothing beats real numbers ;)
The SYSV folks actually did have a buddy allocator a long time ago and they did implement lazy coalescing because is supposedly improved performance.
See chapter 12 section 7 in "Unix Internals" by Uresh Vahalia.
Quoted 3 lines · Andrew Morton
Merged up to 2.5.30. It compiles.
http://www.zip.com.au/~akpm/linux/patches/2.5/2.5.30/lpp.patch
What was the original against?
Signature · 1 line
Daniel
From: [email protected] (Linus Torvalds)
Date: Fri, 2 Aug 2002 04:07:10 +0000 (UTC)
Quoted 3 lines
Of course, if you can actually measure it, that would be interesting. Naive math gives you a guess for the order of magnitude effect, but nothing beats real numbers ;)
Quoted 4 lines · David S. Miller
The SYSV folks actually did have a buddy allocator a long time ago and they did implement lazy coalescing because is supposedly improved performance.
See chapter 12 section 7 in "Unix Internals" by Uresh Vahalia.
And I've implemented it for Linux.
ftp://ftp.kernel.org/pub/linux/kernel/people/wli/vm/lazy_buddy/
Cheers,
Bill
Quoted 8 lines · David S. Miller
Of course, if you can actually measure it, that would be interesting. Naive math gives you a guess for the order of magnitude effect, but nothing beats real numbers ;)
The SYSV folks actually did have a buddy allocator a long time ago and they did implement lazy coalescing because is supposedly improved performance.
I bet that is mainly because of CPU scalability, and being able to avoid touching the buddy lists from multiple CPU's - the same reason _we_ have the per-CPU front-ends on various allocators.
I doubt it is because buddy matters past the 4MB mark. I just can't see how you can avoid the naive math which says that it should be 1/512th as common to coalesce to 4MB as it is to coalesce to 8kB.
Walking the buddy bitmaps for a few levels (ie up to order 3 or 4) is probably quite common, and it's likely to be bad from a SMP cache standpoint (touching a few bits with what must be fairly random patterns). So avoiding the buddy with a simple front-end is likely to win you something, without actually being meaningful at the MAX_ORDER point.
Linus
Quoted 7 lines · Daniel Phillips
Quoted 3 lines · Andrew Morton
Merged up to 2.5.30. It compiles.
http://www.zip.com.au/~akpm/linux/patches/2.5/2.5.30/lpp.patch
What was the original against?
2.4.18
Direct email seemed to get seperated from the cc somewhere along the line ... repeated for others on l-k (sorry Linus ;-))
Quoted 4 lines
I doubt that. At least the naive math says that it should get exponentially less
likely(*)to merge up/down for each level, so by the time you've reached order-10, any merging is already in the noise and totally unmeasurable.
Yeah, it's probably unmeasurable, just ugly ;-)
I guess it's more that it seems unnecessary ... if ia64 are the only people that need it to be that ludicrously large, it'd be better if they just did it in their arch tree. Just because they could theoretically have 256Mb pages, do they really *need* them? ;-)
Quoted 8 lines
Quoted 2 lines
It also makes the
config_nonlinearstuff harder (or we have to# ifdef it, which just causes more unnecessary differentiation).Hmm.. This sounds like a good point, but I thought we already did all the math relative to the start of the zone, so that the alignment thing implied by
MAX_ORDERshouldn't be an issue.Or were you thinking of some other effect?
The config_nonlinear stuff relies on a trick ... we shove physically non-contig areas into the buddy allocator, but the buddy allocator is guaranteed to return phys contig areas. That all works just fine as long as the blocks we put in are of size greater than or equal to 2^MAX_ORDER * PAGE_SIZE, which is currently 4Mb. A 4Mb alignment is not a problem for any known machine, but I think 256Mb may well be. It's kind of a dirty trick, but it's a really neat, efficient solution that gets rid of lots of zone balancing and pgdat proliferation. It also lets me spread around ZONE_NORMAL across nodes for ia32 NUMA.
M.
Quoted 11 lines · Linus Torvalds
I bet that is mainly because of CPU scalability, and being able to avoid touching the buddy lists from multiple CPU's - the same reason _we_ have the per-CPU front-ends on various allocators.
I doubt it is because buddy matters past the 4MB mark. I just can't see how you can avoid the naive math which says that it should be 1/512th as common to coalesce to 4MB as it is to coalesce to 8kB.
Walking the buddy bitmaps for a few levels (ie up to order 3 or 4) is probably quite common, and it's likely to be bad from a SMP cache standpoint (touching a few bits with what must be fairly random patterns). So avoiding the buddy with a simple front-end is likely to win you something, without actually being meaningful at theMAX_ORDERpoint.
This is actually part of my strategy.
By properly organizing the deferred queues into lists of lists and maintaining a small per-cpu cache of pages, a "cache fill" involves doing a single list deletion under the zone->lock and the remainder of the work to fill a pagevec occurs outside the lock, reducing the mean hold time down to ridiculous lows. And since the allocations are batched, the arrival rate is then divided by the batch size. Conversely, frees are also batched and the same effect achieved with the dual operations.
i.e. magazines for the page-level allocator
This can't be achieved with a pure buddy system, as it must examine individual pages one-by-one to keep the bitmaps updated. Vahalia discusses the general approach in another section, and integration with buddy systems (and other allocators) in an exercise.
Cheers,
Bill
In my opinion the proposed large-page patch addresses a relatively pressing need for databases (primarily).
Databases want large pages with IPC_SHM, how can this special syscal hack address that?
It's great for experimentation, but give up syscall slots for this?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Gerrit Huizenga
Gerrit> It would sure be nice if the interface wasn't some kludgey Gerrit> back door but more integrated with things like mmap() or Gerrit> shm*(), with semantics and behaviors that were roughly more Gerrit> predictable. Other than that, no comments as yet on the Gerrit> patch internals...
In my opinion the proposed large-page patch addresses a relatively pressing need for databases (primarily). Longer term, I'd hope that it can be replaced by a transparent superpage scheme. But the existing patch can also serve as a nice benchmark for transparent schemes (and frankly, since it doesn't have to do anything smart behind the scenes, it's likely that the existing patch, where applicable, will always do slightly better than a transparent one).
In any case, the big issue of physical memory fragmentation can be experimented with indepent what the user-level interface looks like. So the existing patch is useful in that sense as well.
--david
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · David S. Miller
DaveM> From: David Mosberger <[email protected]> Date:
DaveM> Thu, 1 Aug 2002 22:24:05 -0700
DaveM> In my opinion the proposed large-page patch addresses a
DaveM> relatively pressing need for databases (primarily).
DaveM> Databases want large pages with IPC_SHM, how can this DaveM> special syscal hack address that?
I believe the interface is OK in that regard. AFAIK, Oracle is happy with it.
DaveM> It's great for experimentation, but give up syscall slots DaveM> for this?
I'm a bit concerned about this, too. My preference would have been to use the regular mmap() and shmat() syscalls with some augmentation/hint as to what the preferred page size is (Simon Winwood's OLS 2002 paper talks about some options here). I like this because hints could be useful even with a transparent superpage scheme.
The original Intel patch did use more of a hint-like approach (the hint was a simple binary flag though: give me regular pages or give me large pages), but Linus preferred a separate syscall interface, so the Intel folks switched over to doing that.
--david
Quoted 8 lines
DaveM> In my opinion the proposed large-page patch addresses a
DaveM> relatively pressing need for databases (primarily).DaveM> Databases want large pages with
IPC_SHM, how can this DaveM> special syscal hack address that?I believe the interface is OK in that regard. AFAIK, Oracle is happy with it.
Is Oracle now the world's only database? I think not.
Quoted 6 lines
DaveM> It's great for experimentation, but give up syscall slots DaveM> for this?
I'm a bit concerned about this, too. My preference would have been to use the regular
mmap()andshmat()syscalls with some augmentation/hint as to what the preferred page size is
I think that's what most users would prefer, and I don't think it adds a vast amount of kernel complexity. Linus doesn't seem to be dead set against the shmem modifications at least ... so that's half way there ;-)
M.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Martin J. Bligh
DaveM> In my opinion the proposed large-page patch addresses a DaveM> relatively pressing need for databases (primarily).
Quoted 1 line
Quoted 1 line
DaveM> Databases want large pages with IPC_SHM, how can this special DaveM> syscal hack address that?
Quoted 2 lines
Quoted 2 lines
I believe the interface is OK in that regard. AFAIK, Oracle is
happy with it.
Martin> Is Oracle now the world's only database? I think not.
I didn't say such a thing. I just don't know what other db vendors/authors think of the proposed interface. I'm sure their feedback would be welcome.
--david
Quoted 11 lines · Martin J. Bligh
Quoted 9 lines
DaveM> In my opinion the proposed large-page patch addresses a
DaveM> relatively pressing need for databases (primarily).DaveM> Databases want large pages with
IPC_SHM, how can this DaveM> special syscal hack address that?I believe the interface is OK in that regard. AFAIK, Oracle is happy with it.
Is Oracle now the world's only database? I think not.
Is a draft of Simon's patch available against 2.5?
-
At some point in the past, Dave Miller wrote:
DaveM> In my opinion the proposed large-page patch addresses a
DaveM> relatively pressing need for databases (primarily). DaveM> Databases want large pages with IPC_SHM, how can this DaveM> special syscal hack address that?
At some point in the past, David Mosberger wrote:
I believe the interface is OK in that regard. AFAIK, Oracle is happy with it.
Quoted 1 line · Martin J. Bligh
Quoted 1 line
Is Oracle now the world's only database? I think not.
Quoted 1 line · Andrew Morton
Is a draft of Simon's patch available against 2.5?
Unless I can turn blood into wine, walk on water, and produce a working 2.5 version of the thing in < 6 hours (not that I'm not trying), this will probably have to wait until Hubertus remeterializes tomorrow morning (EDT) and further porting is done. I'll be up early.
Cheers,
Bill
Quoted 11 lines · Linus Torvalds
Quoted 8 lines · David S. Miller
Of course, if you can actually measure it, that would be interesting. Naive math gives you a guess for the order of magnitude effect, but nothing beats real numbers ;)
The SYSV folks actually did have a buddy allocator a long time ago and they did implement lazy coalescing because is supposedly improved performance.
Quoted 7 lines
I bet that is mainly because of CPU scalability, and being able to avoid touching the buddy lists from multiple CPU's - the same reason _we_ have the per-CPU front-ends on various allocators.
I doubt it is because buddy matters past the 4MB mark. I just can't see how you can avoid the naive math which says that it should be 1/512th as common to coalesce to 4MB as it is to coalesce to 8kB.
Buddy costs tend to be down in the noise compared with the cost of the zone->lock.
I did a per-cpu pages patch a while back which, when it takes that lock, grabs 16 pages or frees 16 pages. Anton tested it on the 12-way: http://samba.org/~anton/linux/2.5.9/ blue -> purple
The cost of rmqueue() and __free_pages_ok went from 13% of system time down to 2%. So that 2% speedup is all that's available by fiddling with the buddy algorithm (I think). And I bet most of that is still taking the lock.
Didn't submit the patch because I think a per-cpu page buffer is a bit of a dopey cop-out. I have patches here which make most of the page-intensive fastpaths in the kernel stop using single pages and start using 16-page batches.
That will make a 16-page allocation request just a natural thing to do. But we will need a per-cpu buffer to wring the last drops out of anonymous pagefaults and generic_file_write(), which do not lend themselves to gang allocation.
I'm a bit concerned about this, too. My preference would have been to use the regular mmap() and shmat() syscalls with some augmentation/hint as to what the preferred page size is (Simon Winwood's OLS 2002 paper talks about some options here). I like this because hints could be useful even with a transparent superpage scheme.
A "hint" to use superpages? That's absurd.
Any time you are able to translate N pages instead of 1 page with 1 TLB entry it's always preferable.
I also don't buy the swapping complexity bit. The fact is, SHM and anonymous pages are easy. Just stay away from the page cache and it is pretty simple to just make the normal VM do this.
If set_pte sees a large page, you simply undo the large ptes in that group and the complexity ends right there. This means the only maker of large pages is the bit that creates the large mappings and has all of the ideal conditions up front. Any time anything happens to that pte you undo the large'ness of it so that you get normal PAGE_SIZE ptes back.
Using superpages for anonymous+SHM pages is really the only area I still think Linux's MM can offer inferior performance compared to what the hardware is actually capable of.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 11 lines · David S. Miller
From: David Mosberger <[email protected]>
Date: Thu, 1 Aug 2002 23:26:07 -0700I'm a bit concerned about this, too. My preference would have been to use the regular
mmap()andshmat()syscalls with some augmentation/hint as to what the preferred page size is (Simon Winwood's OLS 2002 paper talks about some options here). I like this because hints could be useful even with a transparent superpage scheme.A "hint" to use superpages? That's absurd.
What about applications that want fine-grained page aging? 4MB is a tad on the course side for most desktop applications.
-Ryan
What about applications that want fine-grained page aging? 4MB is a tad on the course side for most desktop applications.
Once vmscan sees the page and tries to liberate it, then it will be unlarge'd and thus you'll get fine-grained page aging.
That's the beauty of my implementation suggestion. --
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Uz.ytkownik David Mosberger napisa?:
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · Martin J. Bligh
DaveM> In my opinion the proposed large-page patch addresses a DaveM> relatively pressing need for databases (primarily).
Quoted 1 line
Quoted 1 line
DaveM> Databases want large pages with
IPC_SHM, how can this special DaveM> syscal hack address that?
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
I believe the interface is OK in that regard. AFAIK, Oracle is
happy with it.Martin> Is Oracle now the world's only database? I think not.
I didn't say such a thing. I just don't know what other db vendors/authors think of the proposed interface. I'm sure their feedback would be welcome.
You better don't ask DB people and in esp. the Oracle people
about opinnions on interface design. Unless you wan't something
fscking ugly internally looking like FORTRAN/COBOL coding.
They will always scrap portability/usability use undocumented behaviour and so on in the case they can presumably increase theyr pet benchmark values.
One of the reasons Solaris is *feeling* so slow is that they asked
Oracle people too frequent about oppinions apparently. In esp. they did forgett that there are other uses then DB servers ;-).
PS. I just got too much in touch with Oracle to not hate it...
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 6 lines · Ryan Cumming
Quoted 1 line · David S. Miller
A "hint" to use superpages? That's absurd.
What about applications that want fine-grained page aging? 4MB is a tad on the course side for most desktop applications.
Of course we wouldn't want to use superpages for VMAs smaller than, say, 4 of these superpages.
That would fix this problem automagically.
regards,
Rik
Signature · 3 lines
Bravely reimplemented by the knights who say "NIH". http://www.surriel.com/ http://distro.conectiva.com/
What does this error mean? "local symbols in discarded section .text.exit"
In reply to David S. MillerI need some help debugging this kernel build problem.
Here's the tail of my kernel build.
ld -m elf_i386 -r -o init.o main.o version.o do_mounts.o
make[1]: Leaving directory `/usr/src/v2.5.30/init'
ld -m elf_i386 -T arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.oarch/i386/kernel/init
_task.o init/init.o --start-group arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm
/mm.o fs/fs.o ipc/ipc.o security/built-in.o /usr/src/v2.5.30/arch/i386/lib/lib.a lib/lib.a /usr/ src/v2.5.30/arch/i386/lib/lib.a drivers/built-in.o sound/sound.o arch/i386/pci/pci.o net/network
.o --end-group -o vmlinux
drivers/built-in.o(.data+0x80f4): undefined reference to `local symbols in discarded section .te
xt.exit'
make: *** [vmlinux] Error 1
Re: What does this error mean? "local symbols in discarded section .text.exit"
Quoted 7 lines · jeff millar
I need some help debugging this kernel build problem.
drivers/built-in.o(.data+0x80f4): undefined reference to `local symbols in discarded section .te
xt.exit'
make: *** [vmlinux] Error 1
A know problem with some combinations of binutils and kernel sources. As Debian bintuils package says:
x You may experience problems linking older (and some newer) kernels with x x this version of binutils. This is not because of a bug in the linker, x x but rather a bug in the kernel source. This is being worked out and x x fixed by the upstream kernel group in newer kernels, but not all of the x x problems may have been fixed at this time. Older kernel versions will x x almost always exhibit the problem, however, and no attempts are being x x made to fix those that we know of. x x x x There are a few work-arounds, but the most reliable is to edit the x x linker script for your architecture (e.g. arch/i386/vmlinux.lds) and x x remove the '*(.text.exit)' entry from the 'DISCARD' line. It will x x bloat the kernel somewhat, but it should link properly. x
Regards,
Signature · 2 lines
Jose Luis Domingo Lopez Linux Registered User #189436 Debian Linux Woody (Linux 2.4.19-pre6aa1)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · David S. Miller
Dave.M> A "hint" to use superpages? That's absurd.
Dave.M> Any time you are able to translate N pages instead of 1 page Dave.M> with 1 TLB entry it's always preferable.
Yeah, right. So you think a 256MB page-size is optimal for all apps?
What you're missing is how you *get* to the point where you can map N pages with a single TLB entry. For that to happen, you need to allocate physically contiguous and properly aligned memory (at least given the hw that's common today). Doing has certain costs, no matter what your approach is.
--david
Re: What does this error mean? "local symbols in discarded section .text.exit"
In reply to Jose Luis Domingo LopezJose...
thanks for the reply. This link error happens with 2.5.27-2.5.30. Are you sure the kernel people are working on this?
jeff
----- Original Message -----
From: "Jose Luis Domingo Lopez" <[email protected]>
Quoted 6 lines
Quoted 3 lines · jeff millar
I need some help debugging this kernel build problem.
drivers/built-in.o(.data+0x80f4): undefined reference to `local symbols
in
Quoted 8 lines
Quoted 4 lines
discarded section .te
xt.exit'
make: *** [vmlinux] Error 1A know problem with some combinations of binutils and kernel sources. As Debian bintuils package says:
x You may experience problems linking older (and some newer) kernels with
x
Quoted 1 line
x this version of binutils. This is not because of a bug in the linker,
x
Quoted 1 line
x but rather a bug in the kernel source. This is being worked out and
x
Quoted 1 line
x fixed by the upstream kernel group in newer kernels, but not all of the
x
Quoted 1 line
x problems may have been fixed at this time. Older kernel versions will
x
Quoted 1 line
x almost always exhibit the problem, however, and no attempts are being
x
Quoted 1 line
x made to fix those that we know of.
x
Re: What does this error mean? "local symbols in discarded section .text.exit"
Hi,
Quoted 2 lines · jeff millar
thanks for the reply. This link error happens with 2.5.27-2.5.30. Are you sure the kernel people are working on this?
Well, it doesn't seem so.
http://marc.theaimsgroup.com/?l=linux-kernel&m=102798967514023&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=102799199615357&w=2
The response seems to me like "Well, I don't care as long as the latest (not working on some arches) gcc does..."
Thunder
Signature · 1 line
.-../../-./..-/-..- .-./..-/.-.././.../.-.-.-
On Thu, Aug 01, 2002 at 05:37:46PM -0700, Andrew Morton wrote:
diff -Naru linux.org/arch/i386/kernel/entry.S linux.lp/arch/i386/kernel/entry.S
--- linux.org/arch/i386/kernel/entry.S Mon Feb 25 11:37:53 2002
+++ linux.lp/arch/i386/kernel/entry.S Tue Jul 2 15:12:23 2002
@@ -634,6 +634,10 @@
.long SYMBOL_NAME(sys_ni_syscall) /* 235 reserved for removexattr */
.long SYMBOL_NAME(sys_ni_syscall) /* reserved for lremovexattr */
.long SYMBOL_NAME(sys_ni_syscall) /* reserved for fremovexattr */
+ .long SYMBOL_NAME(sys_get_large_pages) /* Get large_page pages */
+ .long SYMBOL_NAME(sys_free_large_pages) /* Free large_page pages */
+ .long SYMBOL_NAME(sys_share_large_pages)/* Share large_page pages */
+ .long SYMBOL_NAME(sys_unshare_large_pages)/* UnShare large_page pages */
Must large pages be allocated this way?
At some point I would like to see code that mmap's large amounts of data (over 1GB) and have it take advantage of this once the kernel is potentially extended to deal with mapping of large and/or variable sized pages backed to disk.
Also, some scientific applications will malloc(3) gobs of ram, again in excess of 1GB, is it unreasonable to expect that the kernel will notice large allocations and try to provide large pages sbrk in invoked with suitable high values?
--cw