[PATCH][RFC] swsusp: speed up image restoring on x86-64

From: Rafael J. Wysocki
Date: Thu Jan 20 2005 - 14:36:14 EST


Hi,

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). It's
against 2.6.11-rc1-mm1, but applies to 2.6.11-rc1-mm2. Please consifer for applying.

Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>

--- linux-2.6.11-rc1-mm1/arch/x86_64/kernel/suspend_asm.S 2004-12-24 22:35:28.000000000 +0100
+++ linux-2.6.11-rc1-mm1-rjw/arch/x86_64/kernel/suspend_asm.S 2005-01-20 17:28:30.000000000 +0100
@@ -49,43 +49,28 @@
movq %rcx, %cr3;
movq %rax, %cr4; # turn PGE back on

+ movq pagedir_nosave(%rip), %rdx
+ /* compute the limit */
movl nr_copy_pages(%rip), %eax
- xorl %ecx, %ecx
- movq $0, %r10
testl %eax, %eax
jz done
-.L105:
- xorl %esi, %esi
- movq $0, %r11
- jmp .L104
- .p2align 4,,7
-copy_one_page:
- movq %r10, %rcx
-.L104:
- movq pagedir_nosave(%rip), %rdx
- movq %rcx, %rax
- salq $5, %rax
- movq 8(%rdx,%rax), %rcx
- movq (%rdx,%rax), %rax
- movzbl (%rsi,%rax), %eax
- movb %al, (%rsi,%rcx)
+ shlq $5, %rax; # multiply by sizeof(struct pbe)
+ addq %rdx, %rax
+loop:
+ /* get addresses from the pbe and copy the page */
+ movq (%rdx), %rsi
+ movq 8(%rdx), %rdi
+ movq $512, %rcx
+ rep
+ movsq

- movq %cr3, %rax; # flush TLB
- movq %rax, %cr3;
+ movq %cr3, %rcx; # flush TLB
+ movq %rcx, %cr3;

- movq %r11, %rax
- incq %rax
- cmpq $4095, %rax
- movq %rax, %rsi
- 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
+ /* progress to the next pbe */
+ addq $32, %rdx; # add sizeof(struct pbe)
+ cmpq %rax, %rdx
+ jb loop
done:
movl $24, %eax
movl %eax, %ds



Greets,
RJW


--
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
-- Lewis Carroll "Alice's Adventures in Wonderland"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/