Commit 60d5f1e1 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64: Speed up suspend

The following patch speeds up the restoring of swsusp images on x86-64
and makes the assembly code more readable (tested and works on AMD64).
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>

Changed by AK to not hardcode any C values and get them from offset.h instead
and not flushing CR3 needlessly (according to Pavel it was just an old
debugging measure that is not needed anymore)
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2b33c460
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/hardirq.h> #include <linux/hardirq.h>
#include <linux/suspend.h>
#include <asm/pda.h> #include <asm/pda.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/segment.h> #include <asm/segment.h>
...@@ -61,6 +62,8 @@ int main(void) ...@@ -61,6 +62,8 @@ int main(void)
offsetof (struct rt_sigframe32, uc.uc_mcontext)); offsetof (struct rt_sigframe32, uc.uc_mcontext));
BLANK(); BLANK();
#endif #endif
DEFINE(SIZEOF_PBE, sizeof(struct pbe));
DEFINE(pbe_address, offsetof(struct pbe, address));
DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
return 0; return 0;
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/offset.h>
ENTRY(swsusp_arch_suspend) ENTRY(swsusp_arch_suspend)
...@@ -49,43 +50,28 @@ ENTRY(swsusp_arch_resume) ...@@ -49,43 +50,28 @@ ENTRY(swsusp_arch_resume)
movq %rcx, %cr3; movq %rcx, %cr3;
movq %rax, %cr4; # turn PGE back on movq %rax, %cr4; # turn PGE back on
movq pagedir_nosave(%rip), %rdx
/* compute the limit */
movl nr_copy_pages(%rip), %eax movl nr_copy_pages(%rip), %eax
xorl %ecx, %ecx
movq $0, %r10
testl %eax, %eax testl %eax, %eax
jz done jz done
.L105: movq %rdx,%r8
xorl %esi, %esi movl $SIZEOF_PBE,%r9d
movq $0, %r11 mul %r9 # with rax, clobbers rdx
jmp .L104 movq %r8, %rdx
.p2align 4,,7 addq %r8, %rax
copy_one_page: loop:
movq %r10, %rcx /* get addresses from the pbe and copy the page */
.L104: movq pbe_address(%rdx), %rsi
movq pagedir_nosave(%rip), %rdx movq pbe_orig_address(%rdx), %rdi
movq %rcx, %rax movq $512, %rcx
salq $5, %rax rep
movq 8(%rdx,%rax), %rcx movsq
movq (%rdx,%rax), %rax
movzbl (%rsi,%rax), %eax
movb %al, (%rsi,%rcx)
movq %cr3, %rax; # flush TLB
movq %rax, %cr3;
movq %r11, %rax /* progress to the next pbe */
incq %rax addq $SIZEOF_PBE, %rdx
cmpq $4095, %rax cmpq %rax, %rdx
movq %rax, %rsi jb loop
movq %rax, %r11
jbe copy_one_page
movq %r10, %rax
incq %rax
movq %rax, %rcx
movq %rax, %r10
mov nr_copy_pages(%rip), %eax
cmpq %rax, %rcx
jb .L105
done: done:
movl $24, %eax movl $24, %eax
movl %eax, %ds movl %eax, %ds
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment