PATCH swsusp: page rellocation speed up
Subsystems (2)
Hello,
attached patch should speed up page rellocation at time of resume. Please test. The diff is against 2.6.10-bk8
Signature · 1 line
Lukáš Hejtmánek
kernel/power/swsusp.c +24 -13
@@ -885,25 +885,18 @@ } -/* More restore stuff */ -#define does_collide (addr) does_collide_order(pagedir_nosave, addr, 0) -/* * Returns true if given address/order collides with any orig_address */ -static int __init does_collide_order (suspend_pagedir_t *pagedir,unsigned long addr, -int order) +static int __init does_collide_order (unsigned long addr,int order) {int i; -unsigned long addre = addr + (PAGE_SIZE <<order); -for (i=0 ; i < nr_copy_pages; i++) -if ((pagedir+i)->orig_address >= addr && - (pagedir+i)->orig_address < addre) +for (i=0 ; i < (1 <<order); i++) +if (!PageNosaveFree (virt_to_page (addr + i *PAGE_SIZE )))return 1 ; -return 0 ; }
@@ -922,7 +915,7 @@ addr =get_zeroed_page (GFP_ATOMIC );if (!addr)return -ENOMEM ; - }while (does_collide (addr)); + }while (does_collide_order (addr,0 )); (pagedir_nosave+i)->address = addr; }
@@ -939,16 +932,34 @@void **eaten_memory =NULL ;void **c = eaten_memory, *m, *f;int ret =0 ; +struct zone *zone; +int i; +struct pbe *p; +unsigned long zone_pfn;printk ("Relocating pagedir " ); -if (!does_collide_order (old_pagedir, (unsigned long )old_pagedir, pagedir_order)) { +/* Set page flags */ + +for_each_zone (zone) { +for (zone_pfn =0 ; zone_pfn < zone->spanned_pages; ++zone_pfn) +SetPageNosaveFree (pfn_to_page (zone_pfn + + zone->zone_start_pfn)); + } + +/* Clear orig address */ + +for (i =0 , p = pagedir_nosave; i < nr_copy_pages; i++, p++) { +ClearPageNosaveFree (virt_to_page (p->orig_address)); + } + +if (!does_collide_order ((unsigned long )old_pagedir, pagedir_order)) {printk ("not necessary\n" );return check_pagedir (); }while ((m = (void *)__get_free_pages (GFP_ATOMIC , pagedir_order)) !=NULL ) { -if (!does_collide_order (old_pagedir, (unsigned long )m, pagedir_order)) +if (!does_collide_order ((unsigned long )m, pagedir_order))break ; eaten_memory = m;printk ("." );
Quoted 5 lines · Lukas Hejtmanek
Hello,
attached patch should speed up page rellocation at time of resume. Please test. The diff is against 2.6.10-bk8
....
really cool, Passed in my x86 and ppc.
Here is a patch to make pagedir using non-continuity page,
2.6.10 -> mm1 -> this patch -> my patch
I temporary split pbe function to pbe.h, useful merge.
arch/i386/power/swsusp.S +28 -16
@@ -31,24 +31,36 @@ ENTRY(swsusp_arch_resume) movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 - movl pagedir_nosave, %ebx - xorl %eax, %eax - xorl %edx, %edx - .p2align 4,,7 + movl pagedir_nosave, %eax + test %eax, %eax + je copy_loop_end + movl $1024, %edx -copy_loop: - movl 4(%ebx,%edx),%edi - movl (%ebx,%edx),%esi - - movl $1024, %ecx - rep - movsl - - incl %eax - addl $16, %edx - cmpl nr_copy_pages,%eax - jb copy_loop .p2align 4,,7 +copy_loop_start: + movl 0xc(%eax), %ebp + xorl %ebx, %ebx + leal 0x0(%esi),%esi + +copy_one_pgdir: + movl 0x4(%eax),%edi + test %edi, %edi + je copy_loop_end + + movl (%eax), %esi + movl %edx, %ecx + repz movsl %ds:(%esi),%es:(%edi) + + incl %ebx + addl $0x10, %eax + cmpl $0xff, %ebx + jbe copy_one_pgdir + test %ebp, %ebp + movl %ebp, %eax + jne copy_loop_start + + .p2align 4,,7 +copy_loop_end: movl saved_context_esp, %esp movl saved_context_ebp, %ebp
kernel/power/pbe.h +380 -0
380 lines not on this page · raw message
kernel/power/swsusp.c +55 -225
437 lines not on this page · raw message
Signature · 5 lines
Hu Gang .-.
/v\
// \\
Linux User /( )\ [204016]
GPG Key ID ^^-^^ http://soulinfo.com/~hugang/hugang.ascQuoted 6 lines · On Wed, Jan 12, 2005 at 08:49:49PM +0800, [email protected] wrote:
Quoted 5 lines · Lukas Hejtmanek
Hello,
attached patch should speed up page rellocation at time of resume. Please test. The diff is against 2.6.10-bk8
Quoted 7 lines
....
really cool, Passed in my x86 and ppc.
Here is a patch to make pagedir using non-continuity page,
2.6.10 -> mm1 -> this patch -> my patch
support for PowerPc.
2.6.10 -> mm1 -> Lukas Hejtmanek's patch -> agx's patch -> pbe core ->
this patch
agx swsusp patch from http://honk.physik.uni-konstanz.de/~agx/linux-ppc/kernel/
arch/ppc/kernel/swsusp.S renamed from arch/ppc/kernel/swsusp.S~old +49 -35
@@ -159,43 +159,57 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) sync isync - /* Load ptr the list of pages to copy in r3 */ - lis r11,(pagedir_nosave - KERNELBASE)@h - ori r11,r11,pagedir_nosave@l - lwz r10,0(r11) - tophys(r3,r10) - - /* Load the count of pages to copy in r4 */ - lis r11,(nr_copy_pages - KERNELBASE)@h - ori r11,r11,nr_copy_pages@l - lwz r4,0(r11) + /* Load ptr the list of pages to copy in r11 */ + lis r9,pagedir_nosave@ha + addi r9,r9,pagedir_nosave@l + tophys(r9,r9) + lwz r9, 0(r9) +#if 0 + twi 31,r0,0 /* triger trap */ +#endif + cmpwi r9, 0 + beq copy_loop_end - /* Copy the pages. This is a very basic implementation, to - * be replaced by something more cache efficient */ -1: - li r0,256 - mtctr r0 - lwz r11,0(r3) /* source */ - tophys(r5,r11) - lwz r10,4(r3) /* destination */ - tophys(r6,r10) -2: - lwz r8,0(r5) - lwz r9,4(r5) - lwz r10,8(r5) - lwz r11,12(r5) - addi r5,r5,16 - stw r8,0(r6) - stw r9,4(r6) - stw r10,8(r6) - stw r11,12(r6) - addi r6,r6,16 - bdnz 2b - addi r3,r3,16 - subi r4,r4,1 - cmpwi 0,r4,0 - bne 1b +copy_loop: + tophys(r9,r9) + lwz r6, 12(r9) + li r10, 0 + +copy_one_pgdir: + lwz r11, 4(r9) + addi r8,r10,1 + cmpwi r11, 0 + addi r7,r9,16 + beq copy_loop_end + li r0, 256 + mtctr r0 + lwz r9,0(r9) +#if 0 + twi 31,r0,0 /* triger trap */ +#endif + tophys(r10,r11) + tophys(r11,r9) + +copy_one_page: + lwz r0, 0(r11) + stw r0, 0(r10) + lwz r9, 4(r11) + stw r9, 4(r10) + lwz r0, 8(r11) + stw r0, 8(r10) + lwz r9, 12(r11) + addi r11,r11,16 + stw r9, 12(r10) + addi r10,r10,16 + bdnz copy_one_page + mr r10, r8 + cmplwi r10, 255 + mr r9, r7 + ble copy_one_pgdir + mr r9, r6 + bne copy_loop +copy_loop_end: /* Do a very simple cache flush/inval of the L1 to ensure * coherency of the icache
Signature · 5 lines
Hu Gang .-.
/v\
// \\
Linux User /( )\ [204016]
GPG Key ID ^^-^^ http://soulinfo.com/~hugang/hugang.ascQuoted 6 lines · On Wed, Jan 12, 2005 at 08:49:49PM +0800, [email protected] wrote:
Quoted 5 lines · Lukas Hejtmanek
Hello,
attached patch should speed up page rellocation at time of resume. Please test. The diff is against 2.6.10-bk8
Quoted 7 lines
....
really cool, Passed in my x86 and ppc.
Here is a patch to make pagedir using non-continuity page,
2.6.10 -> mm1 -> this patch -> my patch
...
After more deep test, I found A bug, Here is a patch to fix it.
kernel/power/pbe.h renamed from kernel/power/pbe.h~mail +4 -3
@@ -267,7 +267,7 @@ static int __init check_pagedir(void) {void **c, *f;struct pbe *next, *pos; -int error, index, i; +int error, index;suspend_pagedir_t *addr =NULL ;struct zone *zone;unsigned long zone_pfn;
@@ -280,8 +280,9 @@ static int __init check_pagedir(void) }/* Clear orig address */ -pbe_for_each (pos, next, i, nr_copy_pages, pagedir_nosave) { -pr_debug ("clear <%p>\n" , (void *)pos->orig_address); +pbe_for_each (pos, next, index, nr_copy_pages, pagedir_nosave) { +pr_debug ("clear <%p>, <%p>, %d\n" , + pos, (void *)pos->orig_address, index);ClearPageNosaveFree (virt_to_page (pos->orig_address)); }
kernel/power/swsusp.c renamed from kernel/power/swsusp.c~mail +3 -0
@@ -380,6 +380,8 @@ static int write_pagedir(void)pgdir_for_each (pgdir, next, pagedir_nosave) { error =write_page ((unsigned long )pgdir, &swsusp_info.pagedir[n]); +pr_debug ("write_pagedir: <%p>, %lu\n" , + pgdir,swp_offset (swsusp_info.pagedir[n]));if (error)break ; n ++; }
@@ -1008,6 +1010,7 @@ static int __init read_pagedir(void)pgdir_for_each (pgdir, next, pagedir_nosave) { error =read_one_pagedir (pgdir, i);if (error)break ; + pgdir[ONE_PAGE_PBE_NUM -1 ].dummy.val = next ? next->dummy.val :0 ; i++; }BUG_ON (i != n);
Signature · 5 lines
Hu Gang .-.
/v\
// \\
Linux User /( )\ [204016]
GPG Key ID ^^-^^ http://soulinfo.com/~hugang/hugang.ascQuoted 6 lines · On Wed, Jan 12, 2005 at 08:49:49PM +0800, [email protected] wrote:
Quoted 5 lines · Lukas Hejtmanek
Hello,
attached patch should speed up page rellocation at time of resume. Please test. The diff is against 2.6.10-bk8
Quoted 8 lines
....
really cool, Passed in my x86 and ppc.
Here is a patch to make pagedir using non-continuity page,
2.6.10 -> mm1 -> this patch -> my patchI temporary split pbe function to
pbe.h, useful merge.
Here is my lastest patch for this.
changes
Fix a big bug in core code, Now it works in my PPC and X86, please test.
2.6.10 -> mm1 -> axg's patch -> Hejtmanek's -> core.diff
arch/i386/power/swsusp.S +28 -16
@@ -31,24 +31,36 @@ ENTRY(swsusp_arch_resume) movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 - movl pagedir_nosave, %ebx - xorl %eax, %eax - xorl %edx, %edx - .p2align 4,,7 + movl pagedir_nosave, %eax + test %eax, %eax + je copy_loop_end + movl $1024, %edx -copy_loop: - movl 4(%ebx,%edx),%edi - movl (%ebx,%edx),%esi - - movl $1024, %ecx - rep - movsl - - incl %eax - addl $16, %edx - cmpl nr_copy_pages,%eax - jb copy_loop .p2align 4,,7 +copy_loop_start: + movl 0xc(%eax), %ebp + xorl %ebx, %ebx + leal 0x0(%esi),%esi + +copy_one_pgdir: + movl 0x4(%eax),%edi + test %edi, %edi + je copy_loop_end + + movl (%eax), %esi + movl %edx, %ecx + repz movsl %ds:(%esi),%es:(%edi) + + incl %ebx + addl $0x10, %eax + cmpl $0xff, %ebx + jbe copy_one_pgdir + test %ebp, %ebp + movl %ebp, %eax + jne copy_loop_start + + .p2align 4,,7 +copy_loop_end: movl saved_context_esp, %esp movl saved_context_ebp, %ebp
kernel/power/pbe.h +381 -0
381 lines not on this page · raw message
kernel/power/swsusp.c +60 -225
447 lines not on this page · raw message
2.6.10 -> mm1 -> axg's patch -> Hejtmanek's -> core.diff -> ppc.diff
arch/ppc/kernel/swsusp.S +48 -35
91 lines not on this page · raw message
Signature · 5 lines
Hu Gang .-.
/v\
// \\
Linux User /( )\ [204016]
GPG Key ID ^^-^^ http://soulinfo.com/~hugang/hugang.asc