Suspend2 2.1.9.8 for 2.6.12
Subsystems (48)
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel Cunninghamkernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 5
Quoted 9 lines · Nigel Cunningham
diff -ruNp
623-generic-block-io.patch-old/kernel/power/suspend_block_io.c623-generic-block-io.patch-new/kernel/power/suspend_block_io.ckernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +5
-0@@ -0,0 +1,817 @@ +#include "suspend2_core/suspend.h" +#include "suspend2_core/proc.h" +#include "suspend2_core/plugins.h" +#include "suspend2_core/utility.h" +#include "suspend2_core/prepare_image.h"
You've got circular dependencies. kernel/power/suspend2_core depends on kernel/power and vice versa. Please just consider putting them all in kernel/power/
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 13
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +8
-0+/* Bits in struct io_info->flags */ +#define IO_WRITING 1 +#define IO_RESTORE_PAGE_PROT 2 +#define IO_AWAITING_READ 3 +#define IO_AWAITING_WRITE 4 +#define IO_AWAITING_SUBMIT 5 +#define IO_AWAITING_CLEANUP 6 +#define IO_HANDLE_PAGE_PROT 7
Please use enums instead.
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 23
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ +#define MAX_OUTSTANDING_IO 1024 + +/* + * --------------------------------------------------------------- + * + * IO in progress information storage and helpers + * + * --------------------------------------------------------------- + */
Could we please drop the above banner. Hurts my eyes...
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 27
Quoted 4 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+ +struct io_info { + struct bio * sys_struct; + long block[PAGE_SIZE/512];
You're hardcoding sector size here, no?
Quoted 5 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +5
-0+ struct page * buffer_page; + struct page * data_page; + unsigned long flags; + struct block_device * dev; + struct list_head list;
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 42
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ int readahead_index; + struct work_struct work; +}; + +/* Locks separated to allow better SMP support. + * An io_struct moves through the lists as follows. + * free -> submit_batch -> busy -> ready_for_cleanup -> free + */ +static LIST_HEAD(ioinfo_free); +static spinlock_t ioinfo_free_lock = SPIN_LOCK_UNLOCKED;
Please use DEFINE_SPINLOCK instead. It is preferred as some automatic lock checkers need it.
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 44
Quoted 2 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +2
-0+#define BITS_PER_UL (8 * sizeof(unsigned long)) +static volatile unsigned long suspend_readahead_flags[(MAX_READAHEAD + BITS_PER_UL - 1) / BITS_PER_UL];
<asm/types.h> has BITS_PER_LONG. Use it.
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 47
Quoted 3 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +3
-0+static int suspend_end_bio(struct bio * bio, unsigned int num, int err) +{ + struct io_info *io_info = (struct io_info *) bio->bi_private;
Redundant cast.
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 51
Quoted 4 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+static void suspend_wait_on_readahead(int readahead_index) +{ + int index = readahead_index/(8 * sizeof(unsigned long)); + int bit = readahead_index - index * 8 * sizeof(unsigned long);
Use BITS_PER_LONG here.
Quoted 6 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +6
-0+ + /* read_ahead_index is the one we want to return */ + while (!test_bit(bit, &suspend_readahead_flags[index])) + do_bio_wait(6); +} +
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 67
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+/* + * readahead_done + * + * Returns whether the readahead requested is ready. + */ + +static int suspend_readahead_ready(int readahead_index) +{ + int index = readahead_index/(8 * sizeof(unsigned long)); + int bit = readahead_index - (index * 8 * sizeof(unsigned long));
Ditto.
Quoted 22 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +22
-0+ + return test_bit(bit, &suspend_readahead_flags[index]); +} + +/* suspend_readahead_prepare + * Set up for doing readahead on an image */ +static int suspend_prepare_readahead(int index) +{ + unsigned long new_page = get_zeroed_page(GFP_ATOMIC); + + if(!new_page) + return -ENOMEM; + + suspend_bio_ops.readahead_pages[index] = virt_to_page(new_page); + return 0; +} + +/* suspend_readahead_cleanup + * Clean up structures used for readahead */ +static void suspend_cleanup_readahead(int page) +{ + __free_pages(suspend_bio_ops.readahead_pages[page], 0);
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 99
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ suspend_bio_ops.readahead_pages[page] = 0; + return; +} + +static unsigned long suspend_bio_memory_needed(void) +{ + /* We want to have at least enough memory so as to have 128 I/O + * transactions on the fly at once. If we can to more, fine. */ + return (128 * (PAGE_SIZE + sizeof(struct request) + + sizeof(struct bio) + sizeof(struct io_info)));
Where did the magic 128 come from?
Re: [PATCH] [1/48] Suspend2 2.1.9.8 for 2.6.12: submit_intro
In reply to Nigel CunninghamQuoted 5 lines · Nigel Cunningham
diff -ruNp
300-reboot-handler-hook.patch-old/kernel/sys.c300-reboot-handler-hook.patch-new/kernel/sys.ckernel/sys.c 2005-07-04 23:14:18.000000000 +1000 renamed from kernel/sys.c 2005-06-20 11:47:32.000000000 +1000 +0
-0@@ -436,12 +436,12 @@ asmlinkage long sys_reboot(int magic1, i machine_restart(buffer);
kernel/sys.c 2005-07-04 23:14:18.000000000 +1000 asmlinkage long sys_reboot(int magic1, i · line 444
Quoted 10 lines
kernel/sys.c 2005-07-04 23:14:18.000000000 +1000 renamed from kernel/sys.c 2005-06-20 11:47:32.000000000 +1000 +2
-3break; -#ifdef CONFIG_SOFTWARE_SUSPEND +#ifdef CONFIG_SUSPEND2 case LINUX_REBOOT_CMD_SW_SUSPEND: { - int ret = software_suspend(); + suspend2_try_suspend(); unlock_kernel(); - return ret;
Are both mechanisms intended to live in the kernel? If not, where's the patch to remove the old code?
Hi Nigel,
Quoted 6 lines · Nigel Cunningham
As requested, here are the patches that form Suspend2, for review.
I've tried to split it up into byte size chunks, but please don't expect that these will be patches that can mutate swsusp into Suspend2. That would roughly equivalent to asking for patches that patch Reiser3 into Reiser4 - it's a redesign.
Please consider putting diffstat in the patches. They make navigating large patchsets easier.
Pekka
Re: [PATCH] [16/48] Suspend2 2.1.9.8 for 2.6.12: 406-dynamic-pageflags.patch
In reply to Nigel CunninghamQuoted 60 lines · Nigel Cunningham
arch/i386/power/smp.c +60
-0+ +/* +* Save and restore processor state for secondary processors. +* IRQs (and therefore preemption) are already disabled +* when we enter here (IPI). +*/ + +static volatile int loop __nosavedata; + +void __smp_suspend_lowlevel (void * data) +{ + __asm__("movl %%ecx,%%cr3\n" ::"c" (__pa (swsusp_pg_dir))); + +if (test_suspend_state (SUSPEND_NOW_RESUMING )) { +BUG_ON (!irqs_disabled ()); +kernel_fpu_begin (); + c_loops_per_jiffy_ref[_smp_processor_id ()] = current_cpu_data.loops_per_jiffy; +atomic_inc (&suspend_cpu_counter); + +/* Only image copied back while we spin in this loop. Our +* task info should not be looked at while this is happening +* (which smp_processor_id() will do( */ +while (test_suspend_state (SUSPEND_FREEZE_SMP )) { +cpu_relax (); +barrier (); + } + +while (atomic_read (&suspend_cpu_counter) !=_smp_processor_id ()) { +cpu_relax (); +barrier (); + } + my_saved_context = (unsigned char *) (suspend2_saved_contexts +_smp_processor_id ()); +for (loop =sizeof (struct suspend2_saved_context ); loop--; loop) + *(((unsigned char *) &suspend2_saved_context) + loop -1 ) = *(my_saved_context + loop -1 ); +suspend2_restore_processor_context (); +cpu_clear (_smp_processor_id (),per_cpu (cpu_tlbstate,_smp_processor_id ()).active_mm->cpu_vm_mask); +load_cr3 (swapper_pg_dir); +wbinvd (); +__flush_tlb_all (); + current_cpu_data.loops_per_jiffy = c_loops_per_jiffy_ref[_smp_processor_id ()]; +mtrr_restore_one_cpu (); +atomic_dec (&suspend_cpu_counter); + }else {/* suspending */ +BUG_ON (!irqs_disabled ()); +/* +*Save context and go back to idling. +* Note that we cannot leave the processor +* here. It must be able to receive IPIs if +* the LZF compression driver (eg) does a +* vfree after compressing the kernel etc +*/ +while (test_suspend_state (SUSPEND_FREEZE_SMP ) && + (atomic_read (&suspend_cpu_counter) != (_smp_processor_id () -1 ))) { +cpu_relax (); +barrier (); + } +suspend2_save_processor_context (); + my_saved_context = (unsigned char *) (suspend2_saved_contexts +_smp_processor_id ()); +for (loop =sizeof (struct suspend2_saved_context ); loop--; loop) + *(my_saved_context + loop -1 ) = *(((unsigned char *) &suspend2_saved_context) + loop -1 );
arch/i386/power/smp.c line 83
Quoted 10 lines
arch/i386/power/smp.c +10
-0+atomic_inc (&suspend_cpu_counter); +/* Now spin until the atomic copy of the kernel is made. */ +while (test_suspend_state (SUSPEND_FREEZE_SMP )) { +cpu_relax (); +barrier (); + } +atomic_dec (&suspend_cpu_counter); +kernel_fpu_end (); + } +}
we are using cpu hotplug for S3 & S4 SMP to avoid nasty deadlocks. Could this be avoided in suspend2 SMP?
Thanks,
Shaohua
Re: [PATCH] [11/48] Suspend2 2.1.9.8 for 2.6.12: 401-e820-table-support.patch
In reply to Nigel CunninghamHi!
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
arch/i386/kernel/cpu/mtrr/main.c +0
-0@@ -560,7 +559,7 @@ struct mtrr_value {static struct mtrr_value * mtrr_state;Quoted 10 lines
arch/i386/kernel/cpu/mtrr/main.c static int mtrr_save(struct sys_device * · line 580
Quoted 8 lines
arch/i386/kernel/cpu/mtrr/main.c +1
-1-static int mtrr_save (struct sys_device * sysdev,u32 state) +int mtrr_save (void ) {int i;int size = num_var_ranges *sizeof (struct mtrr_value );@@ -580,28 +579,27 @@ static int mtrr_save(struct sys_device *return 0 ; }Isn't this covered by Shaohua Li's patch?
Quoted 3 lines
I believe so, but Shaohua Li's patch isn't merged in 2.6.12 (is it yet at all). This is the solution I've been using for... can't remember how long.
I *think* it is in -mm already.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch
In reply to Nigel CunninghamHi!
Quoted 13 lines
diff -ruNp
353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.cmm/highmem.c +1
-0@@ -26,6 +26,7 @@#include <linux/init.h> #include <linux/hash.h> #include <linux/highmem.h> +#include <linux/suspend.h> #include <asm/tlbflush.h> static mempool_t *page_pool, *isa_page_pool;@@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)
mm/highmem.c static void flush_all_zero_pkmaps(void) · line 105
Quoted 10 lines
mm/highmem.c +4
-1set_page_address (page,NULL ); } -flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); +if (test_suspend_state (SUSPEND_FREEZE_SMP )) +__flush_tlb (); +else +flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); }static inline unsigned long map_new_virtual (struct page *page)
Take a look at cpu hotplug system, it is cleaner way of doing this...
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Quoted 6 lines · Nigel Cunningham
As requested, here are the patches that form Suspend2, for review.
I've tried to split it up into byte size chunks, but please don't expect that these will be patches that can mutate swsusp into Suspend2. That would roughly equivalent to asking for patches that patch Reiser3 into Reiser4 - it's a redesign.
It still has quite a big impact outside kernel/power :-(.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Hi!
Quoted 10 lines
As requested, here are the patches that form Suspend2, for review.
I've tried to split it up into byte size chunks, but please don't expect that these will be patches that can mutate swsusp into Suspend2. That would roughly equivalent to asking for patches that patch Reiser3 into Reiser4 - it's a redesign.
There are a few extra patches not included here, all of which are not core to Suspend2. Since I'm not expecting this code to get merged as is, I haven't worried about including them. If that's a problem, let me know.
Is swsusp1 expected to be functional after these are applied? You removed *some* of its hooks, but not all, so I'm confused.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [1/48] Suspend2 2.1.9.8 for 2.6.12: submit_intro
In reply to Nigel CunninghamQuoted 8 lines · Nigel Cunningham
diff -ruNp
300-reboot-handler-hook.patch-old/kernel/sys.c300-reboot-handler-hook.patch-new/kernel/sys.ckernel/sys.c +0
-1@@ -436,12 +436,12 @@ asmlinkage long sys_reboot(int magic1, imachine_restart (buffer);break ; -#ifdef CONFIG_SOFTWARE_SUSPEND
kernel/sys.c asmlinkage long sys_reboot(int magic1, i · line 446
Quoted 10 lines
kernel/sys.c +3
-2+#ifdef CONFIG_SUSPEND2 case LINUX_REBOOT_CMD_SW_SUSPEND : { -int ret =software_suspend (); +suspend2_try_suspend ();unlock_kernel (); -return ret; +return 0 ; }#endif
It would be nice to return meaningfull error code when something fails...
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [16/48] Suspend2 2.1.9.8 for 2.6.12: 406-dynamic-pageflags.patch
In reply to Shaohua LiHi.
Quoted 2 lines · Shaohua Li
we are using cpu hotplug for S3 & S4 SMP to avoid nasty deadlocks. Could this be avoided in suspend2 SMP?
I haven't had any problems with this code but yes, I do want to switch to using hotplug. It's only in -mm, not mainline?
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [14/48] Suspend2 2.1.9.8 for 2.6.12: 404-check-mounts-support.patch
In reply to Nigel Cunninghammm/swapfile.c asmlinkage long sys_swapoff(const char _ · line 1168
Quoted 11 lines · Nigel Cunningham
diff -ruNp
405-clear-swapfile-bdev-in-swapoff.patch-old/mm/swapfile.c405-clear-swapfile-bdev-in-swapoff.patch-new/mm/swapfile.cmm/swapfile.c +1
-0@@ -1162,6 +1162,7 @@ asmlinkage long sys_swapoff(const char _ swap_file = p->swap_file; p->swap_file =NULL ; p->max =0 ; + p->bdev =NULL ; swap_map = p->swap_map; p->swap_map =NULL ; p->flags =0 ;
I guess some explanation is needed here; and if it is bugfix it should just go in...
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [16/48] Suspend2 2.1.9.8 for 2.6.12: 406-dynamic-pageflags.patch
In reply to Nigel CunninghamQuoted 8 lines · Nigel Cunningham
Hi.
Quoted 2 lines · Shaohua Li
we are using cpu hotplug for S3 & S4 SMP to avoid nasty deadlocks. Could this be avoided in suspend2 SMP?
I haven't had any problems with this code but yes, I do want to switch to using hotplug. It's only in -mm, not mainline?
It's in base kernel now.
Thanks,
Shaohua
Re: [PATCH] [4/48] Suspend2 2.1.9.8 for 2.6.12: 302-init-hooks.patch
In reply to Nigel Cunninghamdrivers/acpi/osl.c acpi_os_initialize1(void) · line 99
Quoted 10 lines · Nigel Cunningham
diff -ruNp
350-workthreads.patch-old/drivers/acpi/osl.c350-workthreads.patch-new/drivers/acpi/osl.cdrivers/acpi/osl.c +1
-1@@ -95,7 +95,7 @@ acpi_os_initialize1(void) return AE_NULL_ENTRY; }#endif - kacpid_wq =create_singlethread_workqueue ("kacpid" ); + kacpid_wq =create_singlethread_workqueue ("kacpid" ,PF_NOFREEZE );BUG_ON (!kacpid_wq);
I'm not sure but kacpid can run any kind of code (depends on BIOS, it might touch some devices), is this safe?
Thanks,
Shaohua
Re: [PATCH] [14/48] Suspend2 2.1.9.8 for 2.6.12: 404-check-mounts-support.patch
In reply to Pavel MachekHi.
Sorry.
It's not really a bug in the swapoff code. Rather, clearing this field allows simple identification of the devices being used for swap (for flushing writes).
Regards,
Nigel
Quoted 16 lines · Pavel Machek
mm/swapfile.c asmlinkage long sys_swapoff(const char _ · line 1168
Quoted 11 lines · Nigel Cunningham
diff -ruNp
405-clear-swapfile-bdev-in-swapoff.patch-old/mm/swapfile.c405-clear-swapfile-bdev-in-swapoff.patch-new/mm/swapfile.cmm/swapfile.c +1
-0@@ -1162,6 +1162,7 @@ asmlinkage long sys_swapoff(const char _ swap_file = p->swap_file; p->swap_file =NULL ; p->max =0 ; + p->bdev =NULL ; swap_map = p->swap_map; p->swap_map =NULL ; p->flags =0 ;I guess some explanation is needed here; and if it is bugfix it should just go in...
Pavel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Hi.
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
As requested, here are the patches that form Suspend2, for review.
I've tried to split it up into byte size chunks, but please don't expect that these will be patches that can mutate swsusp into Suspend2. That would roughly equivalent to asking for patches that patch Reiser3 into Reiser4 - it's a redesign.
Quoted 6 lines
Quoted 3 lines
There are a few extra patches not included here, all of which are not core to Suspend2. Since I'm not expecting this code to get merged as is, I haven't worried about including them. If that's a problem, let me know.
Is swsusp1 expected to be functional after these are applied? You removed *some* of its hooks, but not all, so I'm confused.
It should definitely still be functional.
In the past I've gone with the logic that if people go to the trouble of patching suspend2 in, they probably want to use it instead of swsusp. I'm happy for the reboot and acpi patches to be left out for now.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [4/48] Suspend2 2.1.9.8 for 2.6.12: 302-init-hooks.patch
In reply to Shaohua LiHi.
Quoted 13 lines · Shaohua Li
drivers/acpi/osl.c acpi_os_initialize1(void) · line 99
Quoted 10 lines · Nigel Cunningham
diff -ruNp
350-workthreads.patch-old/drivers/acpi/osl.c350-workthreads.patch-new/drivers/acpi/osl.cdrivers/acpi/osl.c +1
-1@@ -95,7 +95,7 @@ acpi_os_initialize1(void) return AE_NULL_ENTRY; }#endif - kacpid_wq =create_singlethread_workqueue ("kacpid" ); + kacpid_wq =create_singlethread_workqueue ("kacpid" ,PF_NOFREEZE );BUG_ON (!kacpid_wq);I'm not sure but kacpid can run any kind of code (depends on BIOS, it might touch some devices), is this safe?
If it's not, then we definitely want this patch as all workqueues are NOFREEZE at the moment.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch
In reply to Nigel CunninghamQuoted 12 lines · Nigel Cunningham
diff -ruNp
353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.cmm/highmem.c +1
-0@@ -26,6 +26,7 @@#include <linux/init.h> #include <linux/hash.h> #include <linux/highmem.h> +#include <linux/suspend.h> #include <asm/tlbflush.h> static mempool_t *page_pool, *isa_page_pool;
mm/highmem.c static void flush_all_zero_pkmaps(void) · line 100
Quoted 6 lines
mm/highmem.c +2
-1@@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)set_page_address (page,NULL ); } -flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); +if (test_suspend_state (SUSPEND_FREEZE_SMP )) +__flush_tlb ();
On ARM SMP, if you want the "local" version, the flush functions are prefixed by "local_", though I guess we can also define a __flush_tlb() for compatibility if someone wants to use swsusp with ARM SMP.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [PATCH] [45/48] Suspend2 2.1.9.8 for 2.6.12: 621-swsusp-tidy.patch
In reply to Nigel Cunninghamkernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines · Nigel Cunningham
diff -ruNp
622-swapwriter.patch-old/kernel/power/suspend_swap.c622-swapwriter.patch-new/kernel/power/suspend_swap.ckernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +7
-0+/* + * --------------------------------------------------------------- + * + * Internal Data Structures + * + * --------------------------------------------------------------- + */
Can we please tone down this banner?
Quoted 14 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +14
-0+struct { + /* Extent chains for swap & blocks */ + struct extentchain swapextents; + struct extentchain block_chain[MAX_SWAPFILES]; + + /* Location of start of pagedir 1 */ + struct extent * pd1start_block_extent; + int pd1start_chain; + int pd1start_extent_number; + unsigned long pd1start_block_offset; + + /* Devices used for swap */ + dev_t swapdevs[MAX_SWAPFILES]; + char blocksizes[MAX_SWAPFILES];
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ +} header_data; + +static dev_t header_device = 0; +static struct block_device * header_block_device = NULL; +static int headerblocksize = PAGE_SIZE; +static int headerblock; + +/* For swapfile automatically swapon/off'd. */ +static char swapfilename[256] = "";
<linux/suspend.h> already has SWAP_FILENAME_MAXLENGTH. Use that.
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 11 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +11
-0+extern asmlinkage long sys_swapon(const char * specialfile, int swap_flags); +extern asmlinkage long sys_swapoff(const char * specialfile); +static int suspend_swapon_status = 0; + +/* + * --------------------------------------------------------------- + * + * Current state. + * + * --------------------------------------------------------------- + */
Could we please tone down this banner?
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 5 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +5
-0+ +/* Which pagedir are we saving/reloading? Needed so we can know whether to + * remember the last swap entry used at the end of writing pageset2, and + * get that location when saving or reloading pageset1.*/ +static int current_stream = 0;
No need to set to zero. The compiler will do it for you.
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 11 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +11
-0+ +/* Pointer to current swap entry being loaded/saved. */ +static struct extent * currentblockextent = NULL; +static unsigned long currentblockoffset = 0; +static int currentblockchain = 0; +static int currentblocksperpage = 0; + +/* Header Page Information */ +static int header_pages_allocated = 0; +static struct submit_params * first_header_submit_info = NULL, + * last_header_submit_info = NULL, * current_header_submit_info = NULL;
Ditto. (applies to NULL as well)
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 11 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +11
-0+static void get_header_params(struct submit_params * headerpage) +{ + swp_entry_t entry = headerpage->swap_address; + int swapfilenum = swp_type(entry); + unsigned long offset = swp_offset(entry); + struct swap_info_struct * sis = get_swap_info_struct(swapfilenum); + sector_t sector = map_swap_page(sis, offset); + + headerpage->dev = sis->bdev, + headerpage->block[0] = sector; + //headerpage->blocks_used = 1;
Please drop commented out code.
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 5 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +5
-0+static int try_to_open_resume_device(void) +{ + resume_block_device = open_by_devnum(resume_device, FMODE_READ); + + if (IS_ERR(resume_block_device) || (!resume_block_device))
The second set of parenthesis are redundant.
Quoted 8 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +8
-0+ /* + * Put bdev of suspend header in last byte of swap header + * (unsigned short) + */ + if (type > 11) { + dev_t * header_ptr = (dev_t *) &header[1]; + unsigned char * headerblocksize_ptr = + (unsigned char *) &header[5];
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ unsigned long * headerblock_ptr = (unsigned long *) &header[6]; + header_device = *header_ptr; + /* + * We are now using the highest bit of the char to indicate + * whether we have attempted to resume from this image before. + */ + clear_suspend_state(SUSPEND_RESUMED_BEFORE); + if (((int) *headerblocksize_ptr) & 0x80) + set_suspend_state(SUSPEND_RESUMED_BEFORE); + headerblocksize = 512 * (((int) *headerblocksize_ptr) & 0xf);
Hardcoded sector size?
Quoted 4 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+ + /* Restore device info */ + for (i = 0; i < MAX_SWAPFILES; i++) { + dev_t thisdevice = header_data.swapdevs[i];
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ + swap_info[i].bdev = NULL; + + if (!thisdevice) + continue; + + if (thisdevice == resume_device) { + swap_info[i].bdev = resume_block_device; + /* Mark as used so the device doesn't get suspended. */ + swap_info[i].swap_file = (struct file *) 0xffffff;
Please use constants instead of magic numbers.
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 9 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +9
-0+static int swapwriter_write_init(int stream_number) +{ + current_stream = stream_number; + + if (current_stream == 1) { + currentblockextent = header_data.pd1start_block_extent; + currentblockoffset = header_data.pd1start_block_offset; + currentblockchain = header_data.pd1start_chain; + } else
See below.
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 9 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +9
-0+ for (currentblockchain = 0; currentblockchain < MAX_SWAPFILES; + currentblockchain++) + if (header_data.block_chain[currentblockchain].first) { + currentblockextent = + header_data. + block_chain[currentblockchain].first; + currentblockoffset = currentblockextent->minimum; + break; + }
Braces would make sense here.
Quoted 52 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +52
-0+ + currentblocksperpage = get_blocks_per_page(currentblockchain); + + suspend_bio_ops.reset_io_stats(); + + return 0; +} + +static int swapwriter_write_chunk(struct page * buffer_page) +{ + int i; + struct submit_params submit_params; + + if (TEST_ACTION_STATE(SUSPEND_TEST_FILTER_SPEED)) + return 0; + + if (currentblockchain == MAX_SWAPFILES) { + printk("Error! We have run out of blocks for writing data.\n"); + return -ENOSPC; + } + + if (!currentblockextent) { + do { + currentblockchain++; + } while ((currentblockchain < MAX_SWAPFILES) && + (!header_data.block_chain[currentblockchain].first)); + + /* We can validly not have a new blockextent. We + * might be compressing data and the user was + * too optimistic in setting the compression + * ratio or we're just copying the pageset. */ + + if (currentblockchain == MAX_SWAPFILES) { + printk("Argh. Ran out of block chains.\n"); + return -ENOSPC; + } + + currentblockextent = + header_data.block_chain[currentblockchain].first; + currentblockoffset = currentblockextent->minimum; + currentblocksperpage = get_blocks_per_page(currentblockchain); + } + + submit_params.readahead_index = -1; + submit_params.page = buffer_page; + submit_params.dev = swap_info[currentblockchain].bdev; + + /* Get the blocks */ + submit_params.block[0] = currentblockoffset; + for (i = 0; i < currentblocksperpage; i++) + GET_EXTENT_NEXT(currentblockextent, currentblockoffset); +
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ suspend_bio_ops.submit_io(WRITE, &submit_params, 0); + + check_shift_keys(0, NULL); + + return 0; +} + +static int swapwriter_write_cleanup(void) +{ + if (current_stream == 2) {
Where did that magic number two come from?
Quoted 7 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +7
-0+ header_data.pd1start_block_extent = currentblockextent; + header_data.pd1start_block_offset = currentblockoffset; + header_data.pd1start_chain = currentblockchain; + } + + suspend_bio_ops.finish_all_io(); +
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ suspend_bio_ops.check_io_stats(); + + return 0; +} + +static int swapwriter_read_init(int stream_number) +{ + current_stream = stream_number; + + if (current_stream == 1) {
Ditto.
Quoted 5 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +5
-0+static int swapwriter_parse_image_location(char * commandline, int only_writer) +{ + char *thischar, *devstart = NULL, *colon = NULL, *at_symbol = NULL; + union p_diskpage diskpage; + int signature_found, result = -EINVAL, temp_result;
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ + if (strncmp(commandline, "swap:", 5)) { + if (!only_writer) + return 1; + } else + commandline += 5; + + devstart = thischar = commandline; + while ((*thischar != ':') && (*thischar != '@') && + ((thischar - commandline) < 250) && (*thischar))
What's the magic 250 here?
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 9 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +9
-0+ thischar++; + + if (*thischar == ':') { + colon = thischar; + *colon = 0; + thischar++; + } + + while ((*thischar != '@') && ((thischar - commandline) < 250) && (*thischar))
And here?
Quoted 6 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +6
-0+ thischar++; + + if (*thischar == '@') { + at_symbol = thischar; + *at_symbol = 0; + }
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend_swap.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_swap.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ + if (colon) + resume_firstblock = (int) simple_strtoul(colon + 1, NULL, 0); + else + resume_firstblock = 0; + + if (at_symbol) { + resume_firstblocksize = (int) simple_strtoul(at_symbol + 1, NULL, 0); + if (resume_firstblocksize & 0x1FF) + printk("Swapwriter: Blocksizes are usually a multiple of 512. Don't expect this to work!\n");
Then why do we allow it?
Re: [PATCH] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch
In reply to Pekka EnbergRequested changes applied.
Thanks!
Nigel
Quoted 113 lines · Pekka Enberg
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 2
Quoted 6 lines · Nigel Cunningham
diff -ruNp
520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend2.h520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend2.hinclude/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +2
-0@@ -0,0 +1,432 @@ +#undef inline +#define inline __inline__ __attribute__((always_inline))Please drop this macro. <
linux/compiler.h> takes care of it already.Quoted 13 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +13
-0+ +/* image of the saved processor states */ +struct suspend2_saved_context { + unsigned long eax, ebx, ecx, edx; + unsigned long esp, ebp, esi, edi; + unsigned long r8, r9, r10, r11; + unsigned long r12, r13, r14, r15; + +#if 0 + u16 es, fs, gs, ss; + u32 cr0, cr2, cr3, cr4; + u16 gdt_pad; + u16 gdt_limit;include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 25
Quoted 10 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +10
-0+ u32 gdt_base; + u16 idt_pad; + u16 idt_limit; + u32 idt_base; + u16 ldt; + u16 tss; + u32 tr; + u32 safety; + u32 return_address; +#endifPlease drop the #ifdef
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 29
Quoted 4 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +4
-0+ unsigned long eflags; +} __attribute__((packed)); + +extern struct suspend2_saved_context suspend2_saved_context; /* temporary storage */Please move the comment above the declaration (looks as if you're breaking 80 columns).
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 39
Quoted 10 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +10
-0+ +#ifdef CONFIG_MTRR +/* MTRR functions */ +extern int mtrr_save(void); +extern int mtrr_restore_one_cpu(void); +extern void mtrr_restore_finish(void); +#else +#define mtrr_save() do { } while(0) +#define mtrr_restore_one_cpu() do { } while(0) +#define mtrr_restore_finish() do { } while(0)Empty static inline functions are preferred.
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 44
Quoted 5 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +5
-0+#endif + +#ifndef CONFIG_SMP +#undef cpu_clear +#define cpu_clear(a, b) do { } while(0)Same here.
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 47
Quoted 3 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +3
-0+#endif + +extern struct suspend2_saved_context suspend2_saved_context; /* temporary storage */Move comment up.
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 53
Quoted 6 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +6
-0+static void fix_processor_context(void) +{ + int nr = _smp_processor_id(); + struct tss_struct * t = &per_cpu(init_tss,nr); + + set_tss_desc(nr,t); /* This just modifies memory; should not be neccessary. But... This is neccessary, because 386 hardware has concept of busy tsc or some similar stupidity. */Please move comment before function call and indent it properly.
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 line 60
Quoted 7 lines
include/asm-x86_64/suspend2.h 2005-07-05 23:56:15.000000000 +1000 renamed from include/asm-x86_64/suspend2.h 1970-01-01 10:00:00.000000000 +1000 +7
-0+/* + * END of IRQ affinity code, based on LKCD code. + * ----------------------------------------------------------------- + */ +#else +#define save_and_set_irq_affinity() do { } while(0) +#define reset_irq_affinity() do { } while(0)Empty static inlines please.
include/asm-x86_64/suspend.h 2005-07-04 23:14:19.000000000 +1000 extern unsigned long saved_context_eflag · line 46
Quoted 9 lines
diff -ruNp
520-version-specific-x86_64.patch-old/include/asm-x86_64/suspend.h520-version-specific-x86_64.patch-new/include/asm-x86_64/suspend.hinclude/asm-x86_64/suspend.h 2005-07-04 23:14:19.000000000 +1000 renamed from include/asm-x86_64/suspend.h 2005-06-20 11:47:28.000000000 +1000 +1
-1@@ -43,7 +43,7 @@ extern unsigned long saved_context_eflag : /* no output */ \ :"r" ((thread)->debugreg##register)) -extern void fix_processor_context(void); +/* extern void fix_processor_context(void); */Please drop commented out code.
Quoted 10 lines
include/asm-x86_64/suspend.h 2005-07-04 23:14:19.000000000 +1000 renamed from include/asm-x86_64/suspend.h 2005-06-20 11:47:28.000000000 +1000 +0
-1#ifdef CONFIG_ACPI_SLEEP extern unsigned long saved_eip; -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [41/48] Suspend2 2.1.9.8 for 2.6.12: 617-proc.patch
In reply to Nigel Cunninghamkernel/power/suspend2_core/suspend.c line 377
Quoted 4 lines · Nigel Cunningham
diff -ruNp
618-core.patch-old/kernel/power/suspend2_core/suspend.c618-core.patch-new/kernel/power/suspend2_core/suspend.c
---618-core.patch-old/kernel/power/suspend2_core/suspend.c1970-01-01kernel/power/suspend2_core/suspend.c +2
-0+#define SNPRINTF(a...) len += suspend_snprintf(debug_info_buffer + len, \ + PAGE_SIZE - len - 1, ## a)
Please don't introduce subsystem specific wrappers for generic string manipulation functions. Put them to lib/.
Pekka
Re: [PATCH] [2/48] Suspend2 2.1.9.8 for 2.6.12: 300-reboot-handler-hook.patch
In reply to Nigel CunninghamQuoted 4 lines · Nigel Cunningham
diff -ruNp
301-proc-acpi-sleep-activate-hook.patch-old/drivers/acpi/sleep/proc.c301-proc-acpi-sleep-activate-hook.patch-new/drivers/acpi/sleep/proc.c
drivers/acpi/sleep/proc.c 2005-07-04 23:14:18.000000000 +1000 acpi_system_write_sleep ( · line 77
Quoted 10 lines
drivers/acpi/sleep/proc.c 2005-07-04 23:14:18.000000000 +1000 renamed from drivers/acpi/sleep/proc.c 2005-06-20 11:46:50.000000000 +1000 +7
-0@@ -68,6 +68,17 @@ acpi_system_write_sleep ( goto Done; } state = simple_strtoul(str, NULL, 0); +#ifdef CONFIG_SUSPEND2 + /* + * I used to put this after the CONFIG_SOFTWARE_SUSPEND + * test, but people who compile in suspend2 usually want + * to use it instead of swsusp. --NC + */ + if (state == 4) {
enum for states instead of magics, please.
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Nigel CunninghamQuoted 13 lines · Nigel Cunningham
diff -ruNp
625-crypto-api-work.patch-old/crypto/lzf.c625-crypto-api-work.patch-new/crypto/lzf.ccrypto/lzf.c 2005-07-05 23:57:15.000000000 +1000 renamed from crypto/lzf.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+static int lzf_compress(void * context, const u8 *in_data, unsigned int in_len, + u8 *out_data, unsigned int *out_len) +{ + struct lzf_ctx * ctx = (struct lzf_ctx *) context; + const u8 **htab = ctx->hbuf; + const u8 **hslot; + const u8 *ip = in_data; + u8 *op = out_data; + const u8 *in_end = ip + in_len; + u8 *out_end = op + *out_len - 3;
crypto/lzf.c 2005-07-05 23:57:15.000000000 +1000
Quoted 10 lines
crypto/lzf.c 2005-07-05 23:57:15.000000000 +1000 renamed from crypto/lzf.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ const u8 *ref; + + unsigned int hval = FRST (ip); + unsigned long off; + int lit = 0; + + if (ctx->first_call) { + ctx->first_call = 0; + } +#if INIT_HTAB
[snip, snip]
scripts/Lindent, please.
Re: [PATCH] [34/48] Suspend2 2.1.9.8 for 2.6.12: 610-extent.patch
In reply to Nigel Cunninghamkernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 line 5
Quoted 9 lines · Nigel Cunningham
diff -ruNp
611-io.patch-old/kernel/power/suspend2_core/io.c611-io.patch-new/kernel/power/suspend2_core/io.ckernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +5
-0@@ -0,0 +1,1006 @@ +/* + * kernel/power/io.c + * + * Copyright (C) 1998-2001 Gabor Kuti <[email protected]> + * Copyright (C) 1998,2001,2002 Pavel Machek <[email protected]>
^
Whitespace damage (appears elsewhere too).
Quoted 3 lines
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +3
-0+ * Copyright (C) 2002-2003 Florent Chabaud <[email protected]> + * Copyright (C) 2002-2005 Nigel Cunningham <[email protected]> + *
[snip]
Quoted 26 lines
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +26
-0+ pc = size / 5; + + /* Write the data */ + for (i=0; i<size; i++) { + int was_mapped = 0; + struct page * page = pfn_to_page(current_page_index); + + /* Status update */ + if ((i+base) >= nextupdate) + nextupdate = suspend2_update_status(i + base, barmax, + " %d/%d MB ", MB(base+i+1), MB(barmax)); + + if ((i + 1) == pc) { + printk("%d%%...", 20 * step); + step++; + pc = size * step / 5; + } + + /* Write */ + was_mapped = suspend_map_kernel_page(page, 1); + ret = first_filter->ops.filter.write_chunk(page); + if (!was_mapped) + suspend_map_kernel_page(page, 0); + + if (ret) { + printk("Write chunk returned %d.\n", ret);
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ abort_suspend("Failed to write a chunk of the " + "image."); + error = -1; + goto write_pageset_free_buffers; + } + + /* Interactivity */ + check_shift_keys(0, NULL); + + if (TEST_RESULT_STATE(SUSPEND_ABORTED)) {
Why is the above in upper case but test_action_state is in lower case?
Quoted 109 lines
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +109
-0+ abort_suspend("Aborting as requested."); + error = -1; + goto write_pageset_free_buffers; + } + + /* Prepare next */ + current_page_index = __get_next_bit_on(*pageflags, current_page_index); + } + + printk("done.\n"); + + suspend2_update_status(base+size, barmax, " %d/%d MB ", + MB(base+size), MB(barmax)); + +write_pageset_free_buffers: + + /* Cleanup other plugins */ + list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) { + if (this_plugin->disabled) + continue; + if ((this_plugin->type == FILTER_PLUGIN) || + (this_plugin->type == WRITER_PLUGIN)) + continue; + if (this_plugin->write_cleanup) + this_plugin->write_cleanup(); + } + + /* Flush data and cleanup */ + list_for_each_entry(this_plugin, &suspend_filters, ops.filter.filter_list) { + if (this_plugin->disabled) + continue; + if (this_plugin->write_cleanup) + this_plugin->write_cleanup(); + } + active_writer->write_cleanup(); + + /* Statistics */ + end_time = jiffies; + + if ((end_time - start_time) && (!TEST_RESULT_STATE(SUSPEND_ABORTED))) { + suspend_io_time[0][0] += size, + suspend_io_time[0][1] += (end_time - start_time); + } + + return error; +} + +/* read_pageset() + * + * Description: Read a pageset from disk. + * Arguments: pagedir: Pointer to the pagedir to be saved. + * whichtowrite: Controls what debugging output is printed. + * overwrittenpagesonly: Whether to read the whole pageset or + * only part. + * Returns: Zero on success or -1 on failure. + */ + +static int read_pageset(struct pagedir * pagedir, int whichtoread, + int overwrittenpagesonly) +{ + int nextupdate = 0, result = 0, base = 0; + int start_time, end_time, finish_at = pagedir->pageset_size; + int barmax = pagedir1.pageset_size + pagedir2.pageset_size; + int i, pc, step = 1; + struct suspend_plugin_ops * this_plugin, * first_filter = get_next_filter(NULL); + dyn_pageflags_t *pageflags; + int current_page_index; + + if (whichtoread == 1) { + suspend2_prepare_status(1, 1, "Reading kernel & process data..."); + pageflags = &pageset1_copy_map; + } else { + suspend2_prepare_status(1, 0, "Reading caches..."); + if (overwrittenpagesonly) + barmax = finish_at = min(pageset1_size, pageset2_size); + else { + base = pagedir1.pageset_size; + } + pageflags = &pageset2_map; + } + + start_time=jiffies; + + /* Initialise page transformers */ + list_for_each_entry(this_plugin, &suspend_filters, ops.filter.filter_list) { + if (this_plugin->disabled) + continue; + if (this_plugin->read_init && + this_plugin->read_init(whichtoread)) { + abort_suspend("Failed to initialise a filter."); + result = 1; + goto read_pageset_free_buffers; + } + } + + /* Initialise writer */ + if (active_writer->read_init(whichtoread)) { + abort_suspend("Failed to initialise the writer."); + result = 1; + goto read_pageset_free_buffers; + } + + /* Initialise other plugins */ + list_for_each_entry(this_plugin, &suspend_plugins, plugin_list) { + if (this_plugin->disabled) + continue; + if ((this_plugin->type == FILTER_PLUGIN) || + (this_plugin->type == WRITER_PLUGIN)) + continue;
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000
Quoted 10 lines
kernel/power/suspend2_core/io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ if (this_plugin->read_init) + if (this_plugin->read_init(whichtoread)) { + SET_RESULT_STATE(SUSPEND_ABORTED); + goto read_pageset_free_buffers; + } + } + + current_page_index = __get_next_bit_on(*pageflags, -1); + + pc = finish_at / 5;
What's the magic number 5 that pops up everywhere?
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Pekka EnbergHi.
Thanks very much for all your reading and commenting. I really appreciate it. By the way, you do want replies sent to both addresses?
This one is contributed code. I haven't had or needed an update since it was added though, so I guess I could reindent it. Will do.
Regards,
Nigel
Quoted 29 lines · Pekka Enberg
Quoted 13 lines · Nigel Cunningham
diff -ruNp
625-crypto-api-work.patch-old/crypto/lzf.c625-crypto-api-work.patch-new/crypto/lzf.ccrypto/lzf.c 2005-07-05 23:57:15.000000000 +1000 renamed from crypto/lzf.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+static int lzf_compress(void * context, const u8 *in_data, unsigned int in_len, + u8 *out_data, unsigned int *out_len) +{ + struct lzf_ctx * ctx = (struct lzf_ctx *) context; + const u8 **htab = ctx->hbuf; + const u8 **hslot; + const u8 *ip = in_data; + u8 *op = out_data; + const u8 *in_end = ip + in_len; + u8 *out_end = op + *out_len - 3;crypto/lzf.c 2005-07-05 23:57:15.000000000 +1000
Quoted 10 lines
crypto/lzf.c 2005-07-05 23:57:15.000000000 +1000 renamed from crypto/lzf.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ const u8 *ref; + + unsigned int hval = FRST (ip); + unsigned long off; + int lit = 0; + + if (ctx->first_call) { + ctx->first_call = 0; + } +#if INIT_HTAB[snip, snip]
scripts/Lindent, please.
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [32/48] Suspend2 2.1.9.8 for 2.6.12: 609-driver-model.patch
In reply to Nigel Cunninghamkernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000
Quoted 7 lines · Nigel Cunningham
diff -ruNp
610-encryption.patch-old/kernel/power/suspend2_core/encryption.c610-encryption.patch-new/kernel/power/suspend2_core/encryption.ckernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000 renamed from kernel/power/suspend2_core/encryption.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+static inline void free_local_buffer(void) +{ + if (page_buffer) + free_pages((unsigned long) page_buffer, 0);
Use free_page(), please.
Re: [PATCH] [26/48] Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch
In reply to Nigel CunninghamQuoted 54 lines · Nigel Cunningham
diff -ruNp
604-utility-header.patch-old/kernel/power/suspend2_core/utility.c604-utility-header.patch-new/kernel/power/suspend2_core/utility.ckernel/power/suspend2_core/utility.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/utility.c 1970-01-01 10:00:00.000000000 +1000 +46
-0@@ -0,0 +1,46 @@ +/* + * kernel/power/utility.c + * + * Copyright (C) 2004-2005 Nigel Cunningham <[email protected]> + * + * This file is released under the GPLv2. + * + * Routines that only suspend uses at the moment, but which might move + * when we merge because they're generic. + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mm.h> +#include <linux/proc_fs.h> +#include <asm/string.h> + +#include "pageflags.h" + +/* + * suspend_snprintf + * + * Functionality : Print a string with parameters to a buffer of a + * limited size. Unlike vsnprintf, we return the number + * of bytes actually put in the buffer, not the number + * that would have been put in if it was big enough. + */ +int suspend_snprintf(char * buffer, int buffer_size, const char *fmt, ...) +{ + int result; + va_list args; + + if (!buffer_size) { + return 0; + } + + va_start(args, fmt); + result = vsnprintf(buffer, buffer_size, fmt, args); + va_end(args); + + if (result > buffer_size) { + return buffer_size; + } + + return result; +}diff -ruNp
604-utility-header.patch-old/kernel/power/suspend2_core/utility.h604-utility-header.patch-new/kernel/power/suspend2_core/utility.h
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 line 10
Quoted 10 lines
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/utility.h 1970-01-01 10:00:00.000000000 +1000 +10
-0@@ -0,0 +1,12 @@ +/* + * kernel/power/suspend2_core/utility.h + * + * Copyright (C) 2004-2005 Nigel Cunningham <[email protected]> + * + * This file is released under the GPLv2. + * + * Routines that only suspend uses at the moment, but which might move + * when we merge because they're generic. + */
Please do move these.
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 line 12
Quoted 2 lines
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/utility.h 1970-01-01 10:00:00.000000000 +1000 +2
-0+ +extern int suspend_snprintf(char * buffer, int buffer_size, const char *fmt, ...);
What's wrong with regular snprintf?
Pekka
Re: [PATCH] [2/48] Suspend2 2.1.9.8 for 2.6.12: 300-reboot-handler-hook.patch
In reply to Pekka EnbergHi.
Quoted 17 lines · Pekka Enberg
Quoted 4 lines · Nigel Cunningham
diff -ruNp
301-proc-acpi-sleep-activate-hook.patch-old/drivers/acpi/sleep/proc.c301-proc-acpi-sleep-activate-hook.patch-new/drivers/acpi/sleep/proc.cdrivers/acpi/sleep/proc.c 2005-07-04 23:14:18.000000000 +1000 acpi_system_write_sleep ( · line 77
Quoted 10 lines
drivers/acpi/sleep/proc.c 2005-07-04 23:14:18.000000000 +1000 renamed from drivers/acpi/sleep/proc.c 2005-06-20 11:46:50.000000000 +1000 +7
-0@@ -68,6 +68,17 @@ acpi_system_write_sleep ( goto Done; } state = simple_strtoul(str, NULL, 0); +#ifdef CONFIG_SUSPEND2 + /* + * I used to put this after the CONFIG_SOFTWARE_SUSPEND + * test, but people who compile in suspend2 usually want + * to use it instead of swsusp. --NC + */ + if (state == 4) {enum for states instead of magics, please.
Changed to ACPI_STATE_S4. Thanks!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Nigel CunninghamQuoted 2 lines · Nigel Cunningham
Thanks very much for all your reading and commenting. I really appreciate it. By the way, you do want replies sent to both addresses?
I'm just browsing through it for now. Replies to cs.helsinki.fi is sufficient. I use my gmail address for replying to lkml posts only.
Pekka
Re: [PATCH] [26/48] Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch
In reply to Pekka EnbergHi.
Quoted 5 lines · Pekka Enberg
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000
Quoted 3 lines
diff -ruNp
604-utility-header.patch-old/kernel/power/suspend2_core/utility.h604-utility-header.patch-new/kernel/power/suspend2_core/utility.hkernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/utility.h 1970-01-01 10:00:00.000000000 +1000 +0
-0Please do move these.
Okay.
Quoted 4 lines
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000
Quoted 2 lines
kernel/power/suspend2_core/utility.h 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend2_core/utility.h 1970-01-01 10:00:00.000000000 +1000 +2
-0+ +extern int suspend_snprintf(char * buffer, int buffer_size, const char *fmt, ...);What's wrong with regular snprintf?
If there's a buffer overrun, it returns the number of bytes it wanted to use, not the number actually used.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch
Quoted 4 lines · Pekka Enberg
Quoted 4 lines
kernel/power/suspend2_core/utility.h line 12
Quoted 2 lines
kernel/power/suspend2_core/utility.h +2
-0+ +extern int suspend_snprintf (char * buffer,int buffer_size,const char *fmt, ...);What's wrong with regular snprintf?
Quoted 2 lines · Nigel Cunningham
If there's a buffer overrun, it returns the number of bytes it wanted to use, not the number actually used.
But on buffer overrun, you know it wrote size-1 characters. I am unconvinced you need a special snprintf() for suspend. Are there other potential users? If not, please consider dropping suspend_snprintf completelely.
Pekka
Re: [PATCH] [26/48] Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch
In reply to Pekka EnbergHi again.
Quoted 8 lines · Pekka Enberg
Quoted 7 lines
+ *
suspend_snprintf
+ *
+ * Functionality : Print a string with parameters to a buffer of a+ * limited size. Unlike vsnprintf, we return the number + * of bytes actually put in the buffer, not the number + * that would have been put in if it was big enough.+ */
Please do move these.
Renamed and merged into lib/vsprintf.c.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [25/48] Suspend2 2.1.9.8 for 2.6.12: 602-smp.patch
In reply to Nigel CunninghamQuoted 37 lines · Nigel Cunningham
diff -ruNp
603-suspend2_common-headers.patch-old/kernel/power/suspend2_core/suspend2_common.h603-suspend2_common-headers.patch-new/kernel/power/suspend2_core/suspend2_common.hkernel/power/suspend2_core/suspend2_common.h 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/suspend2_common.h 1970-01-01 10:00:00.000000000 +1000 +33
-0@@ -0,0 +1,49 @@ +#ifdef CONFIG_PM_DEBUG +#define SET_DEBUG_STATE(bit) (test_and_set_bit(bit, &suspend_debug_state)) +#define CLEAR_DEBUG_STATE(bit) (test_and_clear_bit(bit, &suspend_debug_state)) +#else +#define SET_DEBUG_STATE(bit) (0) +#define CLEAR_DEBUG_STATE(bit) (0) +#endif + +#define SET_RESULT_STATE(bit) (test_and_set_bit(bit, &suspend_result)) +#define CLEAR_RESULT_STATE(bit) (test_and_clear_bit(bit, &suspend_result)) + +#define SUSPEND_ABORT_REQUESTED 1 +#define SUSPEND_NOSTORAGE_AVAILABLE 2 +#define SUSPEND_INSUFFICIENT_STORAGE 3 +#define SUSPEND_FREEZING_FAILED 4 +#define SUSPEND_UNEXPECTED_ALLOC 5 +#define SUSPEND_KEPT_IMAGE 6 +#define SUSPEND_WOULD_EAT_MEMORY 7 +#define SUSPEND_UNABLE_TO_FREE_ENOUGH_MEMORY 8 +#define SUSPEND_ENCRYPTION_SETUP_FAILED 9 + +/* second status register */ +#define SUSPEND_REBOOT 1 +#define SUSPEND_PAUSE 2 +#define SUSPEND_SLOW 3 +#define SUSPEND_NOPAGESET2 4 +#define SUSPEND_LOGALL 5 +#define SUSPEND_CAN_CANCEL 6 +#define SUSPEND_KEEP_IMAGE 7 +#define SUSPEND_FREEZER_TEST 8 +#define SUSPEND_FREEZER_TEST_SHOWALL 9 +#define SUSPEND_SINGLESTEP 10 +#define SUSPEND_PAUSE_NEAR_PAGESET_END 11
kernel/power/suspend2_core/suspend2_common.h 2005-07-04 23:14:19.000000000 +1000 line 43
Quoted 10 lines
kernel/power/suspend2_core/suspend2_common.h 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/suspend2_common.h 1970-01-01 10:00:00.000000000 +1000 +10
-0+#define SUSPEND_USE_ACPI_S4 12 +#define SUSPEND_KEEP_METADATA 13 +#define SUSPEND_TEST_FILTER_SPEED 14 +#define SUSPEND_FREEZE_TIMERS 15 +#define SUSPEND_DISABLE_SYSDEV_SUPPORT 16 +#define SUSPEND_VGA_POST 17 + +#define TEST_ACTION_STATE(bit) (test_bit(bit, &suspend_action)) +#define SET_ACTION_STATE(bit) (test_and_set_bit(bit, &suspend_action)) +#define CLEAR_ACTION_STATE(bit) (test_and_clear_bit(bit, &suspend_action))
Enums, please.
Re: [PATCH] [37/48] Suspend2 2.1.9.8 for 2.6.12: 613-pageflags.patch
In reply to Nigel Cunninghamkernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 line 7
Quoted 11 lines · Nigel Cunningham
diff -ruNp
614-plugins.patch-old/kernel/power/suspend2_core/plugins.c614-plugins.patch-new/kernel/power/suspend2_core/plugins.ckernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/plugins.c 1970-01-01 10:00:00.000000000 +1000 +7
-0@@ -0,0 +1,341 @@ +#define FILTER_PLUGIN 1 +#define WRITER_PLUGIN 2 +#define MISC_PLUGIN 4 // Block writer, eg. +#define CHECKSUM_PLUGIN 5 + +#define SUSPEND_ASYNC 0 +#define SUSPEND_SYNC 1
Enums are preferred.
kernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 line 17
Quoted 10 lines
kernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/plugins.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ +#define SUSPEND_COMMON_IO_OPS \ + /* Writing the image proper */ \ + int (*write_chunk) (struct page * buffer_page); \ +\ + /* Reading the image proper */ \ + int (*read_chunk) (struct page * buffer_page, int sync); \ +\ + /* Reset plugin if image exists but reading aborted */ \ + void (*noresume_reset) (void);
Please remove the above macro obfuscation.
Re: [PATCH] [32/48] Suspend2 2.1.9.8 for 2.6.12: 609-driver-model.patch
In reply to Pekka EnbergHi again.
Quoted 10 lines · Pekka Enberg
kernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000
Quoted 7 lines · Nigel Cunningham
diff -ruNp
610-encryption.patch-old/kernel/power/suspend2_core/encryption.c610-encryption.patch-new/kernel/power/suspend2_core/encryption.ckernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000 renamed from kernel/power/suspend2_core/encryption.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+static inline void free_local_buffer(void) +{ + if (page_buffer) + free_pages((unsigned long) page_buffer, 0);Use
free_page(), please.
Found more grepping the patches - take them as fixed too.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [32/48] Suspend2 2.1.9.8 for 2.6.12: 609-driver-model.patch
In reply to Pekka EnbergHi.
Quoted 10 lines · Pekka Enberg
kernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000
Quoted 7 lines · Nigel Cunningham
diff -ruNp
610-encryption.patch-old/kernel/power/suspend2_core/encryption.c610-encryption.patch-new/kernel/power/suspend2_core/encryption.ckernel/power/suspend2_core/encryption.c 2005-07-05 23:54:31.000000000 +1000 renamed from kernel/power/suspend2_core/encryption.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+static inline void free_local_buffer(void) +{ + if (page_buffer) + free_pages((unsigned long) page_buffer, 0);Use
free_page(), please.
Done. Thanks!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [25/48] Suspend2 2.1.9.8 for 2.6.12: 602-smp.patch
In reply to Pekka EnbergHi.
On Wed, 2005-07-06 at 22:03, Pekka Enberg wrote:
[snip]
Quoted 6 lines
Quoted 6 lines
kernel/power/suspend2_core/suspend2_common.h +6
-0+#define SUSPEND_SINGLESTEP 10 +#define SUSPEND_PAUSE_NEAR_PAGESET_END 11 +#define SUSPEND_USE_ACPI_S4 12 +#define SUSPEND_KEEP_METADATA 13 +#define SUSPEND_TEST_FILTER_SPEED 14 +#define SUSPEND_FREEZE_TIMERS 15
Quoted 8 lines
kernel/power/suspend2_core/suspend2_common.h line 43
Quoted 6 lines
kernel/power/suspend2_core/suspend2_common.h +6
-0+#define SUSPEND_DISABLE_SYSDEV_SUPPORT 16 +#define SUSPEND_VGA_POST 17 + +#define TEST_ACTION_STATE (bit) (test_bit(bit, &suspend_action)) +#define SET_ACTION_STATE (bit) (test_and_set_bit(bit, &suspend_action)) +#define CLEAR_ACTION_STATE (bit) (test_and_clear_bit(bit, &suspend_action))Enums, please.
Done. I'm off to bed now. Don't think I'm ignoring the rest :>
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch
In reply to Nigel CunninghamQuoted 25 lines · Nigel Cunningham
Quoted 24 lines · Zwane Mwaikambo
Quoted 22 lines · Nigel Cunningham
diff -ruNp
353-disable-highmem-tlb-flush-for-copyback.patch-old/mm/highmem.c353-disable-highmem-tlb-flush-for-copyback.patch-new/mm/highmem.cmm/highmem.c +5
-1@@ -26,6 +26,7 @@#include <linux/init.h> #include <linux/hash.h> #include <linux/highmem.h> +#include <linux/suspend.h> #include <asm/tlbflush.h> static mempool_t *page_pool, *isa_page_pool;@@ -95,7 +96,10 @@ static void flush_all_zero_pkmaps(void)set_page_address (page,NULL ); } -flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); +if (test_suspend_state (SUSPEND_FREEZE_SMP )) +__flush_tlb (); +else +flush_tlb_kernel_range (PKMAP_ADDR (0 ),PKMAP_ADDR (LAST_PKMAP )); }
Quoted 7 lines
Quoted 3 lines
mm/highmem.c static void flush_all_zero_pkmaps(void) · line 105
Quoted 1 line
mm/highmem.c +0
-0static inline unsigned long map_new_virtual (struct page *page)What state are the other processors in when you hit this path?
Looping in arch specific code, waiting for an
atomic_tto tell them it's time to restore state and carry on. They're there the whole time CPU0 is restoring the image and highmem.
Oh ok, so they wouldn't have TLB entries for the above.
Thanks,
Zwane
Re: [PATCH] [11/48] Suspend2 2.1.9.8 for 2.6.12: 401-e820-table-support.patch
In reply to Nigel CunninghamQuoted 9 lines · Nigel Cunningham
Quoted 2 lines · Zwane Mwaikambo
Isn't this covered by Shaohua Li's patch?
I believe so, but Shaohua Li's patch isn't merged in 2.6.12 (is it yet at all). This is the solution I've been using for... can't remember how long.
Thanks for the feedback.
That's fine, i just want to make sure i know which parts can be used by your project too.
Thanks Nigel,
Zwane
Re: [PATCH] [19/48] Suspend2 2.1.9.8 for 2.6.12: 510-version-specific-mac.patch
In reply to Nigel CunninghamQuoted 2 lines · Nigel Cunningham
I've just noticed that all the subject lines are off by one. Sorry. Shall I repost with it right this time?
Yes the subject lines did look a bit confusing, it may be easier in future to add a short description of the patch instead of relying on the patch name.
Quoted 6 lines
Regarding this
x86_64patch, I haven't been able to testx86_64support yet (no hardware here), so I'm sure you're right about all the things. I've really just parroted what swsusp does in its lowlevel code, since saving and restoring cpu state is one thing we do the same way.Will apply changes.
Fair enough.
Thanks,
Zwane
Re: [PATCH] [4/48] Suspend2 2.1.9.8 for 2.6.12: 302-init-hooks.patch
In reply to Shaohua LiQuoted 14 lines · Shaohua Li
drivers/acpi/osl.c acpi_os_initialize1(void) · line 99
Quoted 10 lines · Nigel Cunningham
diff -ruNp
350-workthreads.patch-old/drivers/acpi/osl.c350-workthreads.patch-new/drivers/acpi/osl.cdrivers/acpi/osl.c +1
-1@@ -95,7 +95,7 @@ acpi_os_initialize1(void) return AE_NULL_ENTRY; }#endif - kacpid_wq =create_singlethread_workqueue ("kacpid" ); + kacpid_wq =create_singlethread_workqueue ("kacpid" ,PF_NOFREEZE );BUG_ON (!kacpid_wq);I'm not sure but kacpid can run any kind of code (depends on BIOS, it might touch some devices), is this safe?
FYI, the reason it's there is to do something about acpi events whilst resuming. If kacpid is not running the following bug occurs:
- during suspend, prior to the atomic copy, a GPE fires (eg, a battery notification)
- the GPE is disabled until it is serviced by kacpid, but as kacpid is not running, it isn't serviced - only disabled.
- the disabled state of the GPE is recorded in the atomic copy, and written to disk
- poweroff/S4
- on resume, ACPI initialises the GPEs and enables them all.
- after the restoring the atomic copy, the GPE may fire. However, the kernel thinks it is already disabled and so refuses to disable it again.
- this sends the machine into an interrupt-induced death as the GPE fires over and over and over ...
I prepared a patch a while ago that simply omitted the check and disabled the GPE unconditionally (which was how things were before the big ACPI merge of 2.6.9), but this made the battery status unreadable for at least one user. I never followed that up, but instead some more general GPE suspend/resume handling was discussed, making GPEs system devices that were suspended and resumed accordingly. I don't think any code eventuated from this discussion though ...
Letting kacpid run during suspend appeared to be a good compromise (but still racy if GPEs were to occur at exactly the right instant
- just before the atomic copy). Implementing suspend/resume support for GPEs would be the more ideal solution.
Bernard.
Signature · 1 line
Bernard Blackham <bernard at blackham dot com dot au>
Hi again.
Quoted 2 lines · Pavel Machek
Is swsusp1 expected to be functional after these are applied? You removed *some* of its hooks, but not all, so I'm confused.
I've been thinking about this some more and wondering whether I should just replace swsusp. I really don't want to step on your toes though. What would you like to see happen?
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [37/48] Suspend2 2.1.9.8 for 2.6.12: 613-pageflags.patch
In reply to Pekka EnbergHi.
Quoted 15 lines · Pekka Enberg
kernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 line 7
Quoted 11 lines · Nigel Cunningham
diff -ruNp
614-plugins.patch-old/kernel/power/suspend2_core/plugins.c614-plugins.patch-new/kernel/power/suspend2_core/plugins.ckernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/plugins.c 1970-01-01 10:00:00.000000000 +1000 +7
-0@@ -0,0 +1,341 @@ +#define FILTER_PLUGIN 1 +#define WRITER_PLUGIN 2 +#define MISC_PLUGIN 4 // Block writer, eg. +#define CHECKSUM_PLUGIN 5 + +#define SUSPEND_ASYNC 0 +#define SUSPEND_SYNC 1Enums are preferred.
Quoted 12 lines
kernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 line 17
Quoted 10 lines
kernel/power/suspend2_core/plugins.c 2005-07-04 23:14:19.000000000 +1000 renamed from kernel/power/suspend2_core/plugins.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ +#define SUSPEND_COMMON_IO_OPS \ + /* Writing the image proper */ \ + int (*write_chunk) (struct page * buffer_page); \ +\ + /* Reading the image proper */ \ + int (*read_chunk) (struct page * buffer_page, int sync); \ +\ + /* Reset plugin if image exists but reading aborted */ \ + void (*noresume_reset) (void);Please remove the above macro obfuscation.
Done. Thanks!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Quoted 3 lines · Nigel Cunningham
I've been thinking about this some more and wondering whether I should just replace swsusp. I really don't want to step on your toes though. What would you like to see happen?
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
Signature · 1 line
Matthew Garrett | [email protected]
Hi.
Quoted 8 lines · Matthew Garrett
Quoted 3 lines · Nigel Cunningham
I've been thinking about this some more and wondering whether I should just replace swsusp. I really don't want to step on your toes though. What would you like to see happen?
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
I'm not suggesting removing the sysfs interface or replacing system to ram - just the suspend to disk part.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Hi.
Quoted 5 lines · Pekka Enberg
Hi Nigel,
Quoted 2 lines · Nigel Cunningham
As requested, here are the patches that form Suspend2, for review.
Quoted 7 lines
Quoted 4 lines
I've tried to split it up into byte size chunks, but please don't expect that these will be patches that can mutate swsusp into Suspend2. That would roughly equivalent to asking for patches that patch Reiser3 into Reiser4 - it's a redesign.
Please consider putting diffstat in the patches. They make navigating large patchsets easier.
Adjusted my patch generation script to do this.
Thanks.
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Pekka EnbergHi.
Quoted 14 lines · Pekka Enberg
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 5
Quoted 9 lines · Nigel Cunningham
diff -ruNp
623-generic-block-io.patch-old/kernel/power/suspend_block_io.c623-generic-block-io.patch-new/kernel/power/suspend_block_io.ckernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +5
-0@@ -0,0 +1,817 @@ +#include "suspend2_core/suspend.h" +#include "suspend2_core/proc.h" +#include "suspend2_core/plugins.h" +#include "suspend2_core/utility.h" +#include "suspend2_core/prepare_image.h"You've got circular dependencies.
kernel/power/suspend2_coredepends on kernel/power and vice versa. Please just consider putting them all inkernel/power/
Done. They were separate just to keep things tidy.
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 13
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +8
-0+/* Bits in struct io_info->flags */ +#define IO_WRITING 1 +#define IO_RESTORE_PAGE_PROT 2 +#define IO_AWAITING_READ 3 +#define IO_AWAITING_WRITE 4 +#define IO_AWAITING_SUBMIT 5 +#define IO_AWAITING_CLEANUP 6 +#define IO_HANDLE_PAGE_PROT 7Please use enums instead.
Done!
Quoted 4 lines
Quoted 4 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+ +#define MAX_OUTSTANDING_IO 1024 + +/*
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 23
Quoted 6 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +6
-0+ * --------------------------------------------------------------- + * + * IO in progress information storage and helpers + * + * --------------------------------------------------------------- + */Could we please drop the above banner. Hurts my eyes...
Sorry! :>
Quoted 6 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 27
Quoted 4 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +4
-0+ +struct io_info { + struct bio * sys_struct; + long block[PAGE_SIZE/512];You're hardcoding sector size here, no?
As others do.
Quoted 10 lines
Quoted 10 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +10
-0+ struct page * buffer_page; + struct page * data_page; + unsigned long flags; + struct block_device * dev; + struct list_head list; + int readahead_index; + struct work_struct work; +}; + +/* Locks separated to allow better SMP support.
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 42
Quoted 5 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +5
-0+ * An io_struct moves through the lists as follows. + * free -> submit_batch -> busy -> ready_for_cleanup -> free + */ +static LIST_HEAD(ioinfo_free); +static spinlock_t ioinfo_free_lock = SPIN_LOCK_UNLOCKED;Please use
DEFINE_SPINLOCKinstead. It is preferred as some automatic lock checkers need it.
Done.
Quoted 4 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 44
Quoted 2 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +2
-0+#define BITS_PER_UL (8 * sizeof(unsigned long)) +static volatile unsigned long suspend_readahead_flags[(MAX_READAHEAD + BITS_PER_UL - 1) / BITS_PER_UL];<
asm/types.h> hasBITS_PER_LONG. Use it.
Thanks for educating the ignorant :>
Quoted 5 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 47
Quoted 3 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +3
-0+static int suspend_end_bio(struct bio * bio, unsigned int num, int err) +{ + struct io_info *io_info = (struct io_info *) bio->bi_private;Redundant cast.
k.
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 53
Quoted 6 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +6
-0+static unsigned long suspend_bio_memory_needed(void) +{ + /* We want to have at least enough memory so as to have 128 I/O + * transactions on the fly at once. If we can to more, fine. */ + return (128 * (PAGE_SIZE + sizeof(struct request) + + sizeof(struct bio) + sizeof(struct io_info)));Where did the magic 128 come from?
My bad. Should be MAX_OUTSTANDING_IO.
Thanks, once again!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Quoted 6 lines · Nigel Cunningham
Quoted 2 lines · Matthew Garrett
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
I'm not suggesting removing the sysfs interface or replacing system to ram - just the suspend to disk part.
Right, so you support the resume from disk trigger in sysfs and the /proc/acpi/sleep interface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.
Signature · 1 line
Matthew Garrett | [email protected]
Hi.
Quoted 5 lines · Matthew Garrett
Quoted 4 lines · Nigel Cunningham
Quoted 2 lines · Matthew Garrett
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
Quoted 7 lines
Quoted 2 lines
I'm not suggesting removing the sysfs interface or replacing system to ram - just the suspend to disk part.
Right, so you support the resume from disk trigger in sysfs and the
/proc/acpi/sleepinterface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.
Suspend2 currently has a proc entry to do the same, but I can easily hook into the sysfs code. /proc/acpi/sleep is already taken care of, as is the reboot handler. Suspend2 currently uses resume2= so as to not conflict with swsusp, but that can be changed too. I always to my utmost to ease the pain for other users. If something doesn't work the way you want, just tell me and (assuming it's reasonable), I'll fix it.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel CunninghamHi Nigel,
Quoted 1 line · Pekka Enberg
Quoted 1 line
You're hardcoding sector size here, no?
Quoted 1 line · Nigel Cunningham
As others do.
Even so, please use a constant.
Pekka
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel CunninghamHi Nigel,
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 3
Quoted 7 lines
diff -ruNp
623-generic-block-io.patch-old/kernel/power/suspend_block_io.c623-generic-block-io.patch-new/kernel/power/suspend_block_io.ckernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +3
-0@@ -0,0 +1,817 @@ +struct io_info { + struct bio * sys_struct; + long block[PAGE_SIZE/512];
Aah, but for this you should use block_size(io_info->dev) instead. No need to mess with sector sizes. Why is this long by the way? PAGE_SIZE/512 is block size in bytes.
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 11
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +8
-0+ struct page * buffer_page; + struct page * data_page; + unsigned long flags; + struct block_device * dev; + struct list_head list; + int readahead_index; + struct work_struct work; +};
Pekka
Hi,
Quoted 5 lines · Matthew Garrett
Quoted 4 lines · Nigel Cunningham
Quoted 2 lines · Matthew Garrett
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
Quoted 7 lines
Quoted 2 lines
I'm not suggesting removing the sysfs interface or replacing system to ram - just the suspend to disk part.
Right, so you support the resume from disk trigger in sysfs and the
/proc/acpi/sleepinterface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.
I don't think that swsusp can be replaced with suspend2 right now. First, swsusp works on x86-64, and the support in suspend2 is preliminary, AFAIK. Second, the IA64 support for swsusp is in the works, and it is not supported by suspend2.
Please don't plan to drop swsusp until you are able to replace it _completely_.
Greets,
Rafael
Signature · 3 lines
- 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"
Hi!
Quoted 6 lines
Quoted 2 lines
Is swsusp1 expected to be functional after these are applied? You removed *some* of its hooks, but not all, so I'm confused.
I've been thinking about this some more and wondering whether I should just replace swsusp. I really don't want to step on your toes though. What would you like to see happen?
When/if suspend2 is merged and working, there's no reason to keep swsusp around. So patches for removing swsusp1 are quite okay at the end of series. OTOH it is one more patch for you to maintain, so... do whatever you want.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Pekka EnbergHi.
Quoted 13 lines · Pekka Enberg
Hi Nigel,
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 3
Quoted 7 lines
diff -ruNp
623-generic-block-io.patch-old/kernel/power/suspend_block_io.c623-generic-block-io.patch-new/kernel/power/suspend_block_io.ckernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +3
-0@@ -0,0 +1,817 @@ +struct io_info { + struct bio * sys_struct; + long block[PAGE_SIZE/512];Aah, but for this you should use
block_size(io_info->dev)instead. No need to mess with sector sizes. Why is this long by the way? PAGE_SIZE/512 is block size in bytes.
No... it's the maximum number of blocks per page. Depending upon how the user has set the blocksize when they created the filesystem (in the case of filesystems), the number of blocks we use per page might be 1, 2, 4 or 8.
It's long because a sector number is stored in it.
Regards,
Nigel
Quoted 11 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 line 11
Quoted 8 lines
kernel/power/suspend_block_io.c 2005-07-05 23:48:59.000000000 +1000 renamed from kernel/power/suspend_block_io.c 1970-01-01 10:00:00.000000000 +1000 +8
-0+ struct page * buffer_page; + struct page * data_page; + unsigned long flags; + struct block_device * dev; + struct list_head list; + int readahead_index; + struct work_struct work; +};Pekka
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Hi.
Quoted 16 lines · Rafael J. Wysocki
Hi,
Quoted 5 lines · Matthew Garrett
Quoted 4 lines · Nigel Cunningham
Quoted 2 lines · Matthew Garrett
Do you implement the entire swsusp userspace interface? If not, removing it probably isn't a reasonable plan without fair warning.
Quoted 7 lines
Quoted 2 lines
I'm not suggesting removing the sysfs interface or replacing system to ram - just the suspend to disk part.
Right, so you support the resume from disk trigger in sysfs and the
/proc/acpi/sleepinterface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.
Quoted 6 lines
I don't think that swsusp can be replaced with suspend2 right now. First, swsusp works on x86-64, and the support in suspend2 is preliminary, AFAIK. Second, the IA64 support for swsusp is in the works, and it is not supported by suspend2.
Please don't plan to drop swsusp until you are able to replace it _completely_.
Fair enough. I didn't realise Pavel had IA64 support too :>
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel CunninghamOn Fri, 8 Jul 2005 07:16 am, Nigel Cunningham wrote:
Hi,
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
kernel/power/suspend_block_io.c +3
-0+struct io_info { +struct bio * sys_struct; +long block[PAGE_SIZE /512 ];
Quoted 9 lines
Quoted 3 lines
Aah, but for this you should use
block_size(io_info->dev)instead. No need to mess with sector sizes. Why is this long by the way? PAGE_SIZE/512 is block size in bytes.No... it's the maximum number of blocks per page. Depending upon how the user has set the blocksize when they created the filesystem (in the case of filesystems), the number of blocks we use per page might be 1, 2, 4 or 8.
MAX_BUF_PER_PAGE
Quoted 2 lines
It's long because a sector number is stored in it.
sector_t?
Nick
Send instant messages to your online friends http://au.messenger.yahoo.com
Re: Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel CunninghamQuoted 4 lines · Nigel Cunningham
No... it's the maximum number of blocks per page. Depending upon how the user has set the blocksize when they created the filesystem (in the case of filesystems), the number of blocks we use per page might be 1, 2, 4 or 8.
Yes. Sorry about that. I don't know what I was smoking. (But it must have been the good stuff (-:.)
Pekka
Re: Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Nigel CunninghamQuoted 4 lines · Pekka Enberg
Quoted 4 lines
Quoted 4 lines
kernel/power/suspend_block_io.c +3
-0@@ -0,0 +1,817 @@ +struct io_info { +struct bio * sys_struct; +long block[PAGE_SIZE /512 ];
Quoted 6 lines · Nigel Cunningham
No... it's the maximum number of blocks per page. Depending upon how the user has set the blocksize when they created the filesystem (in the case of filesystems), the number of blocks we use per page might be 1, 2, 4 or 8.
It's long because a sector number is stored in it.
The field block wants a better name. block_sectors, perhaps?
Pekka
Re: Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to Pekka J EnbergHi.
Quoted 9 lines · Pekka J Enberg
Hi Nigel,
Quoted 1 line · Pekka Enberg
Quoted 1 line
You're hardcoding sector size here, no?
Quoted 1 line · Nigel Cunningham
As others do.
Even so, please use a constant.
Done
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [46/48] Suspend2 2.1.9.8 for 2.6.12: 622-swapwriter.patch
In reply to [email protected]Hi.
Quoted 18 lines · On Fri, 2005-07-08 at 07:26, [email protected] wrote:
On Fri, 8 Jul 2005 07:16 am, Nigel Cunningham wrote:
Hi,
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
kernel/power/suspend_block_io.c +3
-0+struct io_info { +struct bio * sys_struct; +long block[PAGE_SIZE /512 ];Quoted 9 lines
Quoted 3 lines
Aah, but for this you should use
block_size(io_info->dev)instead. No need to mess with sector sizes. Why is this long by the way? PAGE_SIZE/512 is block size in bytes.No... it's the maximum number of blocks per page. Depending upon how the user has set the blocksize when they created the filesystem (in the case of filesystems), the number of blocks we use per page might be 1, 2, 4 or 8.
Quoted 6 lines
MAX_BUF_PER_PAGEQuoted 2 lines
It's long because a sector number is stored in it.
sector_t?
Fixed. Ta.
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Quoted 4 lines · Matthew Garrett
Right, so you support the resume from disk trigger in sysfs and the
/proc/acpi/sleepinterface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.
JFTR: i second this. There is already enough hackery involved if one wants to provide a smooth user experience ;-)
Signature · 3 lines
Stefan Seyfried \ "I didn't want to write for pay. I QA / R&D Team Mobile Devices \ wanted to be paid for what I write." SUSE LINUX Products GmbH, Nürnberg \ -- Leonard Cohen
Hi.
Quoted 9 lines · Stefan Seyfried
Quoted 4 lines · Matthew Garrett
Right, so you support the resume from disk trigger in sysfs and the
/proc/acpi/sleepinterface? If suspend2 is a complete dropin replacement then I'm much happier with the idea of dropping swsusp, but I don't want to have to tie suspend/resume scripts to kernel versions.JFTR: i second this. There is already enough hackery involved if one wants to provide a smooth user experience ;-)
Consider it promised, and feel free to poke me if I forget! (That said, I won't now!).
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [9/48] Suspend2 2.1.9.8 for 2.6.12: 354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch
In reply to Nigel CunninghamHi!
mm/vmscan.c static int kswapd(void *p) · line 1234
Quoted 13 lines
diff -ruNp
360-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c360-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.cmm/vmscan.c +4
-2@@ -1228,8 +1228,10 @@ static int kswapd(void *p) order =0 ;for ( ; ; ) {unsigned long new_order; - -try_to_freeze (); +if (freezing (current)) { +try_to_freeze (); + pgdat->kswapd_max_order =0 ; + }
Why not
if (try_to_freeze()) pgdat->... = 0;
?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [18/48] Suspend2 2.1.9.8 for 2.6.12: 501-tlb-flushing-functions.patch
In reply to Nigel CunninghamHi!
arch/ppc/platforms/pmac_feature.c static struct pmac_mb_def pmac_mb_defs[] · line 2297
Quoted 12 lines
diff -ruNp
510-version-specific-mac.patch-old/arch/ppc/platforms/pmac_feature.c510-version-specific-mac.patch-new/arch/ppc/platforms/pmac_feature.carch/ppc/platforms/pmac_feature.c +4
-1@@ -2291,7 +2291,10 @@ static struct pmac_mb_def pmac_mb_defs[] }, {"PowerBook5,1" ,"PowerBook G4 17\"" ,PMAC_TYPE_UNKNOWN_INTREPID , intrepid_features, - PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE, + PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE +#ifdef CONFIG_SOFTWARE_REPLACE_SLEEP + | PMAC_MB_CAN_SLEEP, +#endif
There's different number of ","s depending on CONFIG_... Is that ok?
arch/ppc/syslib/of_device.c static int of_device_remove(struct devic · line 110
Quoted 12 lines
diff -ruNp
510-version-specific-mac.patch-old/arch/ppc/syslib/of_device.c510-version-specific-mac.patch-new/arch/ppc/syslib/of_device.carch/ppc/syslib/of_device.c +1
-1@@ -104,7 +104,7 @@ static int of_device_remove(struct devicreturn 0 ; } -static int of_device_suspend (struct device *dev,u32 state) +static int of_device_suspend (struct device *dev,pm_message_t state) {struct of_device * of_dev =to_of_device (dev);struct of_platform_driver * drv =to_of_platform_driver (dev->driver);
Can I have these separately?
Quoted 7 lines
diff -ruNp
510-version-specific-mac.patch-old/drivers/macintosh/via-pmu.c510-version-specific-mac.patch-new/drivers/macintosh/via-pmu.cdrivers/macintosh/via-pmu.c +0
-0@@ -2894,6 +2894,13 @@ pmu_ioctl(struct inode * inode, struct freturn -EACCES ;if (sleep_in_progress)return -EBUSY ;
drivers/macintosh/via-pmu.c pmu_ioctl(struct inode * inode, struct f · line 2906
Quoted 10 lines
drivers/macintosh/via-pmu.c +7
-0+#ifdef CONFIG_SOFTWARE_REPLACE_SLEEP + { +extern void software_suspend_pending (void ); +software_suspend_pending (); +return (0 ); + } +#endif sleep_in_progress =1 ;switch (pmu_kind) {case PMU_OHARE_BASED :
Indentation? And use return 0; not return (0);
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [31/48] Suspend2 2.1.9.8 for 2.6.12: 608-compression.patch
In reply to Nigel CunninghamHi!
Quoted 29 lines
diff -ruNp
609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.c609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.ckernel/power/suspend2_core/driver_model.c +25
-0@@ -0,0 +1,95 @@ +/* +* kernel/power/suspend2_core/driver_model.c +* +* Copyright (C) 2004-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* Support for the driver model and ACPI sleep states. +*/ + +#include <linux/pm.h> +#include "driver_model.h" +#include "power_off.h" + +extern struct pm_ops * pm_ops; +static u32 pm_disk_mode_save; + +#ifdef CONFIG_ACPI +static int suspend_pm_state_used =0 ; +extern u32 acpi_leave_sleep_state (u8 sleep_state); +#endif + +/* suspend_drivers_init +* +* Store the original pm ops settings.
kernel/power/suspend2_core/driver_model.c line 35
Quoted 10 lines
kernel/power/suspend2_core/driver_model.c +10
-0+*/ +int suspend_drivers_init (void ) +{ +if (pm_ops) { + pm_disk_mode_save = pm_ops->pm_disk_mode; + pm_ops->pm_disk_mode =PM_DISK_PLATFORM ; + } + +return 0 ; +}
That seems like quite an ugly hack.
Quoted 24 lines
kernel/power/suspend2_core/driver_model.c +24
-0+/* suspend_drivers_cleanup +* +* Restore the original pm disk mode. +*/ +void suspend_drivers_cleanup (void ) +{ +if (pm_ops) + pm_ops->pm_disk_mode = pm_disk_mode_save; +} + +/* suspend_drivers_suspend +* +* Suspend the drivers after an atomic copy. +*/ +int suspend_drivers_suspend (int stage) +{ +int result =0 ; +const pm_message_t state =PMSG_FREEZE ; + +switch (stage) { +case SUSPEND_DRIVERS_IRQS_DISABLED : +BUG_ON (!irqs_disabled ()); + result =device_power_down (state); +BUG_ON (!irqs_disabled ());
kernel/power/suspend2_core/driver_model.c line 70
Quoted 10 lines
kernel/power/suspend2_core/driver_model.c +10
-0+break ; + +case SUSPEND_DRIVERS_IRQS_ENABLED : +BUG_ON (irqs_disabled ()); + result =device_suspend (state); +BUG_ON (irqs_disabled ()); +break ; + } +return result; +}
Can't you just inline these?
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [26/48] Suspend2 2.1.9.8 for 2.6.12: 603-suspend2_common-headers.patch
In reply to Nigel CunninghamHi!
Quoted 40 lines
diff -ruNp
604-utility-header.patch-old/kernel/power/suspend2_core/utility.c604-utility-header.patch-new/kernel/power/suspend2_core/utility.ckernel/power/suspend2_core/utility.c +36
-0@@ -0,0 +1,46 @@ +/* +* kernel/power/utility.c +* +* Copyright (C) 2004-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* Routines that only suspend uses at the moment, but which might move +* when we merge because they're generic. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mm.h> +#include <linux/proc_fs.h> +#include <asm/string.h> + +#include "pageflags.h" + +/* +* suspend_snprintf +* +* Functionality : Print a string with parameters to a buffer of a +* limited size. Unlike vsnprintf, we return the number +* of bytes actually put in the buffer, not the number +* that would have been put in if it was big enough. +*/ +int suspend_snprintf (char * buffer,int buffer_size,const char *fmt, ...) +{ +int result; +va_list args; + +if (!buffer_size) { +return 0 ; + } +
kernel/power/suspend2_core/utility.c line 46
Quoted 10 lines
kernel/power/suspend2_core/utility.c +10
-0+va_start (args, fmt); + result =vsnprintf (buffer, buffer_size, fmt, args); +va_end (args); + +if (result > buffer_size) { +return buffer_size; + } + +return result; +}
Eh, this needs to be either generic function or not there at all.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [9/48] Suspend2 2.1.9.8 for 2.6.12: 354-disable-mce-checking-during-suspend-avoid-smp-deadlock.patch
In reply to Pavel MachekHi.
Quoted 17 lines · Pavel Machek
Hi!
mm/vmscan.c static int kswapd(void *p) · line 1234
Quoted 13 lines
diff -ruNp
360-reset-kswapd-max-order-after-resume.patch-old/mm/vmscan.c360-reset-kswapd-max-order-after-resume.patch-new/mm/vmscan.cmm/vmscan.c +4
-2@@ -1228,8 +1228,10 @@ static int kswapd(void *p) order =0 ;for ( ; ; ) {unsigned long new_order; - -try_to_freeze (); +if (freezing (current)) { +try_to_freeze (); + pgdat->kswapd_max_order =0 ; + }Why not
Quoted 4 lines
if (try_to_freeze()) pgdat->... = 0;?
I have no idea. Fixed. Thanks!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Nigel CunninghamHi!
crypto/lzf.c line 91
Quoted 11 lines
crypto/lzf.c +11
-0+/* +* sacrifice some compression quality in favour of compression speed. +* (roughly 1-2% worse compression for large blocks and +* 9-10% for small, redundant, blocks and >>20% better speed in both cases) +* In short: enable this for binary data, disable this for text data. +*/ +#define ULTRA_FAST 1 + +#define STRICT_ALIGN 0 +#define USE_MEMCPY 1 +#define INIT_HTAB 0
Ugly, ugly, ugly. Pick one set of options and use them.
crypto/lzf.c line 102
Quoted 8 lines
crypto/lzf.c +8
-0+/* +* don't play with this unless you benchmark! +* decompression is not dependent on the hash function +* the hashing function might seem strange, just believe me +* it works ;) +*/ +#define FRST (p) (((p[0]) << 8) + p[1]) +#define NEXT (v,p) (((v) << 8) + p[2])
Dnt wrt mcr nms lk ths!
crypto/lzf.c line 214
Quoted 11 lines
crypto/lzf.c +11
-0+if (ctx->first_call) { + ctx->first_call =0 ; + } +#if INIT_HTAB +# if USE_MEMCPY +memset (htab,0 ,sizeof (htab)); +# else +for (hslot = htab; hslot < htab +HSIZE ; hslot++) + *hslot++ = ip; +# endif +#endif
Eh? Use_memcpy and then it memsets?
BTW if it is "contributed code", you may want original contributor to push it, so that you don't have to do all the lindenting/cleaning/etc yourself.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
Howdy.
Quoted 3 lines · Pavel Machek
BTW if it is "contributed code", you may want original contributor to push it, so that you don't have to do all the lindenting/cleaning/etc yourself.
It is, and he's gone to ground. As requested by Pekka, I've Lindented it. Apart from that, I didn't really want to touch it for fear of breaking it :> Then again, I felt like that with suspend code at one stage!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [31/48] Suspend2 2.1.9.8 for 2.6.12: 608-compression.patch
In reply to Pavel MachekHowdy.
Quoted 35 lines · Pavel Machek
Hi!
Quoted 33 lines
diff -ruNp
609-driver-model.patch-old/kernel/power/suspend2_core/driver_model.c609-driver-model.patch-new/kernel/power/suspend2_core/driver_model.ckernel/power/suspend2_core/driver_model.c +29
-0@@ -0,0 +1,95 @@ +/* +* kernel/power/suspend2_core/driver_model.c +* +* Copyright (C) 2004-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* Support for the driver model and ACPI sleep states. +*/ + +#include <linux/pm.h> +#include "driver_model.h" +#include "power_off.h" + +extern struct pm_ops * pm_ops; +static u32 pm_disk_mode_save; + +#ifdef CONFIG_ACPI +static int suspend_pm_state_used =0 ; +extern u32 acpi_leave_sleep_state (u8 sleep_state); +#endif + +/* suspend_drivers_init +* +* Store the original pm ops settings. +*/ +int suspend_drivers_init (void ) +{ +if (pm_ops) {
Quoted 8 lines
kernel/power/suspend2_core/driver_model.c line 35
Quoted 6 lines
kernel/power/suspend2_core/driver_model.c +6
-0+ pm_disk_mode_save = pm_ops->pm_disk_mode; + pm_ops->pm_disk_mode =PM_DISK_PLATFORM ; + } + +return 0 ; +}That seems like quite an ugly hack.
Mmm. Adam and I have been discussing a more generic mechanism for powering down, switching between states and so on. Hopefully that will take care of these issues.
Quoted 28 lines
Quoted 28 lines
kernel/power/suspend2_core/driver_model.c +28
-0+/* suspend_drivers_cleanup +* +* Restore the original pm disk mode. +*/ +void suspend_drivers_cleanup (void ) +{ +if (pm_ops) + pm_ops->pm_disk_mode = pm_disk_mode_save; +} + +/* suspend_drivers_suspend +* +* Suspend the drivers after an atomic copy. +*/ +int suspend_drivers_suspend (int stage) +{ +int result =0 ; +const pm_message_t state =PMSG_FREEZE ; + +switch (stage) { +case SUSPEND_DRIVERS_IRQS_DISABLED : +BUG_ON (!irqs_disabled ()); + result =device_power_down (state); +BUG_ON (!irqs_disabled ()); +break ; + +case SUSPEND_DRIVERS_IRQS_ENABLED : +BUG_ON (irqs_disabled ());
Quoted 8 lines
kernel/power/suspend2_core/driver_model.c line 70
Quoted 6 lines
kernel/power/suspend2_core/driver_model.c +6
-0+ result =device_suspend (state); +BUG_ON (irqs_disabled ()); +break ; + } +return result; +}Can't you just inline these?
Yes, I could. Just trying to keep driver model stuff separate.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [37/48] Suspend2 2.1.9.8 for 2.6.12: 613-pageflags.patch
In reply to Nigel CunninghamHi!
You know what I think about plugins, right? There are already plugins at block device level, like raid5, LVM, device mapper... I do not see why you should need another one.
Quoted 11 lines
kernel/power/suspend2_core/plugins.c +11
-0+/* +* expected_compression_ratio +* +* Returns the expected ratio between the amount of memory +* to be saved and the amount of space required on the +* storage device. +*/ +int expected_compression_ratio (void ) +{ +struct suspend_plugin_ops * this_filter; +unsigned long ratio =100 ;
kernel/power/suspend2_core/plugins.c line 61
Quoted 10 lines
kernel/power/suspend2_core/plugins.c +10
-0+ +list_for_each_entry (this_filter, &suspend_filters, ops.filter.filter_list) { +if (this_filter->disabled) +continue ; +if (this_filter->ops.filter.expected_compression) + ratio = ratio * this_filter->ops.filter.expected_compression () /100 ; + } + +return (int ) ratio; +}
Why the cast and why long in the first place?
kernel/power/suspend2_core/plugins.c line 102
Quoted 13 lines
kernel/power/suspend2_core/plugins.c +13
-0+struct suspend_plugin_ops *find_plugin_given_name (char * name) +{ +struct suspend_plugin_ops * this_plugin, * found_plugin =NULL ; + +list_for_each_entry (this_plugin, &suspend_plugins, plugin_list) { +if (!strcmp (name, this_plugin->name)) { + found_plugin = this_plugin; +break ; + } + } + +return found_plugin; +}
How often are you doing this? Would hash table be prefered? How many plugins do you have? Maybe statical registration is right solution?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [37/48] Suspend2 2.1.9.8 for 2.6.12: 613-pageflags.patch
Hi.
Quoted 21 lines · Pavel Machek
Hi!
You know what I think about plugins, right? There are already plugins at block device level, like raid5, LVM, device mapper... I do not see why you should need another one.
Quoted 15 lines
kernel/power/suspend2_core/plugins.c +15
-0+/* +* expected_compression_ratio +* +* Returns the expected ratio between the amount of memory +* to be saved and the amount of space required on the +* storage device. +*/ +int expected_compression_ratio (void ) +{ +struct suspend_plugin_ops * this_filter; +unsigned long ratio =100 ; + +list_for_each_entry (this_filter, &suspend_filters, ops.filter.filter_list) { +if (this_filter->disabled) +continue ;
Quoted 8 lines
kernel/power/suspend2_core/plugins.c line 61
Quoted 6 lines
kernel/power/suspend2_core/plugins.c +6
-0+if (this_filter->ops.filter.expected_compression) + ratio = ratio * this_filter->ops.filter.expected_compression () /100 ; + } + +return (int ) ratio; +}Why the cast and why long in the first place?
My bad. Actually, since I recently switched to cryptoapi support, I can get rid of this function.
Quoted 8 lines
Quoted 8 lines
kernel/power/suspend2_core/plugins.c +8
-0+struct suspend_plugin_ops *find_plugin_given_name (char * name) +{ +struct suspend_plugin_ops * this_plugin, * found_plugin =NULL ; + +list_for_each_entry (this_plugin, &suspend_plugins, plugin_list) { +if (!strcmp (name, this_plugin->name)) { + found_plugin = this_plugin; +break ;
Quoted 8 lines
kernel/power/suspend2_core/plugins.c line 102
Quoted 5 lines
kernel/power/suspend2_core/plugins.c +5
-0+ } + } + +return found_plugin; +}How often are you doing this? Would hash table be prefered? How many plugins do you have? Maybe statical registration is right solution?
There would only be half a dozen tops.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [28/48] Suspend2 2.1.9.8 for 2.6.12: 605-kernel_power_suspend.patch
In reply to Nigel CunninghamHi!
Quoted 28 lines
diff -ruNp
606-all-settings.patch-old/kernel/power/suspend2_core/all_settings.c606-all-settings.patch-new/kernel/power/suspend2_core/all_settings.ckernel/power/suspend2_core/all_settings.c +24
-0@@ -0,0 +1,325 @@ +/* +* /kernel/power/suspend2_core/all_settings.c +* +* Suspend2 is released under the GPLv2. +* +* Copyright (C) 2002-2005 Nigel Cunningham <[email protected]> +* +* This file provides the all_settings proc entry, used to save +* and restore all suspend2 settings en masse. +*/ + +#include <linux/mm.h> +#include <linux/suspend.h> +#include <asm/uaccess.h> + +#include "plugins.h" +#include "proc.h" +#include "suspend2_common.h" +#include "prepare_image.h" +#include "power_off.h" +#include "io.h" + +#define ALL_SETTINGS_VERSION 4 +
kernel/power/suspend2_core/all_settings.c line 34
Quoted 10 lines
kernel/power/suspend2_core/all_settings.c +10
-0+static int resume2_len; + +/* +* suspend_write2_compat_proc. +* +* This entry allows all of the settings to be set at once. +* It was originally for compatibility with pre- /proc/suspend +* versions, but has been retained because it makes saving and +* restoring the configuration simpler. +*/
Okay, and it is also extremely ugly. Now you have chance to clean it up, please drop it.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [30/48] Suspend2 2.1.9.8 for 2.6.12: 607-atomic-copy.patch
In reply to Nigel CunninghamHi!
Quoted 3 lines
---
608-compression.patch-old/kernel/power/suspend2_core/compression.c1970-01-01 10:00:00.000000000 +1000
+++608-compression.patch-new/kernel/power/suspend2_core/compression.c
~~~~~~~~~~~~~
suspend2_core looks like an extremely bad name for a directory... And this is really plugin, not a core, no? Plus it would be nice to drop non-essential stuff for initial submit, so that it is not *that* big to review.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [29/48] Suspend2 2.1.9.8 for 2.6.12: 606-all-settings.patch
In reply to Nigel CunninghamHi!
kernel/power/suspend2_core/atomic_copy.c line 170
Quoted 9 lines
kernel/power/suspend2_core/atomic_copy.c +9
-0+static void suspend2_suspend_2 (void ) +{ +if (!save_image_part1 ()) { +suspend_power_down (); + +if (suspend2_powerdown_method ==3 ) { +int temp_result; + + temp_result =read_pageset2 (1 );
Is that just me or do I see way too many numbers. suspend2_suspend_2 is really funny name for a functions. powerdown_method should really use some symbolic constants.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [38/48] Suspend2 2.1.9.8 for 2.6.12: 614-plugins.patch
In reply to Nigel CunninghamHi!
Quoted 1 line
+unsigned long
suspend2_powerdown_method= 5; /* S5 = off */
Constants.....
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (suspend2_powerdown_method == 3 || + suspend2_powerdown_method == 4)
Constants...
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (suspend2_powerdown_method == 3 || + suspend2_powerdown_method == 4)
Constants...
kernel/power/suspend2_core/power_off.c line 137
Quoted 6 lines
kernel/power/suspend2_core/power_off.c +6
-0+suspend2_prepare_status (1 ,0 ,"Ready to reboot." ); +suspend2_prepare_status (1 ,0 ,"Seeking to enter ACPI state" ); +suspend2_prepare_status (1 ,0 ,"Preparing to enter ACPI state failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Suspending devices failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Entering ACPI state failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Powering down." );
Too many magical constants here... Plus I don't really like your own logging subsystem.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [35/48] Suspend2 2.1.9.8 for 2.6.12: 611-io.patch
In reply to Nigel CunninghamHi!
kernel/power/suspend2_core/pagedir.c line 109
Quoted 1 line
kernel/power/suspend2_core/pagedir.c +1
-0+//p->pageset_size = pageset_size;
Please don't leave commented code in.
Quoted 36 lines
kernel/power/suspend2_core/pagedir.c +36
-0+unsigned long suspend2_get_nonconflicting_pages (const int order) +{ +struct page * page; +unsigned long new_page; +int more =0 ; +unsigned long pgcount; + +do { + new_page =__get_free_pages (GFP_ATOMIC | __GFP_NOWARN, order); +if (!new_page) +return 0 ; + more =0 ; +for (pgcount =0 ; pgcount < (1UL << order); pgcount++) { + page =virt_to_page (new_page +PAGE_SIZE * pgcount); +if (PagePageset1 (page)) { + more =1 ; +break ; + } + } +if (more) { + page =virt_to_page (new_page); +list_add (&page->lru, &conflicting_pages); + +/* since this page is technically free, we can abuse it to +* store the order. When we resume it'll just be overwritten, +* but we need this value when freeing it in +* suspend2_release_conflicting_pages. */ + *((int *)new_page) = order; + } + } +while (more); + +memset ((void *)new_page,0 ,PAGE_SIZE * (1 <<order)); +return new_page; +} +
kernel/power/suspend2_core/pagedir.c line 264
Quoted 10 lines
kernel/power/suspend2_core/pagedir.c +10
-0+/* suspend2_get_nonconflicting_page +* +* Description: Gets a page that will not be overwritten as we copy the +* original kernel page. +*/ + +unsigned long suspend2_get_nonconflicting_page (void ) +{ +return suspend2_get_nonconflicting_pages (0 ); +}
Can you just replace it in callers?
kernel/power/suspend2_core/pagedir.h line 24
Quoted 2 lines
kernel/power/suspend2_core/pagedir.h +2
-0+#define pageset1_size (pagedir1.pageset_size) +#define pageset2_size (pagedir2.pageset_size)
This only makes reading code harder...
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [40/48] Suspend2 2.1.9.8 for 2.6.12: 616-prepare_image.patch
In reply to Nigel CunninghamHi!
Quoted 38 lines
diff -ruNp
617-proc.patch-old/kernel/power/suspend2_core/proc.c617-proc.patch-new/kernel/power/suspend2_core/proc.ckernel/power/suspend2_core/proc.c +34
-0@@ -0,0 +1,336 @@ +/* +* /kernel/power/proc.c +* +* Copyright (C) 2002-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* This file contains support for proc entries for tuning Software Suspend. +* +* We have a generic handler that deals with the most common cases, and +* hooks for special handlers to use. +* +* Versions: +* 1: /proc/sys/kernel/suspend the only tuning interface +* 2: Initial version of this file +* 3: Removed kernel debugger parameter. +* Added checkpage parameter (for checking checksum of a page over time). +* 4: Added entry for maximum granularity in splash screen progress bar. +* (Progress bar is slow, but the right setting will vary with disk & +* processor speed and the user's tastes). +* 5: Added enable_escape to control ability to cancel aborting by pressing +* ESC key. +* 6: Removed checksumming and checkpage parameter. Made all debugging proc +* entries dependant upon debugging being compiled in. +* Meaning of some flags also changed in this version. +* 7: Added header_locations entry to simplify getting the resume= parameter for +* swapfiles easy and swapfile entry for automatically doing swapon/off from +* swapfiles as well as partitions. +* 8: Added option for marking process pages as pageset 2 (processes_pageset2). +* 9: Added option for keep image mode. +* Enumeration patch from Michael Frank applied. +* 10: Various corrections to when options are disabled/enabled; +* Added option for specifying expected compression. +* 11: Added option for freezer testing. Debug only.
kernel/power/suspend2_core/proc.c line 44
Quoted 10 lines
kernel/power/suspend2_core/proc.c +10
-0+* 12: Removed test entries no_async_[read|write], processes_pageset2 and +* NoPageset2. +* 13: Make default_console_level available when debugging disabled, but limited +* to 0 or 1. +* 14: Rewrite to allow for dynamic registration of proc entries and smooth the +* transition to kobjects in 2.6. +* 15: Add setting resume2 parameter without rebooting (still need to run lilo +* though!). Add support for generic string handling and switch resume2 to use +* it. +* 16: Switched to cryptoapi, adding entries for selecting encryptor and compressor.
Pretty please, can we support just one version?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [33/48] Suspend2 2.1.9.8 for 2.6.12: 610-encryption.patch
In reply to Nigel CunninghamHi!
kernel/power/suspend2_core/extent.c line 86
Quoted 6 lines
kernel/power/suspend2_core/extent.c +6
-0+/* +* put_extent_chain. +* +* Frees a whole chain of extents. +*/ +void put_extent_chain (struct extentchain * chain)
This probably should be extent_chain.
kernel/power/suspend2_core/extent.h line 21
Quoted 8 lines
kernel/power/suspend2_core/extent.h +8
-0+#ifndef EXTENT_H +#define EXTENT_H +struct extentchain { + int size; /* size of the extent ie sum (max-min+1) */ + int allocs; + int frees; + int debug; + int timesusedoptimisation;
time_suse_d_optimisation? ;-).
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [39/48] Suspend2 2.1.9.8 for 2.6.12: 615-poweroff.patch
In reply to Nigel CunninghamHi!
Quoted 11 lines
kernel/power/suspend2_core/prepare_image.c +10
-0@@ -0,0 +1,585 @@ +/* +* kernel/power/prepare_image.c +* +* Copyright (C) 2003-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* We need to eat memory until we can: +* 1. Perform the save without changing anything (RAM_NEEDED < max_mapnr) +* 2. Fit it all in available space (active_writer->available_space() >= STORAGE_NEEDED)
kernel/power/suspend2_core/prepare_image.c line 20
Quoted 10 lines
kernel/power/suspend2_core/prepare_image.c +10
-0+* 3. Reload the pagedir and pageset1 to places that don't collide with their +* final destinations, not knowing to what extent the resumed kernel will +* overlap with the one loaded at boot time. I think the resumed kernel should overlap +* completely, but I don't want to rely on this as it is an unproven assumption. We +* therefore assume there will be no overlap at all (worse case). +* 4. Meet the user's requested limit (if any) on the size of the image. +* The limit is in MB, so pages/256 (assuming 4K pages). +* +* (Final test in save_image doesn't use EATEN_ENOUGH_MEMORY) +*/
Can you just fix/use shrink_all_memory().
kernel/power/suspend2_core/prepare_image.c line 33
Quoted 1 line
kernel/power/suspend2_core/prepare_image.c +1
-0+#define EATEN_ENOUGH_MEMORY () (amount_needed(1) < 1)
Hmm...
kernel/power/suspend2_core/prepare_image.c line 34
Quoted 1 line
kernel/power/suspend2_core/prepare_image.c +1
-0+static int arefrozen =0 , numnosave =0 ;
Missing _s.
Quoted 27 lines
kernel/power/suspend2_core/prepare_image.c +27
-0+/* display_stats +* +* Display the vital statistics.of the image. +*/ +#ifdef CONFIG_PM_DEBUG +static void display_stats (void ) +{ + storage_allocated = active_writer->ops.writer.storage_allocated (); + suspend_message(SUSPEND_EAT_MEMORY, SUSPEND_MEDIUM, 1, + "Free:%d(%d). Sets:%d(%d),%d(%d). Nosave:%d-%d=%d. Storage:%d/%d+%d=%d(%lu). Needed:%d|%d|%d.\n", + + /* Free */ + real_nr_free_pages(), + real_nr_free_pages() - nr_free_highpages(), + + /* Sets */ + pageset1_size, pageset1_sizelow, + pageset2_size, pageset2_sizelow, + + /* Nosave */ + numnosave, extra_pagedir_pages_allocated, + numnosave - extra_pagedir_pages_allocated, + + /* Storage */ + storage_allocated, + MAIN_STORAGE_NEEDED(1), HEADER_STORAGE_NEEDED, + STORAGE_NEEDED(1),
kernel/power/suspend2_core/prepare_image.c line 277
Quoted 10 lines
kernel/power/suspend2_core/prepare_image.c +10
-0+ storage_available, + +/* Needed */ +RAM_TO_SUSPEND -real_nr_free_pages () -nr_free_highpages (), +STORAGE_NEEDED (1 ) - storage_available, + (image_size_limit > 0) ? (STORAGE_NEEDED(1) - (image_size_limit << 8)) : 0); +} +#else +#define display_stats () do { } while(0) +#endif
Is this kind of debugging neccessary any more?
Quoted 15 lines
kernel/power/suspend2_core/prepare_image.h +15
-0+#define MIN_FREE_RAM (max_low_pfn >> 7) + +#define EXTRA_PD1_PAGES_ALLOWANCE 100 + +#define MAIN_STORAGE_NEEDED (USE_ECR ) \ + ((pageset1_size + pageset2_size + 100 + \ + EXTRA_PD1_PAGES_ALLOWANCE) * \ + (USE_ECR ? expected_compression_ratio() : 100) / 100) + +#define HEADER_BYTES_NEEDED \ + ((extents_allocated * 2 * sizeof(unsigned long)) + \ + sizeof(struct suspend_header) + \ + sizeof(struct plugin_header) + \ + (int) header_storage_for_plugins() + \ + (PAGES_PER_BITMAP << PAGE_SHIFT) + \
kernel/power/suspend2_core/prepare_image.h line 43
Quoted 10 lines
kernel/power/suspend2_core/prepare_image.h +10
-0+ num_plugins * \ + (sizeof(struct plugin_header) + sizeof(int))) + +#define HEADER_STORAGE_NEEDED ((int) ((HEADER_BYTES_NEEDED + (int) PAGE_SIZE - 1) >> PAGE_SHIFT)) + +#define STORAGE_NEEDED (USE_ECR ) \ + (MAIN_STORAGE_NEEDED(USE_ECR) + HEADER_STORAGE_NEEDED) + +#define RAM_TO_SUSPEND (1 + max((pageset1_size + EXTRA_PD1_PAGES_ALLOWANCE - pageset2_sizelow), 0) + \ + MIN_FREE_RAM + memory_for_plugins())
Can we convert this to inline functions or something?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [42/48] Suspend2 2.1.9.8 for 2.6.12: 618-core.patch
In reply to Nigel CunninghamHi!
Have you seen Christoph's recent fixes to refrigerator? You probably have same problems..... And he wanted to move refrigerator to sched/ and make it more generic for page migration, too... what about using it, too? ;-).
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [44/48] Suspend2 2.1.9.8 for 2.6.12: 620-userui.patch
In reply to Nigel Cunninghamkernel/power/swsusp.c line 39
Quoted 8 lines · Nigel Cunningham
diff -ruNp
621-swsusp-tidy.patch-old/kernel/power/swsusp.c621-swsusp-tidy.patch-new/kernel/power/swsusp.ckernel/power/swsusp.c +1
-0@@ -36,6 +36,8 @@* For TODOs,FIXMEs also look in Documentation/power/swsusp.txt */ +#define KERNEL_POWER_SWSUSP_C
Headers that change depending on #define's are considered evil......
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [47/48] Suspend2 2.1.9.8 for 2.6.12: 623-generic-block-io.patch
In reply to Nigel CunninghamHi!
Quoted 14 lines
kernel/power/suspend_file.c +14
-0+static int target_type =-1 ; + +/* +static char * description[7] = { +"Socket", +"Link", +"Regular file", +"Block device", +"Directory", +"Character device", +"Fifo", +}; +*/ +
...
Quoted 28 lines
kernel/power/suspend_file.c +28
-0+/* +* Helpers. +*/ + +/* +* Return the type of target we have, an index into the descriptions +* above. +*/ +static int get_target_type (struct inode * inode) +{ +switch (inode->i_mode &S_IFMT ) { +case S_IFSOCK : + target_type =0 ; +break ; +case S_IFLNK : + target_type =1 ; +break ; +case S_IFREG : + target_type =2 ; +break ; +case S_IFBLK : + target_type =3 ; +break ; +case S_IFDIR : + target_type =4 ; +break ; +case S_IFCHR : + target_type =5 ;
kernel/power/suspend_file.c line 219
Quoted 10 lines
kernel/power/suspend_file.c +10
-0+break ; +case S_IFIFO : + target_type =6 ; +break ; + } +return target_type; +} + +#define target_is_usable (!(target_type == 1 || target_type == 4)) +#define target_num_sectors (target_inode->i_size >> target_blkbits)
Why do you need this?
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [13/48] Suspend2 2.1.9.8 for 2.6.12: 403-debug-pagealloc-support.patch
In reply to Nigel Cunninghamthis is missing a description. But I don't think that one is gonna help, we're not gonna add truckloads of crap just to print a warning when a user shoots himself in his foot.
Re: [PATCH] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch
In reply to Nigel CunninghamPlease add an explanation why this is nessecary. Big NACK for the patch as-is, but to find a proper solution we need to know what you're actually doing.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
In reply to Nigel CunninghamAgain, why do you think you need this?
Re: [PATCH] [7/48] Suspend2 2.1.9.8 for 2.6.12: 352-disable-pdflush-during-suspend.patch
In reply to Nigel Cunninghamno explanation and even the subject doesn't match patch contents..
Re: [PATCH] [12/48] Suspend2 2.1.9.8 for 2.6.12: 402-mtrr-remove-sysdev.patch
In reply to Nigel CunninghamSo what's this deep magic doing? And why do you add such crude function for debug pagealloc builds only?
Re: [PATCH] [10/48] Suspend2 2.1.9.8 for 2.6.12: 360-reset-kswapd-max-order-after-resume.patch
In reply to Nigel CunninghamSo what is this doing, and is it breaking swsusp support?
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Nigel CunninghamPlease send new crytptoapi algorithms to the cryptoapi maintainers for review. It's something that's completely independent of any software suspend stuff.
Re: [PATCH] [43/48] Suspend2 2.1.9.8 for 2.6.12: 619-userspace-nofreeze.patch
In reply to Nigel CunninghamUI support is nothing that belongs here. People won't die by having a text console for a while.
This submissions is completely useless. 48 patches without description and a subbject lines that hides the little information even more.
Please start again, and only with useful patches that on their own, against -mm and with detailed explanations of each patch.
Re: [PATCH] [30/48] Suspend2 2.1.9.8 for 2.6.12: 607-atomic-copy.patch
In reply to Pavel MachekHi.
Quoted 11 lines · Pavel Machek
Hi!
Quoted 3 lines
---
608-compression.patch-old/kernel/power/suspend2_core/compression.c1970-01-01 10:00:00.000000000 +1000
+++608-compression.patch-new/kernel/power/suspend2_core/compression.c~~~~~~~~~~~~~
suspend2_corelooks like an extremely bad name for a directory... And this is really plugin, not a core, no? Plus it would be nice to drop non-essential stuff for initial submit, so that it is not *that* big to review.
Suspend2_core was just to keep things nicely separated for the moment. I've already shifted everything into kernel/power after Pekka's email.
Regarding non essential stuff, the compression and encryption parts are really quite small. LZF Compression doubles the speed, and encryption is considered important by people who care about security. It also helps you see why the plugin stuff is useful. Of course plugin isn't really the right name anymore - it's more of an internal api.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [29/48] Suspend2 2.1.9.8 for 2.6.12: 606-all-settings.patch
In reply to Pavel MachekHi.
Quoted 16 lines · Pavel Machek
Hi!
kernel/power/suspend2_core/atomic_copy.c line 170
Quoted 9 lines
kernel/power/suspend2_core/atomic_copy.c +9
-0+static void suspend2_suspend_2 (void ) +{ +if (!save_image_part1 ()) { +suspend_power_down (); + +if (suspend2_powerdown_method ==3 ) { +int temp_result; + + temp_result =read_pageset2 (1 );Is that just me or do I see way too many numbers.
suspend2_suspend_2is really funny name for a functions.powerdown_methodshould really use some symbolic constants.
No, it's not just you. It's one of those hangovers from the original code that I hadn't gotten around to cleaning up.
Symbolic constants now in place for the powerdown method too.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [38/48] Suspend2 2.1.9.8 for 2.6.12: 614-plugins.patch
In reply to Pavel MachekHi.
Quoted 11 lines · Pavel Machek
Hi!
Quoted 1 line
+unsigned long
suspend2_powerdown_method= 5; /* S5 = off */Constants.....
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (suspend2_powerdown_method == 3 || + suspend2_powerdown_method == 4)Constants...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (suspend2_powerdown_method == 3 || + suspend2_powerdown_method == 4)Constants...
Once per file is enough :>
Quoted 9 lines
kernel/power/suspend2_core/power_off.c line 137
Quoted 6 lines
kernel/power/suspend2_core/power_off.c +6
-0+suspend2_prepare_status (1 ,0 ,"Ready to reboot." ); +suspend2_prepare_status (1 ,0 ,"Seeking to enter ACPI state" ); +suspend2_prepare_status (1 ,0 ,"Preparing to enter ACPI state failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Suspending devices failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Entering ACPI state failed. Using normal powerdown." ); +suspend2_prepare_status (1 ,0 ,"Powering down." );Too many magical constants here... Plus I don't really like your own logging subsystem.
The first parameter isn't needed anymore - gone. Second one changed to an enum DONT_CLEAR_BAR | CLEAR_BAR.
Not liking it - that's alright there's some code you've written that I don't like either :>
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [43/48] Suspend2 2.1.9.8 for 2.6.12: 619-userspace-nofreeze.patch
In reply to Christoph HellwigHi.
Quoted 2 lines · Christoph Hellwig
UI support is nothing that belongs here. People won't die by having a text console for a while.
UI support belongs here for the following reasons:
- While driver support is imperfect, there is the potential for hangs. People need to be able to recognise when this happens. They therefore need some feedback to know that the process is not hung, and to be able to say where it hung when it does.
- Particularly for the desktop, we want the system to look professional, not half baked.
- Some support is needed for the user to be able to cancel a suspend. You might not want to. Others might not want to, but this doesn't mean that others shouldn't have the option of changing their minds.
I have already moved much of the code out to userspace in an effort to ease your concerns. I'm not going so far as to remove the functionality, though.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [48/48] Suspend2 2.1.9.8 for 2.6.12: 624-filewriter.patch
In reply to Christoph HellwigHi.
Quoted 2 lines · Christoph Hellwig
Please send new crytptoapi algorithms to the cryptoapi maintainers for review. It's something that's completely independent of any software suspend stuff.
Thanks.
Did this about a week prior to sending the patches. Sorry - including this in the patches posted was an oversight.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [12/48] Suspend2 2.1.9.8 for 2.6.12: 402-mtrr-remove-sysdev.patch
In reply to Christoph HellwigHi.
Quoted 2 lines · Christoph Hellwig
So what's this deep magic doing? And why do you add such crude function for debug pagealloc builds only?
For debug_pagealloc, the pages we want to save and restore need to be mapped for the the atomic copy, and unmapped afterwards. This function achieves that.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Hi.
Quoted 2 lines · Christoph Hellwig
This submissions is completely useless. 48 patches without description and a subbject lines that hides the little information even more.
Yes. My mistake with the subject lines. Sorry. I'll also add better descriptions when I repost.
Quoted 2 lines
Please start again, and only with useful patches that on their own, against -mm and with detailed explanations of each patch.
First I'll act on feedback from this round. Regarding diffing against -mm, I though Andrew wanted patches against Linus' tree. I'm happy to do both. Andrew?
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
In reply to Christoph HellwigHi.
Quoted 1 line · Christoph Hellwig
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Quoted 4 lines · Nigel Cunningham
First I'll act on feedback from this round. Regarding diffing against
-mm, I though Andrew wanted patches against Linus' tree. I'm happy to do both. Andrew?
Is it anywhere near being ready?
Am still futzing with the ongoing pm_message_t saga here. I hope there's no overlap with that.
Re: [PATCH] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch
In reply to Christoph HellwigHi.
Quoted 2 lines · Christoph Hellwig
Please add an explanation why this is nessecary. Big NACK for the patch as-is, but to find a proper solution we need to know what you're actually doing.
When the user has an initrd or initramfs, they're supposed to include
echo > /proc/software_suspend/do_resume
at the point in their initrd where drivers needed for accessing the image, encryption keys and so on have been set up, but the root fs has not yet been mounted. If they don't do that, we should scream loudly, because mounting the root fs (even read only) will replay the journal, making the image not match what is on disk. This in turn can and probably will result in hard disk corruption if they echo to do_resume from say /etc/rc.d/rc.sysinit.
In addition, the try_to_freeze call is needed because, having loaded an image, we freeze kernel threads before doing the atomic restore.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [13/48] Suspend2 2.1.9.8 for 2.6.12: 403-debug-pagealloc-support.patch
In reply to Christoph HellwigHi.
Quoted 3 lines · Christoph Hellwig
this is missing a description. But I don't think that one is gonna help, we're not gonna add truckloads of crap just to print a warning when a user shoots himself in his foot.
I would like to improve this so we actually check the mount time for the filesystems, but this was a simpler intermediate step.
It may seem superfluous to you, but Suspend2 has over 12,000 users, and not all of them are expert users. Not everyone gets it right first time.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Hi.
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Nigel Cunningham
First I'll act on feedback from this round. Regarding diffing against
-mm, I though Andrew wanted patches against Linus' tree. I'm happy to do both. Andrew?Is it anywhere near being ready?
Yes. Development has almost stopped. I'm just addressing the responses from last week's email and then will send again, so yes. Here's my todo list (some done already):
Todo list as at 12 July 2005.
FIX.
- Check for redundant variables & functions and remove.
- Ensure driver model calls are right (Bug 45).
- NFS issue (Bug 52)
COMPLETE.
- Opteron support (Bug 1).
- Documentation cleanups.
IMPLEMENT.
- 64GB support.
- IA64 support.
- Implement remembering compression ratio acheived using another method apart
from LZF plugin.
HCH/Pavel Replies.
- Setting NoSave pages early.
- Amount needed parameter.
- Add underscores to variable names.
- Inline functions for image preparation (storage needed etc).
- Debugging code from extents.
- extenchain -> extent_chain
- Patch descriptions/rationales.
- Against mm.
- Remove #define XXX_C
Quoted 2 lines
Am still futzing with the ongoing
pm_message_tsaga here. I hope there's no overlap with that.
We've been using pm_message_t in Suspend2 since February, so we should already be where you're heading.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [44/48] Suspend2 2.1.9.8 for 2.6.12: 620-userui.patch
In reply to Pavel MachekHi
Quoted 11 lines · Pavel Machek
kernel/power/swsusp.c line 39
Quoted 8 lines · Nigel Cunningham
diff -ruNp
621-swsusp-tidy.patch-old/kernel/power/swsusp.c621-swsusp-tidy.patch-new/kernel/power/swsusp.ckernel/power/swsusp.c +1
-0@@ -36,6 +36,8 @@* For TODOs,FIXMEs also look in Documentation/power/swsusp.txt */ +#define KERNEL_POWER_SWSUSP_C Headers that change depending on #define's are considered evil......
Fixed. Thanks!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [42/48] Suspend2 2.1.9.8 for 2.6.12: 618-core.patch
In reply to Pavel MachekHi.
Quoted 6 lines · Pavel Machek
Hi!
Have you seen Christoph's recent fixes to refrigerator? You probably have same problems..... And he wanted to move refrigerator to sched/ and make it more generic for page migration, too... what about using it, too? ;-).
Yeah. I'm using them already. I must say though that I don't think sched.h is necessarily the best place for the refrigerator defines. Any change to those functions and you have to recompile most of the kernel. Is a refrigerator.h an idea?
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [42/48] Suspend2 2.1.9.8 for 2.6.12: 618-core.patch
Hi!
Quoted 9 lines
Quoted 4 lines
Have you seen Christoph's recent fixes to refrigerator? You probably have same problems..... And he wanted to move refrigerator to sched/ and make it more generic for page migration, too... what about using it, too? ;-).
Yeah. I'm using them already. I must say though that I don't think
sched.his necessarily the best place for the refrigerator defines. Any change to those functions and you have to recompile most of the kernel. Is arefrigerator.han idea?
I do not think those recompiles pose a big problem; we don't want million separate headers. I'd trust Christoph with this.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [39/48] Suspend2 2.1.9.8 for 2.6.12: 615-poweroff.patch
In reply to Pavel MachekHi.
Quoted 17 lines · Pavel Machek
Hi!
Quoted 15 lines
kernel/power/suspend2_core/prepare_image.c +14
-0@@ -0,0 +1,585 @@ +/* +* kernel/power/prepare_image.c +* +* Copyright (C) 2003-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* We need to eat memory until we can: +* 1. Perform the save without changing anything (RAM_NEEDED < max_mapnr) +* 2. Fit it all in available space (active_writer->available_space() >= STORAGE_NEEDED) +* 3. Reload the pagedir and pageset1 to places that don't collide with their +* final destinations, not knowing to what extent the resumed kernel will +* overlap with the one loaded at boot time. I think the resumed kernel should overlap +* completely, but I don't want to rely on this as it is an unproven assumption. We
Quoted 8 lines
kernel/power/suspend2_core/prepare_image.c line 20
Quoted 6 lines
kernel/power/suspend2_core/prepare_image.c +6
-0+* therefore assume there will be no overlap at all (worse case). +* 4. Meet the user's requested limit (if any) on the size of the image. +* The limit is in MB, so pages/256 (assuming 4K pages). +* +* (Final test in save_image doesn't use EATEN_ENOUGH_MEMORY) +*/ Can you just fix/use
shrink_all_memory().
We are using shrink_all_memory now. We just try to be intelligent about how much memory gets freed. Most of the time, very little needs to be released in order to suspend, and you get a more responsive system than if you free all and sundry and then have to swap it back in post-resume. If the use really wants to emulate swsusp and free everything they can, they can just set the imagesize limit to 1MB. (It's a soft limit).
Quoted 7 lines
kernel/power/suspend2_core/prepare_image.c line 33
Quoted 1 line
kernel/power/suspend2_core/prepare_image.c +1
-0+#define EATEN_ENOUGH_MEMORY () (amount_needed(1) < 1)Hmm...
kernel/power/suspend2_core/prepare_image.c line 34
Quoted 1 line
kernel/power/suspend2_core/prepare_image.c +1
-0+static int arefrozen =0 , numnosave =0 ;Missing _s.
Fixed. Thanks.
Quoted 31 lines
Quoted 31 lines
kernel/power/suspend2_core/prepare_image.c +31
-0+/* display_stats +* +* Display the vital statistics.of the image. +*/ +#ifdef CONFIG_PM_DEBUG +static void display_stats (void ) +{ + storage_allocated = active_writer->ops.writer.storage_allocated (); + suspend_message(SUSPEND_EAT_MEMORY, SUSPEND_MEDIUM, 1, + "Free:%d(%d). Sets:%d(%d),%d(%d). Nosave:%d-%d=%d. Storage:%d/%d+%d=%d(%lu). Needed:%d|%d|%d.\n", + + /* Free */ + real_nr_free_pages(), + real_nr_free_pages() - nr_free_highpages(), + + /* Sets */ + pageset1_size, pageset1_sizelow, + pageset2_size, pageset2_sizelow, + + /* Nosave */ + numnosave, extra_pagedir_pages_allocated, + numnosave - extra_pagedir_pages_allocated, + + /* Storage */ + storage_allocated, + MAIN_STORAGE_NEEDED(1), HEADER_STORAGE_NEEDED, + STORAGE_NEEDED(1), + storage_available, + + /* Needed */ + RAM_TO_SUSPEND - real_nr_free_pages() - nr_free_highpages(),
Quoted 8 lines
kernel/power/suspend2_core/prepare_image.c line 277
Quoted 6 lines
kernel/power/suspend2_core/prepare_image.c +6
-0+STORAGE_NEEDED (1 ) - storage_available, + (image_size_limit > 0) ? (STORAGE_NEEDED(1) - (image_size_limit << 8)) : 0); +} +#else +#define display_stats () do { } while(0) +#endif Is this kind of debugging neccessary any more?
Not very often. Removed. I can re-add when necessary.
Quoted 19 lines
Quoted 19 lines
kernel/power/suspend2_core/prepare_image.h +19
-0+#define MIN_FREE_RAM (max_low_pfn >> 7) + +#define EXTRA_PD1_PAGES_ALLOWANCE 100 + +#define MAIN_STORAGE_NEEDED (USE_ECR ) \ + ((pageset1_size + pageset2_size + 100 + \ + EXTRA_PD1_PAGES_ALLOWANCE) * \ + (USE_ECR ? expected_compression_ratio() : 100) / 100) + +#define HEADER_BYTES_NEEDED \ + ((extents_allocated * 2 * sizeof(unsigned long)) + \ + sizeof(struct suspend_header) + \ + sizeof(struct plugin_header) + \ + (int) header_storage_for_plugins() + \ + (PAGES_PER_BITMAP << PAGE_SHIFT) + \ + num_plugins * \ + (sizeof(struct plugin_header) + sizeof(int))) + +#define HEADER_STORAGE_NEEDED ((int) ((HEADER_BYTES_NEEDED + (int) PAGE_SIZE - 1) >> PAGE_SHIFT))
Quoted 8 lines
kernel/power/suspend2_core/prepare_image.h line 43
Quoted 6 lines
kernel/power/suspend2_core/prepare_image.h +6
-0+ +#define STORAGE_NEEDED (USE_ECR ) \ + (MAIN_STORAGE_NEEDED(USE_ECR) + HEADER_STORAGE_NEEDED) + +#define RAM_TO_SUSPEND (1 + max((pageset1_size + EXTRA_PD1_PAGES_ALLOWANCE - pageset2_sizelow), 0) + \ + MIN_FREE_RAM + memory_for_plugins())Can we convert this to inline functions or something?
Done.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [33/48] Suspend2 2.1.9.8 for 2.6.12: 610-encryption.patch
In reply to Pavel Machek'ello!
Quoted 11 lines · Pavel Machek
Hi!
kernel/power/suspend2_core/extent.c line 86
Quoted 6 lines
kernel/power/suspend2_core/extent.c +6
-0+/* +* put_extent_chain. +* +* Frees a whole chain of extents. +*/ +void put_extent_chain (struct extentchain * chain)This probably should be
extent_chain.
Quoted 10 lines
kernel/power/suspend2_core/extent.h line 21
Quoted 8 lines
kernel/power/suspend2_core/extent.h +8
-0+#ifndef EXTENT_H +#define EXTENT_H +struct extentchain { + int size; /* size of the extent ie sum (max-min+1) */ + int allocs; + int frees; + int debug; + int timesusedoptimisation;
time_suse_d_optimisation? ;-).
Fixed up!
Thanks, once again!
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [40/48] Suspend2 2.1.9.8 for 2.6.12: 616-prepare_image.patch
In reply to Pavel MachekHi.
Quoted 44 lines · Pavel Machek
Hi!
Quoted 42 lines
diff -ruNp
617-proc.patch-old/kernel/power/suspend2_core/proc.c617-proc.patch-new/kernel/power/suspend2_core/proc.ckernel/power/suspend2_core/proc.c +38
-0@@ -0,0 +1,336 @@ +/* +* /kernel/power/proc.c +* +* Copyright (C) 2002-2005 Nigel Cunningham <[email protected]> +* +* This file is released under the GPLv2. +* +* This file contains support for proc entries for tuning Software Suspend. +* +* We have a generic handler that deals with the most common cases, and +* hooks for special handlers to use. +* +* Versions: +* 1: /proc/sys/kernel/suspend the only tuning interface +* 2: Initial version of this file +* 3: Removed kernel debugger parameter. +* Added checkpage parameter (for checking checksum of a page over time). +* 4: Added entry for maximum granularity in splash screen progress bar. +* (Progress bar is slow, but the right setting will vary with disk & +* processor speed and the user's tastes). +* 5: Added enable_escape to control ability to cancel aborting by pressing +* ESC key. +* 6: Removed checksumming and checkpage parameter. Made all debugging proc +* entries dependant upon debugging being compiled in. +* Meaning of some flags also changed in this version. +* 7: Added header_locations entry to simplify getting the resume= parameter for +* swapfiles easy and swapfile entry for automatically doing swapon/off from +* swapfiles as well as partitions. +* 8: Added option for marking process pages as pageset 2 (processes_pageset2). +* 9: Added option for keep image mode. +* Enumeration patch from Michael Frank applied. +* 10: Various corrections to when options are disabled/enabled; +* Added option for specifying expected compression. +* 11: Added option for freezer testing. Debug only. +* 12: Removed test entries no_async_[read|write], processes_pageset2 and +* NoPageset2. +* 13: Make default_console_level available when debugging disabled, but limited +* to 0 or 1.
Quoted 8 lines
kernel/power/suspend2_core/proc.c line 44
Quoted 6 lines
kernel/power/suspend2_core/proc.c +6
-0+* 14: Rewrite to allow for dynamic registration of proc entries and smooth the +* transition to kobjects in 2.6. +* 15: Add setting resume2 parameter without rebooting (still need to run lilo +* though!). Add support for generic string handling and switch resume2 to use +* it. +* 16: Switched to cryptoapi, adding entries for selecting encryptor and compressor. Pretty please, can we support just one version?
It is just one version supported. This is a log of the changes made. Sorry for the ambiguity.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [28/48] Suspend2 2.1.9.8 for 2.6.12: 605-kernel_power_suspend.patch
In reply to Pavel MachekHi.
Quoted 5 lines · Pavel Machek
Hi!
Quoted 3 lines
diff -ruNp
606-all-settings.patch-old/kernel/power/suspend2_core/all_settings.c606-all-settings.patch-new/kernel/power/suspend2_core/all_settings.ckernel/power/suspend2_core/all_settings.c +0
-0
[...]
Quoted 8 lines
Quoted 5 lines
+ * This entry allows all of the settings to be set at once.
+ * It was originally for compatibility with pre-/proc/suspend
+ * versions, but has been retained because it makes saving and
+ * restoring the configuration simpler.
+ */Okay, and it is also extremely ugly. Now you have chance to clean it up, please drop it.
After checking with users, done.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [35/48] Suspend2 2.1.9.8 for 2.6.12: 611-io.patch
In reply to Pavel MachekHi.
Quoted 5 lines · Pavel Machek
Hi!
kernel/power/suspend2_core/pagedir.c line 109
Quoted 1 line
kernel/power/suspend2_core/pagedir.c +1
-0+//p->pageset_size = pageset_size; Please don't leave commented code in.
Fixed.
Quoted 40 lines
Quoted 40 lines
kernel/power/suspend2_core/pagedir.c +40
-0+unsigned long suspend2_get_nonconflicting_pages (const int order) +{ +struct page * page; +unsigned long new_page; +int more =0 ; +unsigned long pgcount; + +do { + new_page =__get_free_pages (GFP_ATOMIC | __GFP_NOWARN, order); +if (!new_page) +return 0 ; + more =0 ; +for (pgcount =0 ; pgcount < (1UL << order); pgcount++) { + page =virt_to_page (new_page +PAGE_SIZE * pgcount); +if (PagePageset1 (page)) { + more =1 ; +break ; + } + } +if (more) { + page =virt_to_page (new_page); +list_add (&page->lru, &conflicting_pages); + +/* since this page is technically free, we can abuse it to +* store the order. When we resume it'll just be overwritten, +* but we need this value when freeing it in +* suspend2_release_conflicting_pages. */ + *((int *)new_page) = order; + } + } +while (more); + +memset ((void *)new_page,0 ,PAGE_SIZE * (1 <<order)); +return new_page; +} + +/* suspend2_get_nonconflicting_page +* +* Description: Gets a page that will not be overwritten as we copy the +* original kernel page.
Quoted 8 lines
kernel/power/suspend2_core/pagedir.c line 264
Quoted 6 lines
+ */
kernel/power/suspend2_core/pagedir.c +5
-0+ +unsigned long suspend2_get_nonconflicting_page (void ) +{ +return suspend2_get_nonconflicting_pages (0 ); +}Can you just replace it in callers?
Done.
Quoted 4 lines
kernel/power/suspend2_core/pagedir.h line 24
Quoted 2 lines
kernel/power/suspend2_core/pagedir.h +2
-0+#define pageset1_size (pagedir1.pageset_size) +#define pageset2_size (pagedir2.pageset_size)This only makes reading code harder...
Removed.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [10/48] Suspend2 2.1.9.8 for 2.6.12: 360-reset-kswapd-max-order-after-resume.patch
In reply to Christoph HellwigQuoted 1 line · Christoph Hellwig
So what is this doing, and is it breaking swsusp support?
Marking at boot time pages that shouldn't be saved. I'm not sure why Pavel doesn't seem to need it. None of these changes break Pavel's code.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch
In reply to a message not in the archiveHi.
Quoted 8 lines · Matthew Garrett
Quoted 3 lines · Nigel Cunningham
When the user has an initrd or initramfs, they're supposed to include
echo >
/proc/software_suspend/do_resumeThis is a different interface to the one in swsusp, which is under /sys. Do we really need to keep multiple interfaces to the same functionality?
We already have that - the reboot handler, acpi S4 support and the sysfs interface. This should have been asked when sysfs was added :>. For the sake of backwards compatibility for current suspend2 users, it should stay for a while at least. The other thing here is that there is much more to /proc/software_suspend than do_resume.
Quoted 11 lines
Quoted 7 lines
at the point in their initrd where drivers needed for accessing the image, encryption keys and so on have been set up, but the root fs has not yet been mounted. If they don't do that, we should scream loudly, because mounting the root fs (even read only) will replay the journal, making the image not match what is on disk. This in turn can and probably will result in hard disk corruption if they echo to
do_resumefrom say/etc/rc.d/rc.sysinit.In general, the kernel does very little to prevent users from shooting themselves in the foot (or even chainsawing off their arms). We can do these checks in userspace rather than adding more kernel code.
Just because the kernel does very little, that doesn't mean it should. Particularly for something like suspend to disk, where it's not just a matter of an oops but of potential hard disk corruption, this is important.
If I could do it in userspace, I would. The trouble is, the userspace app may not be there to tell the user what is happening, and this might be part of the problem.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch
Quoted 9 lines · Nigel Cunningham
Quoted 3 lines · Matthew Garrett
In general, the kernel does very little to prevent users from shooting themselves in the foot (or even chainsawing off their arms). We can do these checks in userspace rather than adding more kernel code.
Just because the kernel does very little, that doesn't mean it should. Particularly for something like suspend to disk, where it's not just a matter of an oops but of potential hard disk corruption, this is important.
The kernel isn't there to protect people. It's there to provide functionality.
Quoted 3 lines
If I could do it in userspace, I would. The trouble is, the userspace app may not be there to tell the user what is happening, and this might be part of the problem.
You're suggesting that users who are technically competent to compile their own kernel and write their own initrd scripts are unable to deal with checking whether or not a filesystem is mounted? You don't need an application to do that, it's a simple matter of shell scripting. And, in almost every case, if something is a simple matter of shell scripting it shouldn't be in the kernel.
Signature · 1 line
Matthew Garrett | [email protected]
Hi.
Quoted 2 lines · Andrew Morton
Am still futzing with the ongoing
pm_message_tsaga here. I hope there's no overlap with that.
Perhaps I can help there. I've been preparing a patchset against the latest mm. Here's a patch with additional changes I know about.
Hope it's helpful.
Regards,
Nigel
arch/ppc/platforms/pmac_pic.c | 2 +- arch/ppc/syslib/open_pic.c | 2 +- drivers/base/power/resume.c | 8 ++++---- drivers/base/power/runtime.c | 8 ++++---- drivers/base/power/suspend.c | 14 +++++++------- drivers/base/power/sysfs.c | 9 +++++---- drivers/ide/ide.c | 2 +- drivers/ide/pci/sc1200.c | 8 ++++---- drivers/ide/ppc/pmac.c | 16 ++++++++-------- drivers/macintosh/mediabay.c | 6 +++--- drivers/macintosh/via-pmu.c | 2 +- drivers/media/dvb/cinergyT2/cinergyT2.c | 2 +- drivers/media/video/bttv-driver.c | 2 +- drivers/net/irda/vlsi_ir.c | 18 ++++++++++-------- drivers/net/wireless/airo.c | 3 ++- drivers/net/wireless/orinoco_pci.c | 2 +- drivers/net/wireless/prism54/islpci_hotplug.c | 2 +- drivers/pci/pci.c | 11 +++++++---- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/serial/pmac_zilog.c | 6 +++--- drivers/usb/core/hub.c | 18 +++++++++--------- drivers/usb/core/usb.c | 2 +- drivers/usb/host/ehci-dbg.c | 2 +- drivers/usb/host/ohci-dbg.c | 2 +- drivers/usb/host/sl811-hcd.c | 6 +++--- drivers/video/aty/aty128fb.c | 12 ++++++------ drivers/video/aty/atyfb_base.c | 10 +++++----- drivers/video/aty/radeon_pm.c | 12 ++++++------ drivers/video/i810/i810_main.c | 22 ++++++++-------------- drivers/video/savage/savagefb_driver.c | 2 +- include/linux/pm.h | 18 ++++++++++++++---- sound/pci/atiixp.c | 4 ++-- 32 files changed, 123 insertions(+), 112 deletions(-)
arch/ppc/platforms/pmac_pic.c +1 -1
@@ -619,7 +619,7 @@ not_found:return viaint; } -static int pmacpic_suspend (struct sys_device *sysdev,u32 state) +static int pmacpic_suspend (struct sys_device *sysdev,pm_message_t state) {int viaint =pmacpic_find_viaint ();
arch/ppc/syslib/open_pic.c +1 -1
@@ -948,7 +948,7 @@ static void openpic_cached_disable_irq(u* we need something better to deal with that... Maybe switch to S1 for * cpufreq changes */ -int openpic_suspend (struct sys_device *sysdev,u32 state) +int openpic_suspend (struct sys_device *sysdev,pm_message_t state) {int i;unsigned long flags;
drivers/base/power/resume.c +4 -4
@@ -26,11 +26,11 @@ int resume_device(struct device * dev)down (&dev->sem);if (dev->power.pm_parent - && dev->power.pm_parent->power.power_state) { + && dev->power.pm_parent->power.power_state.event) {dev_err (dev,"PM: resume from %d, parent %s still %d\n" , - dev->power.power_state, + dev->power.power_state.event, dev->power.pm_parent->bus_id, - dev->power.pm_parent->power.power_state); + dev->power.pm_parent->power.power_state.event); }if (dev->bus && dev->bus->resume) {dev_dbg (dev,"resuming\n" );
@@ -54,7 +54,7 @@ void dpm_resume(void)list_add_tail (entry, &dpm_active);up (&dpm_list_sem); -if (!dev->power.prev_state) +if (!dev->power.prev_state.event)resume_device (dev);down (&dpm_list_sem);put_device (dev);
drivers/base/power/runtime.c +4 -4
@@ -13,10 +13,10 @@static void runtime_resume (struct device * dev) {dev_dbg (dev,"resuming\n" ); -if (!dev->power.power_state) +if (!dev->power.power_state.event)return ;if (!resume_device (dev)) - dev->power.power_state =0 ; + dev->power.power_state =PMSG_ON ; }
@@ -49,10 +49,10 @@ int dpm_runtime_suspend(struct device *int error =0 ;down (&dpm_sem); -if (dev->power.power_state == state) +if (dev->power.power_state.event == state.event) goto Done; -if (dev->power.power_state) +if (dev->power.power_state.event)runtime_resume (dev);if (!(error =suspend_device (dev, state)))
drivers/base/power/suspend.c +7 -7
@@ -40,22 +40,22 @@ int suspend_device(struct device * dev,int error =0 ;down (&dev->sem); -if (dev->power.power_state) { +if (dev->power.power_state.event) {dev_dbg (dev,"PM: suspend %d-->%d\n" , - dev->power.power_state, state); + dev->power.power_state.event, state.event); }if (dev->power.pm_parent - && dev->power.pm_parent->power.power_state) { + && dev->power.pm_parent->power.power_state.event) {dev_err (dev,"PM: suspend %d->%d, parent %s already %d\n" , - dev->power.power_state, state, + dev->power.power_state.event, state.event, dev->power.pm_parent->bus_id, - dev->power.pm_parent->power.power_state); + dev->power.pm_parent->power.power_state.event); } - dev->power.prev_state = dev->power.power_state; + dev->power.prev_state.event = dev->power.power_state.event; -if (dev->bus && dev->bus->suspend && !dev->power.power_state) { +if (dev->bus && dev->bus->suspend && !dev->power.power_state.event) {dev_dbg (dev,"suspending\n" ); error = dev->bus->suspend (dev, state); }
drivers/base/power/sysfs.c +5 -4
@@ -26,19 +26,20 @@static ssize_t state_show (struct device * dev,struct device_attribute *attr,char * buf) { -return sprintf (buf,"%u\n" , dev->power.power_state); +return sprintf (buf,"%u\n" , dev->power.power_state.event); }static ssize_t state_store (struct device * dev,struct device_attribute *attr,const char * buf,size_t n) { -u32 state; +pm_message_t state;char * rest;int error =0 ; - state =simple_strtoul (buf, &rest,10 ); + state.event =simple_strtoul (buf, &rest,10 ); + state.flags =PFL_RUNTIME ;if (*rest)return -EINVAL ; -if (state) +if (state.event) error =dpm_runtime_suspend (dev, state);else dpm_runtime_resume (dev);
drivers/ide/ide.c +1 -1
@@ -1229,7 +1229,7 @@ static int generic_ide_suspend(struct de rq.special = &args; rq.pm = &rqpm; rqpm.pm_step = ide_pm_state_start_suspend; - rqpm.pm_state = state; + rqpm.pm_state = state.event;return ide_do_drive_cmd (drive, &rq, ide_wait); }
drivers/ide/pci/sc1200.c +4 -4
@@ -350,9 +350,9 @@ static int sc1200_suspend (struct pci_de {ide_hwif_t *hwif =NULL ; -printk ("SC1200: suspend(%u)\n" , state); +printk ("SC1200: suspend(%u)\n" , state.event); -if (state ==0 ) { +if (state.event ==EVENT_ON ) {// we only save state when going from full power to less //
@@ -386,8 +386,8 @@ static int sc1200_suspend (struct pci_de/* You don't need to iterate over disks -- sysfs should have done that for you already */ pci_disable_device (dev); -pci_set_power_state (dev,state); - dev->current_state = state; +pci_set_power_state (dev,pci_choose_state (dev, state)); + dev->current_state = state.event;return 0 ; }
drivers/ide/ppc/pmac.c +8 -8
@@ -1504,12 +1504,12 @@ pmac_ide_macio_attach(struct macio_dev * }static int -pmac_ide_macio_suspend (struct macio_dev *mdev,u32 state) +pmac_ide_macio_suspend (struct macio_dev *mdev,pm_message_t state) {ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev);int rc =0 ; -if (state != mdev->ofdev.dev.power.power_state && state >=2 ) { +if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >=EVENT_SUSPEND ) { rc =pmac_ide_do_suspend (hwif);if (rc ==0 ) mdev->ofdev.dev.power.power_state = state;
@@ -1524,10 +1524,10 @@ pmac_ide_macio_resume(struct macio_dev *ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev);int rc =0 ; -if (mdev->ofdev.dev.power.power_state !=0 ) { +if (mdev->ofdev.dev.power.power_state.event !=EVENT_ON ) { rc =pmac_ide_do_resume (hwif);if (rc ==0 ) - mdev->ofdev.dev.power.power_state =0 ; + mdev->ofdev.dev.power.power_state =PMSG_ON ; }return rc;
@@ -1608,12 +1608,12 @@ pmac_ide_pci_attach(struct pci_dev *pdev }static int -pmac_ide_pci_suspend (struct pci_dev *pdev,u32 state) +pmac_ide_pci_suspend (struct pci_dev *pdev,pm_message_t state) {ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata (pdev);int rc =0 ; -if (state != pdev->dev.power.power_state && state >=2 ) { +if (state.event != pdev->dev.power.power_state.event && state.event >=2 ) { rc =pmac_ide_do_suspend (hwif);if (rc ==0 ) pdev->dev.power.power_state = state;
@@ -1628,10 +1628,10 @@ pmac_ide_pci_resume(struct pci_dev *pdevide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata (pdev);int rc =0 ; -if (pdev->dev.power.power_state !=0 ) { +if (pdev->dev.power.power_state.event !=EVENT_ON ) { rc =pmac_ide_do_resume (hwif);if (rc ==0 ) - pdev->dev.power.power_state =0 ; + pdev->dev.power.power_state =PMSG_ON ; }return rc;
drivers/macintosh/mediabay.c +3 -3
@@ -708,7 +708,7 @@ static int __pmac media_bay_suspend(stru {struct media_bay_info *bay =macio_get_drvdata (mdev); -if (state != mdev->ofdev.dev.power.power_state && state ==PM_SUSPEND_MEM ) { +if (state.event != mdev->ofdev.dev.power.power_state.event && state.event ==EVENT_SUSPEND ) {down (&bay->lock); bay->sleeping =1 ;set_mb_power (bay,0 );
@@ -723,8 +723,8 @@ static int __pmac media_bay_resume(struc {struct media_bay_info *bay =macio_get_drvdata (mdev); -if (mdev->ofdev.dev.power.power_state !=0 ) { - mdev->ofdev.dev.power.power_state =0 ; +if (mdev->ofdev.dev.power.power_state.event !=EVENT_ON ) { + mdev->ofdev.dev.power.power_state =PMSG_ON ;/* We re-enable the bay using it's previous content only if it did not change. Note those bozo timings,
drivers/macintosh/via-pmu.c +1 -1
@@ -3065,7 +3065,7 @@ static int pmu_sys_suspended = 0;static int pmu_sys_suspend (struct sys_device *sysdev,pm_message_t state) { -if (state !=PM_SUSPEND_DISK || pmu_sys_suspended) +if (state.event !=EVENT_SUSPEND || pmu_sys_suspended)return 0 ;/* Suspend PMU event interrupts */
drivers/media/dvb/cinergyT2/cinergyT2.c +1 -1
@@ -888,7 +888,7 @@ static int cinergyt2_suspend (struct usbif (down_interruptible (&cinergyt2->sem))return -ERESTARTSYS ; -if (state >0 ) {/* state 0 seems to mean DEVICE_PM_ON */ +if (state.event >0 ) {/* state 0 seems to mean DEVICE_PM_ON */ struct cinergyt2 *cinergyt2 =usb_get_intfdata (intf);#ifdef ENABLE_RC cancel_delayed_work (&cinergyt2->rc_query_work);
drivers/media/video/bttv-driver.c +1 -1
@@ -4043,7 +4043,7 @@ static int bttv_suspend(struct pci_dev *struct bttv_buffer_set idle;unsigned long flags; -dprintk ("bttv%d: suspend %d\n" , btv->c.nr, state); +dprintk ("bttv%d: suspend %d\n" , btv->c.nr, state.event);/* stop dma + irqs */ spin_lock_irqsave (&btv->s_lock,flags);
drivers/net/irda/vlsi_ir.c +10 -8
@@ -1748,10 +1748,11 @@ static int vlsi_irda_suspend(struct pci_ {struct net_device *ndev =pci_get_drvdata (pdev);vlsi_irda_dev_t *idev; +pci_power_t new_state; -if (state <1 || state >3 ) { +if (state.event <EVENT_FREEZE || state.event >EVENT_SUSPEND ) {IRDA_ERROR ("%s - %s: invalid pm state request: %u\n" , - __FUNCTION__,PCIDEV_NAME (pdev), state); + __FUNCTION__,PCIDEV_NAME (pdev), state.event);return 0 ; }if (!ndev) {
@@ -1760,14 +1761,15 @@ static int vlsi_irda_suspend(struct pci_return 0 ; } idev = ndev->priv; + new_state =pci_choose_state (pdev, state);down (&idev->sem);if (pdev->current_state !=0 ) {/* already suspended */ -if (state > pdev->current_state) {/* simply go deeper */ -pci_set_power_state (pdev,state); - pdev->current_state = state; +if (new_state > pdev->current_state) {/* simply go deeper */ +pci_set_power_state (pdev, new_state); + pdev->current_state = new_state; }else -IRDA_ERROR ("%s - %s: invalid suspend request %u -> %u\n" , __FUNCTION__,PCIDEV_NAME (pdev), pdev->current_state, state); +IRDA_ERROR ("%s - %s: invalid suspend request %u -> %u\n" , __FUNCTION__,PCIDEV_NAME (pdev), pdev->current_state, state.event);up (&idev->sem);return 0 ; }
@@ -1781,8 +1783,8 @@ static int vlsi_irda_suspend(struct pci_ idev->new_baud = idev->baud; } -pci_set_power_state (pdev,state); - pdev->current_state = state; +pci_set_power_state (pdev,new_state); + pdev->current_state = new_state; idev->resume_ok =1 ;up (&idev->sem);return 0 ;
drivers/net/wireless/airo.c +2 -1
@@ -5487,6 +5487,7 @@ static int airo_pci_suspend(struct pci_dstruct airo_info *ai = dev->priv;Cmd cmd;Resp rsp; +int new_state =pci_choose_state (pdev, state);if ((ai->APList ==NULL ) && (ai->APList =kmalloc (sizeof (APListRid),GFP_KERNEL )) ==NULL )
@@ -5502,7 +5503,7 @@ static int airo_pci_suspend(struct pci_dreturn -EAGAIN ;disable_MAC (ai,0 );netif_device_detach (dev); - ai->power = state; + ai->power = state.event; cmd.cmd=HOSTSLEEP ;issuecommand (ai, &cmd, &rsp);
drivers/net/wireless/orinoco_pci.c +1 -1
@@ -302,7 +302,7 @@ static int orinoco_pci_suspend(struct pcint err;printk (KERN_DEBUG "%s: Orinoco-PCI entering sleep mode (state=%d)\n" , - dev->name, state); + dev->name, state.event); err =orinoco_lock (priv, &flags);if (err) {
drivers/net/wireless/prism54/islpci_hotplug.c +1 -1
@@ -268,7 +268,7 @@ prism54_suspend(struct pci_dev *pdev, pmBUG_ON (!priv);printk (KERN_NOTICE "%s: got suspend request (state %d)\n" , - ndev->name, state); + ndev->name, state.event);pci_save_state (pdev);
drivers/pci/pci.c +7 -4
@@ -333,11 +333,14 @@ pci_power_t pci_choose_state(struct pci_if (ret >=0 ) state = ret; } -switch (state) { -case 0 :return PCI_D0 ; -case 3 :return PCI_D3hot; +switch (state.event) { +case EVENT_ON : +case EVENT_FREEZE : +return PCI_D0 ; +case EVENT_SUSPEND : +return PCI_D3hot;default : -printk ("They asked me for state %d\n" , state); +printk ("They asked me for state %d\n" , state.event);BUG (); }return PCI_D0 ;
drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -1475,7 +1475,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING *4 ));/* Startup the kernel thread for this host adapter. */ - phba->worker_thread =kthread_run (lpfc_do_work, phba, + phba->worker_thread =kthread_run (lpfc_do_work, phba,PF_NOFREEZE ,"lpfc_worker_%d" , phba->brd_no);if (IS_ERR (phba->worker_thread)) { error =PTR_ERR (phba->worker_thread);
drivers/serial/pmac_zilog.c +3 -3
@@ -1601,7 +1601,7 @@ static int pmz_suspend(struct macio_devreturn 0 ; } -if (pm_state == mdev->ofdev.dev.power.power_state || pm_state <2 ) +if (pm_state.event == mdev->ofdev.dev.power.power_state.event || pm_state.event <EVENT_SUSPEND )return 0 ;pmz_debug ("suspend, switching to state %d\n" , pm_state);
@@ -1661,7 +1661,7 @@ static int pmz_resume(struct macio_dev *if (uap ==NULL )return 0 ; -if (mdev->ofdev.dev.power.power_state ==0 ) +if (mdev->ofdev.dev.power.power_state.event ==EVENT_ON )return 0 ;pmz_debug ("resume, switching to state 0\n" );
@@ -1714,7 +1714,7 @@ static int pmz_resume(struct macio_dev *pmz_debug ("resume, switching complete\n" ); - mdev->ofdev.dev.power.power_state =0 ; + mdev->ofdev.dev.power.power_state =PMSG_ON ;return 0 ; }
drivers/usb/core/hub.c +9 -9
@@ -1570,7 +1570,7 @@ static int __usb_suspend_device (structstruct usb_driver *driver; intf = udev->actconfig->interface[i]; -if (state <= intf->dev.power.power_state) +if (state.event <= intf->dev.power.power_state.event)continue ;if (!intf->dev.driver)continue ;
@@ -1578,11 +1578,11 @@ static int __usb_suspend_device (structif (driver->suspend) { status = driver->suspend (intf, state); -if (intf->dev.power.power_state != state +if (intf->dev.power.power_state.event != state.event || status)dev_err (&intf->dev,"suspend %d fail, code %d\n" , - state, status); + state.event, status); }/* only drivers with suspend() can ever resume();
@@ -1595,7 +1595,7 @@ static int __usb_suspend_device (struct* since we know every driver's probe/disconnect works * even for drivers that can't suspend. */ -if (!driver->suspend || state >PM_SUSPEND_MEM ) { +if (!driver->suspend || state.event >EVENT_SUSPEND ) {#if 1 dev_warn (&intf->dev,"resume is unsafe!\n" );#else
@@ -1616,7 +1616,7 @@ static int __usb_suspend_device (struct* policies (when HNP doesn't apply) once we have mechanisms to * turn power back on! (Likely not before 2.7...) */ -if (state >PM_SUSPEND_MEM ) { +if (state.event >EVENT_SUSPEND ) {dev_warn (&udev->dev,"no poweroff yet, suspending instead\n" ); }
@@ -1733,7 +1733,7 @@ static int finish_port_resume(struct usbstruct usb_driver *driver; intf = udev->actconfig->interface[i]; -if (intf->dev.power.power_state ==PMSG_ON ) +if (intf->dev.power.power_state.event ==EVENT_SUSPEND )continue ;if (!intf->dev.driver) {/* FIXME maybe force to alt 0 */
@@ -1747,11 +1747,11 @@ static int finish_port_resume(struct usb/* can we do better than just logging errors? */ status = driver->resume (intf); -if (intf->dev.power.power_state !=PMSG_ON +if (intf->dev.power.power_state.event !=EVENT_ON || status)dev_dbg (&intf->dev,"resume fail, state %d code %d\n" , - intf->dev.power.power_state, status); + intf->dev.power.power_state.event, status); } status =0 ;
@@ -1934,7 +1934,7 @@ static int hub_resume(struct usb_interfaunsigned port1;int status; -if (intf->dev.power.power_state ==PM_SUSPEND_ON ) +if (intf->dev.power.power_state.event ==EVENT_ON )return 0 ;for (port1 =1 ; port1 <= hdev->maxchild; port1++) {
drivers/usb/core/usb.c +1 -1
@@ -1400,7 +1400,7 @@ static int usb_generic_suspend(struct de driver =to_usb_driver (dev->driver);/* there's only one USB suspend state */ -if (intf->dev.power.power_state) +if (intf->dev.power.power_state.event)return 0 ;if (driver->suspend)
drivers/usb/host/ehci-dbg.c +1 -1
@@ -643,7 +643,7 @@ show_registers (struct class_device *claspin_lock_irqsave (&ehci->lock, flags); -if (bus->controller->power.power_state) { +if (bus->controller->power.power_state.event) { size =scnprintf (next, size,"bus %s, device %s (driver " DRIVER_VERSION ")\n" "%s\n"
drivers/usb/host/ohci-dbg.c +1 -1
@@ -631,7 +631,7 @@ show_registers (struct class_device *cla hcd->product_desc, hcd_name); -if (bus->controller->power.power_state) { +if (bus->controller->power.power_state.event) { size -=scnprintf (next, size,"SUSPENDED (no register access)\n" ); goto done;
drivers/usb/host/sl811-hcd.c +3 -3
@@ -1781,9 +1781,9 @@ sl811h_suspend(struct device *dev, pm_meif (phase !=SUSPEND_POWER_DOWN )return retval; -if (state <=PM_SUSPEND_MEM ) +if (state.event ==EVENT_FREEZE ) retval =sl811h_hub_suspend (hcd); -else +else if (state.event ==EVENT_SUSPEND )port_power (sl811,0 );if (retval ==0 ) dev->power.power_state = state;
@@ -1802,7 +1802,7 @@ sl811h_resume(struct device *dev, u32 ph/* with no "check to see if VBUS is still powered" board hook, * let's assume it'd only be powered to enable remote wakeup. */ -if (dev->power.power_state >PM_SUSPEND_MEM +if (dev->power.power_state.event >EVENT_FREEZE || !hcd->can_wakeup) { sl811->port1 =0 ;port_power (sl811,1 );
drivers/video/aty/aty128fb.c +6 -6
@@ -2329,11 +2329,11 @@ static int aty128_pci_suspend(struct pci* that. On laptops, the AGP slot is just unclocked, so D2 is * expected, while on desktops, the card is powered off */ -if (state >=3 ) - state =2 ; +if (state.event >=3 ) + state.event =2 ;#endif /* CONFIG_PPC_PMAC */ -if (state !=2 || state == pdev->dev.power.power_state) +if (state.event !=2 || state.event == pdev->dev.power.power_state.event)return 0 ;printk (KERN_DEBUG "aty128fb: suspending...\n" );
@@ -2367,7 +2367,7 @@ static int aty128_pci_suspend(struct pci* used dummy fb ops, 2.5 need proper support for this at the * fbdev level */ -if (state ==2 ) +if (state.event ==2 )aty128_set_suspend (par,1 );release_console_sem ();
@@ -2382,11 +2382,11 @@ static int aty128_do_resume(struct pci_dstruct fb_info *info =pci_get_drvdata (pdev);struct aty128fb_par *par = info->par; -if (pdev->dev.power.power_state ==0 ) +if (!pdev->dev.power.power_state.event)return 0 ;/* Wakeup chip */ -if (pdev->dev.power.power_state ==2 ) +if (pdev->dev.power.power_state.event ==2 )aty128_set_suspend (par,0 ); par->asleep =0 ;
drivers/video/aty/atyfb_base.c +5 -5
@@ -2028,11 +2028,11 @@ static int atyfb_pci_suspend(struct pci_* that. On laptops, the AGP slot is just unclocked, so D2 is * expected, while on desktops, the card is powered off */ -if (state >=3 ) - state =2 ; +if (state.event >=3 ) + state.event =2 ;#endif /* CONFIG_PPC_PMAC */ -if (state !=2 || state == pdev->dev.power.power_state) +if (state.event !=2 || state.event == pdev->dev.power.power_state.event)return 0 ;acquire_console_sem ();
@@ -2071,12 +2071,12 @@ static int atyfb_pci_resume(struct pci_dstruct fb_info *info =pci_get_drvdata (pdev);struct atyfb_par *par = (struct atyfb_par *) info->par; -if (pdev->dev.power.power_state ==0 ) +if (pdev->dev.power.power_state.event ==EVENT_ON )return 0 ;acquire_console_sem (); -if (pdev->dev.power.power_state ==2 ) +if (pdev->dev.power.power_state.event ==2 )aty_power_mgmt (0 , par); par->asleep =0 ;
drivers/video/aty/radeon_pm.c +6 -6
@@ -2526,18 +2526,18 @@ int radeonfb_pci_suspend(struct pci_devstruct radeonfb_info *rinfo = info->par;int i; -if (state == pdev->dev.power.power_state) +if (state.event == pdev->dev.power.power_state.event)return 0 ;printk (KERN_DEBUG "radeonfb (%s): suspending to state: %d...\n" , -pci_name (pdev), state); +pci_name (pdev), state.event);/* For suspend-to-disk, we cheat here. We don't suspend anything and * let fbcon continue drawing until we are all set. That shouldn't * really cause any problem at this point, provided that the wakeup * code knows that any state in memory may not match the HW */ -if (state !=PM_SUSPEND_MEM ) +if (state.event !=EVENT_SUSPEND ) goto done;acquire_console_sem ();
@@ -2616,7 +2616,7 @@ int radeonfb_pci_resume(struct pci_dev *struct radeonfb_info *rinfo = info->par;int rc =0 ; -if (pdev->dev.power.power_state ==0 ) +if (!pdev->dev.power.power_state.event)return 0 ;if (rinfo->no_schedule) {
@@ -2626,7 +2626,7 @@ int radeonfb_pci_resume(struct pci_dev *acquire_console_sem ();printk (KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n" , -pci_name (pdev), pdev->dev.power.power_state); +pci_name (pdev), pdev->dev.power.power_state.event);if (pci_enable_device (pdev)) {
@@ -2637,7 +2637,7 @@ int radeonfb_pci_resume(struct pci_dev * }pci_set_master (pdev); -if (pdev->dev.power.power_state ==PM_SUSPEND_MEM ) { +if (pdev->dev.power.power_state.event ==EVENT_SUSPEND ) {/* Wakeup chip. Check from config space if we were powered off * (todo: additionally, check CLK_PIN_CNTL too) */
drivers/video/i810/i810_main.c +8 -14
@@ -1506,23 +1506,17 @@ static int i810fb_suspend(struct pci_devstruct i810fb_par *par = (struct i810fb_par *) info->par;int blank =0 , prev_state = par->cur_state; -if (state == prev_state) +if (state.event == prev_state)return 0 ; - par->cur_state = state; + par->cur_state = state.event; -switch (state) { -case 1 : - blank =VESA_VSYNC_SUSPEND ; -break ; -case 2 : - blank =VESA_HSYNC_SUSPEND ; -break ; -case 3 : - blank =VESA_POWERDOWN ; -break ; -default : -return -EINVAL ; +switch (state.event) { +case EVENT_SUSPEND : + blank =VESA_POWERDOWN ; +break ; +default : +return -EINVAL ; } info->fbops->fb_blank (blank, info);
drivers/video/savage/savagefb_driver.c +1 -1
@@ -2110,7 +2110,7 @@ static int savagefb_suspend (struct pci_struct savagefb_par *par = (struct savagefb_par *)info->par;DBG ("savagefb_suspend" ); -printk (KERN_DEBUG "state: %u\n" , state); +printk (KERN_DEBUG "state: %u\n" , state.event);acquire_console_sem ();fb_set_suspend (info,pci_choose_state (dev, state));
include/linux/pm.h +14 -4
@@ -186,7 +186,10 @@ extern int pm_suspend(suspend_state_t ststruct device ; -typedef u32 __bitwise pm_message_t ; +typedef struct pm_message { +int event; +int flags; +}pm_message_t ;/* * There are 4 important states driver can be in:
@@ -207,9 +210,16 @@ typedef u32 __bitwise pm_message_t;* or something similar soon. */ -#define PMSG_FREEZE ((__force pm_message_t) 3) -#define PMSG_SUSPEND ((__force pm_message_t) 3) -#define PMSG_ON ((__force pm_message_t) 0) +#define EVENT_ON 0 +#define EVENT_FREEZE 1 +#define EVENT_SUSPEND 2 + +#define PFL_RUNTIME 1 + +#define PMSG_FREEZE ({struct pm_message m; m.event = EVENT_FREEZE; m.flags = 0; m; }) +#define PMSG_SUSPEND ({struct pm_message m; m.event = EVENT_SUSPEND; m.flags = 0; m; }) +#define PMSG_ON ({struct pm_message m; m.event = EVENT_ON; m.flags = 0; m; }) +struct dev_pm_info {pm_message_t power_state;
sound/pci/atiixp.c +2 -2
@@ -1419,7 +1419,7 @@ static int snd_atiixp_suspend(snd_card_tsnd_atiixp_aclink_down (chip);snd_atiixp_chip_stop (chip); -pci_set_power_state (chip->pci,3 ); +pci_set_power_state (chip->pci, PCI_D3hot);pci_disable_device (chip->pci);return 0 ; }
@@ -1430,7 +1430,7 @@ static int snd_atiixp_resume(snd_card_tint i;pci_enable_device (chip->pci); -pci_set_power_state (chip->pci,0 ); +pci_set_power_state (chip->pci,PCI_D0 );pci_set_master (chip->pci);snd_atiixp_aclink_reset (chip);
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [3/48] Suspend2 2.1.9.8 for 2.6.12: 301-proc-acpi-sleep-activate-hook.patch
In reply to Matthew GarrettHi.
Quoted 6 lines · Matthew Garrett
Quoted 5 lines · Nigel Cunningham
Quoted 3 lines · Matthew Garrett
In general, the kernel does very little to prevent users from shooting themselves in the foot (or even chainsawing off their arms). We can do these checks in userspace rather than adding more kernel code.
Quoted 7 lines
Quoted 4 lines
Just because the kernel does very little, that doesn't mean it should. Particularly for something like suspend to disk, where it's not just a matter of an oops but of potential hard disk corruption, this is important.
The kernel isn't there to protect people. It's there to provide functionality.
Both are true. If it only provided functionality, it wouldn't remount filesystems read only on journal errors or the like.
Quoted 10 lines
Quoted 3 lines
If I could do it in userspace, I would. The trouble is, the userspace app may not be there to tell the user what is happening, and this might be part of the problem.
You're suggesting that users who are technically competent to compile their own kernel and write their own initrd scripts are unable to deal with checking whether or not a filesystem is mounted? You don't need an application to do that, it's a simple matter of shell scripting. And, in almost every case, if something is a simple matter of shell scripting it shouldn't be in the kernel.
I'm suggesting that people make mistakes, and they don't always read the documentation or think of everything. These checks are there precisely because people have messed up in the past, and to cover the case where userspace isn't ready or able - for whatever reason - to do those checks or tell the user they've done something wrong.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
In reply to Nigel CunninghamHi!
Quoted 7 lines
Quoted 1 line
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
This seems to be red herring. Sometimes sync took way too long (like hours) with older kernels and reiserfs, but I believe that has been fixed. If not, we need to fix it, anyway; no need to work around it in suspend2.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
Hi.
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Quoted 1 line
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
Quoted 7 lines
Quoted 2 lines
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
This seems to be red herring. Sometimes sync took way too long (like hours) with older kernels and reiserfs, but I believe that has been fixed. If not, we need to fix it, anyway; no need to work around it in suspend2.
Are you considering races such as the case where one process is submitting I/O (say dd) while another is trying to sync? Even if sync does return sooner (presumably because it only syncs writes submitted before the sync), there will still be dirty data after the sync completes. And if we start another sync thread, it will suffer the same problem. The only solution is to stop I/O being submitted, then sync. But having stopped I/O being submitted, we need to still have the threads the process the I/O (possibly userspace ones) unfrozen. Hence we need to differentiate 'syncthreads'.
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
Hi!
Quoted 13 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
Quoted 7 lines
Quoted 2 lines
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
This seems to be red herring. Sometimes sync took way too long (like hours) with older kernels and reiserfs, but I believe that has been fixed. If not, we need to fix it, anyway; no need to work around it in suspend2.
Quoted 9 lines
Are you considering races such as the case where one process is submitting I/O (say dd) while another is trying to sync? Even if sync does return sooner (presumably because it only syncs writes submitted before the sync), there will still be dirty data after the sync completes. And if we start another sync thread, it will suffer the same problem. The only solution is to stop I/O being submitted, then sync. But having stopped I/O being submitted, we need to still have the threads the process the I/O (possibly userspace ones) unfrozen. Hence we need to differentiate 'syncthreads'.
OTOH: this is only critical for "niceness", not for correctness. Calling sync() before suspend is simply nice thing to do, but it is not required in any way. If someone is doing long dd, tough, they are going to loose some data if wakeup fails. It is no worse than sudden poweroff.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
Hi.
Quoted 25 lines · Pavel Machek
Hi!
Quoted 13 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
Quoted 7 lines
Quoted 2 lines
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
This seems to be red herring. Sometimes sync took way too long (like hours) with older kernels and reiserfs, but I believe that has been fixed. If not, we need to fix it, anyway; no need to work around it in suspend2.
Quoted 9 lines
Are you considering races such as the case where one process is submitting I/O (say dd) while another is trying to sync? Even if sync does return sooner (presumably because it only syncs writes submitted before the sync), there will still be dirty data after the sync completes. And if we start another sync thread, it will suffer the same problem. The only solution is to stop I/O being submitted, then sync. But having stopped I/O being submitted, we need to still have the threads the process the I/O (possibly userspace ones) unfrozen. Hence we need to differentiate 'syncthreads'.
Quoted 5 lines
OTOH: this is only critical for "niceness", not for correctness. Calling
sync()before suspend is simply nice thing to do, but it is not required in any way. If someone is doing long dd, tough, they are going to loose some data if wakeup fails. It is no worse than sudden poweroff.
How can you say it's only required for niceness one minute, then admit it might result in data loss the next?
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
Hi!
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Again, why do you think you need this?
1. If something should be wrong with the freezer, it forms part of a safety net that stops your data on disk being trashed.
Quoted 7 lines
Quoted 2 lines
2. Separating out threads doing syncing from threads submitting I/O makes the refrigerator much more reliable, even under extreme load.
This seems to be red herring. Sometimes sync took way too long (like hours) with older kernels and reiserfs, but I believe that has been fixed. If not, we need to fix it, anyway; no need to work around it in suspend2.
Are you considering races such as the case where one process is submitting I/O (say dd) while another is trying to sync? Even if sync does return sooner (presumably because it only syncs writes submitted before the sync), there will still be dirty data after the sync completes. And if we start another sync thread, it will suffer the same problem. The only solution is to stop I/O being submitted, then sync. But having stopped I/O being submitted, we need to still have the threads the process the I/O (possibly userspace ones) unfrozen. Hence we need to differentiate 'syncthreads'.
Quoted 8 lines
Quoted 5 lines
OTOH: this is only critical for "niceness", not for correctness. Calling
sync()before suspend is simply nice thing to do, but it is not required in any way. If someone is doing long dd, tough, they are going to loose some data if wakeup fails. It is no worse than sudden poweroff.How can you say it's only required for niceness one minute, then admit it might result in data loss the next?
It will result in data loss *if resume fails*. But failing resume *always* causes data in running programs to be lost, so I do not see that as a problem.
Pavel
Signature · 1 line
teflon -- maybe it is a trademark, but it should not be.
Re: [PATCH] [5/48] Suspend2 2.1.9.8 for 2.6.12: 350-workthreads.patch
Hi.
Quoted 6 lines · Pavel Machek
Quoted 6 lines
Quoted 5 lines
OTOH: this is only critical for "niceness", not for correctness. Calling
sync()before suspend is simply nice thing to do, but it is not required in any way. If someone is doing long dd, tough, they are going to loose some data if wakeup fails. It is no worse than sudden poweroff.
Quoted 6 lines
Quoted 2 lines
How can you say it's only required for niceness one minute, then admit it might result in data loss the next?
It will result in data loss *if resume fails*. But failing resume *always* causes data in running programs to be lost, so I do not see that as a problem.
It does for you :>
Regards,
Nigel
Signature · 5 lines
Evolution. Enumerate the requirements. Consider the interdependencies. Calculate the probabilities. Be amazed that people believe it happened.
Re: [PATCH] [43/48] Suspend2 2.1.9.8 for 2.6.12: 619-userspace-nofreeze.patch
In reply to Nigel CunninghamQuoted 3 lines · Nigel Cunningham
People need to be able to recognise when this happens. They therefore need some feedback to know that the process is not hung, and to be able to say where it hung when it does.
this is called printk.