SMP support for swsusp (this one actually works for me)
Subsystems (3)
Hi!
Here's SMP support for swsusp; this one actually works for me [with keyboard hack], but I'd like more testers. If it looks okay, I'll merge simple pieces with andrew.
Pavel
drivers/input/serio/i8042.c +5 -1
@@ -841,12 +841,13 @@return -1 ; } +#if 0 if (i8042_mux_present)if (i8042_enable_mux_mode (&i8042_aux_values,NULL ) ||i8042_enable_mux_ports (&i8042_aux_values)) {printk (KERN_WARNING "i8042: failed to resume active multiplexor, mouse won't work.\n" ); } - +#endif /* * Reconnect anything that was connected to the ports. */
@@ -854,12 +855,15 @@if (i8042_kbd_values.exists &&i8042_activate_port (&i8042_kbd_port) ==0 )serio_reconnect (&i8042_kbd_port); +#if 0 if (i8042_aux_values.exists &&i8042_activate_port (&i8042_aux_port) ==0 )serio_reconnect (&i8042_aux_port);for (i =0 ; i <4 ; i++)if (i8042_mux_values[i].exists &&i8042_activate_port (i8042_mux_port + i) ==0 )serio_reconnect (i8042_mux_port + i); +#endif +/* * Restart timer (for polling "stuck" data) */
include/linux/suspend.h +8 -0
@@ -81,6 +81,14 @@ }#endif /* CONFIG_PM */ +#ifdef CONFIG_SMP +extern void smp_freeze (void ); +extern void smp_restart (void ); +#else +static inline void smp_freeze (void ) {} +static inline void smp_restart (void ) {} +#endif + asmlinkage void do_magic(int is_resume); asmlinkage void do_magic_resume_1(void); asmlinkage void do_magic_resume_2(void);
kernel/power/process.c +0 -1
@@ -109,7 +109,6 @@wake_up_process (p); }else printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); -wake_up_process (p); }while_each_thread (g, p);read_unlock (&tasklist_lock);
kernel/power/swsusp.c +16 -4
@@ -837,8 +855,11 @@free_some_memory (); -/* Save state of all device drivers, and stop them. */ -if ((res =device_suspend (4 ))==0 ) +mdelay (1000 ); +smp_freeze (); +/* Save state of all device drivers, and stop them. */ +printk ("Suspending devices... " ); +if ((res =device_suspend (4 ))==0 ) {/* If stopping device drivers worked, we proceed basically into * suspend_save_image. *
@@ -848,8 +869,16 @@* unsuspends all device drivers, and writes memory to disk * using normal kernel mechanism. */ +printk ("ok\n" ); +#if 1 do_magic (0 ); +#else +device_resume (); +#endif + }thaw_processes (); +printk ("Processes thawed\n" ); +smp_restart (); }else res = -EBUSY ; software_suspend_enabled =1 ;
@@ -1173,8 +1204,7 @@static int __init software_resume (void ) {if (num_online_cpus () >1 ) { -printk (KERN_WARNING "Software Suspend has malfunctioning SMP support. Disabled :(\n" ); -return -EINVAL ; +printk (KERN_WARNING "SMP support is very experimental.\n" ); }/* We enable the possibility of machine suspend */ software_suspend_enabled =1 ;
@@ -1201,6 +1231,8 @@printk ("resuming from %s\n" , resume_file);if (read_suspend_image (resume_file,0 )) goto read_failure; +mdelay (1000 ); +smp_freeze ();device_suspend (4 );do_magic (1 );panic ("This never returns" );
arch/i386/power/cpu.c +60 -49
163 lines not on this page · raw message
kernel/power/smp.c +85 -0
85 lines not on this page · raw message
kernel/power/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-y := main.o process.o console.o pm.o +obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o obj-$(CONFIG_PM_DISK) += disk.o pmdisk.o
kernel/sched.c +1 -0
@@ -3558,6 +3558,7 @@ p =kthread_create (migration_thread, hcpu,"migration/%d" ,cpu);if (IS_ERR (p))return NOTIFY_BAD ; + p->flags |=PF_NOFREEZE ;kthread_bind (p, cpu);/* Must be high prio: stop_machine expects to yield to it. */ rq =task_rq_lock (p, &flags);
%diffstat
Documentation/power/swsusp.txt | 5 + Documentation/power/video.txt | 4 + arch/i386/kernel/cpu/mtrr/main.c | 3 + arch/i386/kernel/signal.c | 3 - arch/i386/power/cpu.c | 109 +++++++++++++++++++++------------------ arch/i386/power/swsusp.S | 4 - arch/x86_64/kernel/time.c | 31 +++++++++-- drivers/acpi/event.c | 24 +++----- drivers/acpi/thermal.c | 15 +++++ drivers/input/power.c | 12 ++++ drivers/input/serio/i8042.c | 6 +- include/linux/suspend.h | 8 ++ kernel/power/Makefile | 1 kernel/power/process.c | 1 kernel/power/smp.c | 85 ++++++++++++++++++++++++++++++ kernel/power/swsusp.c | 78 +++++++++++++++++++-------- kernel/signal.c | 6 +- 17 files changed, 293 insertions(+), 102 deletions(-)
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 4 lines
Here's SMP support for swsusp; this one actually works for me [with keyboard hack], but I'd like more testers. If it looks okay, I'll merge simple pieces with andrew.
This looks cool, but I have some aesthetic nits about it:
Quoted 7 lines
drivers/input/serio/i8042.c +1
-0@@ -841,12 +841,13 @@return -1 ; } +#if 0
...
Quoted 2 lines
drivers/input/serio/i8042.c +2
-0+#endif +#if 0
...
Quoted 1 line
+#endif
If that's dead code, why not remove it?
drivers/input/serio/i8042.c
Quoted 7 lines
drivers/input/serio/i8042.c +7
-0+#ifdef CONFIG_SMP +extern void smp_freeze (void ); +extern void smp_restart (void ); +#else +static inline void smp_freeze (void ) {} +static inline void smp_restart (void ) {} +#endif
Could you name those something more explicit, like swsusp_smp_freeze(), etc, so you don't have potential namespace conflicts?
drivers/input/serio/i8042.c
Quoted 5 lines
drivers/input/serio/i8042.c +4
-0+#if 1 do_magic (0 ); +#else +device_resume (); +#endif
What is this? It looks completely gratuitous.
arch/i386/power/cpu.c line 71
Quoted 10 lines
arch/i386/power/cpu.c +4
-1-void save_processor_state(void) +void __save_processor_state (struct saved_context *ctxt) +voidsave_processor_state (void) +{ +__save_processor_state (&saved_context); }
This also looks completely gratuitous and confusing - if you're not doing anything else but calling the __function, then why even create __function?
Quoted 2 lines
EXPORT_SYMBOL(save_processor_state);
EXPORT_SYMBOL(restore_processor_state);
And, why are they exported in the first place?
Quoted 11 lines
%diffstat
Documentation/power/swsusp.txt | 5 + Documentation/power/video.txt | 4 + arch/i386/kernel/cpu/mtrr/main.c | 3 + arch/i386/kernel/signal.c | 3 - arch/i386/power/cpu.c | 109 +++++++++++++++++++++------------------ arch/i386/power/swsusp.S | 4 - arch/x86_64/kernel/time.c | 31 +++++++++-- drivers/acpi/event.c | 24 +++----- drivers/acpi/thermal.c | 15 +++++ drivers/input/power.c | 12 ++++
Quoted 8 lines
drivers/input/serio/i8042.c | 6 +- include/linux/suspend.h | 8 ++ kernel/power/Makefile | 1 kernel/power/process.c | 1 kernel/power/smp.c | 85 ++++++++++++++++++++++++++++++ kernel/power/swsusp.c | 78 +++++++++++++++++++-------- kernel/signal.c | 6 +- 17 files changed, 293 insertions(+), 102 deletions(-)
Were there more files to the patch? Some of the ones listed here were not in the email?
BTW, nice work.
Pat
Hi!
Quoted 5 lines
Quoted 3 lines
Here's SMP support for swsusp; this one actually works for me [with keyboard hack], but I'd like more testers. If it looks okay, I'll merge simple pieces with andrew.
This looks cool, but I have some aesthetic nits about it:
I'll kill #if 0s before attempting to merge.
Quoted 10 lines
include/linux/suspend.h line 90
Quoted 7 lines
include/linux/suspend.h +7
-0+#ifdef CONFIG_SMP +extern void smp_freeze (void ); +extern void smp_restart (void ); +#else +static inline void smp_freeze (void ) {} +static inline void smp_restart (void ) {} +#endif Could you name those something more explicit, like
swsusp_smp_freeze(), etc, so you don't have potential namespace conflicts?
I guess that S3 sleep might find them usefull, too.
Perhaps calling them disable_nonboot_cpus() and enable_nonboot_cpus() are better names?
Quoted 11 lines
arch/i386/power/cpu.c line 71
Quoted 7 lines
arch/i386/power/cpu.c +4
-1-void save_processor_state(void) +void __save_processor_state (struct saved_context *ctxt) +voidsave_processor_state (void) +{ +__save_processor_state (&saved_context); }This also looks completely gratuitous and confusing - if you're not doing anything else but calling the
__function, then why even create__function?
__save_processor_state() is needed from smp.c, save_processor_state() is needed from swsusp.S. I did not want to break that for now.
Quoted 4 lines
Quoted 2 lines
EXPORT_SYMBOL(save_processor_state);
EXPORT_SYMBOL(restore_processor_state);And, why are they exported in the first place?
Not sure... swsusp can't be modular so I should be able to just kill this, right?
Quoted 3 lines
Quoted 3 lines
%diffstat
Documentation/power/swsusp.txt | 5 + Documentation/power/video.txt | 4 +
...
Quoted 7 lines
Quoted 4 lines
kernel/power/smp.c | 85 ++++++++++++++++++++++++++++++ kernel/power/swsusp.c | 78 +++++++++++++++++++-------- kernel/signal.c | 6 +- 17 files changed, 293 insertions(+), 102 deletions(-)Were there more files to the patch? Some of the ones listed here were not in the email?
I hand-edited the diff and forgot to kill this, sorry. Nothing should be missing.
Quoted 1 line
BTW, nice work.
Thanks!
Pavel
Signature · 2 lines
People were complaining that M$ turns users into beta-testers... ...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
Quoted 5 lines · Patrick Mochel
Quoted 1 line
+#if 0
...
Quoted 1 line
+#endif
If that's dead code, why not remove it?
I'm not entirely convinced that is dead code on all systems ...
Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan