* [PATCH 1/4] Task notifier against mm: Allow notifier to remove itself
@ 2005-07-29 20:32 Christoph Lameter
2005-07-29 20:33 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Christoph Lameter
0 siblings, 1 reply; 14+ messages in thread
From: Christoph Lameter @ 2005-07-29 20:32 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel
Patch for Pavel against 2.6.13-rc3-mm3 (after removal of the TIF_FREEZE
patch). The same patch was posted yesterday against 2.6.13-rc3. I verified
again that this patch works fine on i386.
---
Allow notifier to remove itself.
This is done by retrieving the pointer to the next notifier from the list before the
notifier call.
Signed-off-by: Christoph Lameter <christoph@lameter.com>
Index: linux-2.6.13-rc3-mm3/kernel/sys.c
===================================================================
--- linux-2.6.13-rc3-mm3.orig/kernel/sys.c 2005-07-29 10:38:39.000000000 -0700
+++ linux-2.6.13-rc3-mm3/kernel/sys.c 2005-07-29 12:29:18.000000000 -0700
@@ -172,15 +172,18 @@
{
int ret=NOTIFY_DONE;
struct notifier_block *nb = *n;
+ struct notifier_block *next;
while(nb)
{
- ret=nb->notifier_call(nb,val,v);
+ /* Determining next here allows the notifier to unregister itself */
+ next = nb->next;
+ ret = nb->notifier_call(nb,val,v);
if(ret&NOTIFY_STOP_MASK)
{
return ret;
}
- nb=nb->next;
+ nb = next;
}
return ret;
}
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-29 20:32 [PATCH 1/4] Task notifier against mm: Allow notifier to remove itself Christoph Lameter @ 2005-07-29 20:33 ` Christoph Lameter 2005-07-29 20:34 ` [PATCH 3/4] Task notifier against mm: Make suspend code SMP safe using todo list Christoph Lameter 2005-07-30 11:22 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Pavel Machek 0 siblings, 2 replies; 14+ messages in thread From: Christoph Lameter @ 2005-07-29 20:33 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm Introduce a todo notifier in the task_struct so that a task can be told to do certain things. Abuse the suspend hooks try_to_freeze, freezing and refrigerator to establish checkpoints where the todo list is processed. This will break software suspend (next patch fixes and cleans up software suspend). Signed-off-by: Christoph Lameter <christoph@lameter.com> Index: linux-2.6.13-rc3-mm3/include/linux/sched.h =================================================================== --- linux-2.6.13-rc3-mm3.orig/include/linux/sched.h 2005-07-29 12:32:17.000000000 -0700 +++ linux-2.6.13-rc3-mm3/include/linux/sched.h 2005-07-29 12:37:44.000000000 -0700 @@ -35,6 +35,7 @@ #include <linux/topology.h> #include <linux/seccomp.h> #include <linux/taskdelays.h> +#include <linux/notifier.h> #include <linux/auxvec.h> /* For AT_VECTOR_SIZE */ @@ -783,7 +784,10 @@ int (*notifier)(void *priv); void *notifier_data; sigset_t *notifier_mask; - + + /* todo list to be executed in the context of this thread */ + struct notifier_block *todo; + void *security; struct audit_context *audit_context; seccomp_t seccomp; @@ -1353,79 +1357,36 @@ #endif -#ifdef CONFIG_PM -/* - * Check if a process has been frozen - */ -static inline int frozen(struct task_struct *p) -{ - return p->flags & PF_FROZEN; -} - -/* - * Check if there is a request to freeze a process - */ -static inline int freezing(struct task_struct *p) -{ - return p->flags & PF_FREEZE; -} - -/* - * Request that a process be frozen - * FIXME: SMP problem. We may not modify other process' flags! - */ -static inline void freeze(struct task_struct *p) -{ - p->flags |= PF_FREEZE; -} - /* - * Wake up a frozen process + * Check if there is a todo list request */ -static inline int thaw_process(struct task_struct *p) +static inline int todo_list_active(void) { - if (frozen(p)) { - p->flags &= ~PF_FROZEN; - wake_up_process(p); - return 1; - } - return 0; + return current->todo != NULL; } -/* - * freezing is complete, mark process as frozen - */ -static inline void frozen_process(struct task_struct *p) +static inline void run_todo_list(void) { - p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; + notifier_call_chain(¤t->todo, 0, current); } -extern void refrigerator(void); -extern int freeze_processes(void); -extern void thaw_processes(void); - -static inline int try_to_freeze(void) +static inline int try_todo_list(void) { - if (freezing(current)) { - refrigerator(); + if (todo_list_active()) { + run_todo_list(); return 1; } else return 0; } -#else -static inline int frozen(struct task_struct *p) { return 0; } -static inline int freezing(struct task_struct *p) { return 0; } -static inline void freeze(struct task_struct *p) { BUG(); } -static inline int thaw_process(struct task_struct *p) { return 1; } -static inline void frozen_process(struct task_struct *p) { BUG(); } - -static inline void refrigerator(void) {} -static inline int freeze_processes(void) { BUG(); return 0; } -static inline void thaw_processes(void) {} - -static inline int try_to_freeze(void) { return 0; } -#endif /* CONFIG_PM */ +/* + * Compatibility definitions to use the suspend checkpoints for the task todo list. + * These may be removed once all uses of try_to_free, refrigerator and freezing + * have been removed. + */ +#define try_to_freeze try_todo_list +#define refrigerator run_todo_list +#define freezing(p) todo_list_active() /* API for registering delay info */ #ifdef CONFIG_DELAY_ACCT Index: linux-2.6.13-rc3-mm3/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -213,7 +213,7 @@ fastcall void recalc_sigpending_tsk(struct task_struct *t) { if (t->signal->group_stop_count > 0 || - (freezing(t)) || + (t->todo) || PENDING(&t->pending, &t->blocked) || PENDING(&t->signal->shared_pending, &t->blocked)) set_tsk_thread_flag(t, TIF_SIGPENDING); @@ -2231,7 +2231,7 @@ current->state = TASK_INTERRUPTIBLE; timeout = schedule_timeout(timeout); - try_to_freeze(); + try_todo_list(); spin_lock_irq(¤t->sighand->siglock); sig = dequeue_signal(current, &these, &info); current->blocked = current->real_blocked; Index: linux-2.6.13-rc3-mm3/arch/frv/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/frv/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/frv/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -536,7 +536,7 @@ if (!user_mode(regs)) return 1; - if (try_to_freeze()) + if (try_todo_list()) goto no_signal; if (!oldset) Index: linux-2.6.13-rc3-mm3/arch/h8300/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/h8300/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/h8300/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -517,7 +517,7 @@ if ((regs->ccr & 0x10)) return 1; - if (try_to_freeze()) + if (try_todo_list()) goto no_signal; current->thread.esp0 = (unsigned long) regs; Index: linux-2.6.13-rc3-mm3/arch/i386/kernel/io_apic.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/i386/kernel/io_apic.c 2005-07-29 12:32:11.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/i386/kernel/io_apic.c 2005-07-29 12:32:32.000000000 -0700 @@ -575,7 +575,7 @@ for ( ; ; ) { set_current_state(TASK_INTERRUPTIBLE); time_remaining = schedule_timeout(time_remaining); - try_to_freeze(); + try_todo_list(); if (time_after(jiffies, prev_balance_time+balanced_irq_interval)) { preempt_disable(); Index: linux-2.6.13-rc3-mm3/arch/i386/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/i386/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/i386/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -608,7 +608,7 @@ if (!user_mode(regs)) return 1; - if (try_to_freeze()) + if (try_todo_list()) goto no_signal; if (!oldset) Index: linux-2.6.13-rc3-mm3/arch/m32r/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/m32r/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/m32r/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -371,7 +371,7 @@ if (!user_mode(regs)) return 1; - if (try_to_freeze()) + if (try_todo_list()) goto no_signal; if (!oldset) Index: linux-2.6.13-rc3-mm3/arch/ppc/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/ppc/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/ppc/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -705,7 +705,7 @@ unsigned long frame, newsp; int signr, ret; - if (try_to_freeze()) { + if (try_todo_list()) { signr = 0; if (!signal_pending(current)) goto no_signal; Index: linux-2.6.13-rc3-mm3/arch/x86_64/kernel/signal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/arch/x86_64/kernel/signal.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/arch/x86_64/kernel/signal.c 2005-07-29 12:32:32.000000000 -0700 @@ -425,7 +425,7 @@ if (!user_mode(regs)) return 1; - if (try_to_freeze()) + if (try_todo_list()) goto no_signal; if (!oldset) ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/4] Task notifier against mm: Make suspend code SMP safe using todo list 2005-07-29 20:33 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Christoph Lameter @ 2005-07-29 20:34 ` Christoph Lameter 2005-07-29 20:35 ` [PATCH 4/4] Task notifier against mm: s/try_to_freeze/try_todo_list in some driver Christoph Lameter 2005-07-30 11:22 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Pavel Machek 1 sibling, 1 reply; 14+ messages in thread From: Christoph Lameter @ 2005-07-29 20:34 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm Make the suspend code use the todo list in the task_struct This patch makes the suspend code SMP clean by removing PF_FREEZE and PF_FROZEN. Instead it relies on the new notification handler in the task_struct, a completion handler and an atomic counter for the number of processes frozen. All the logic is local to the suspend code and no longer requires changes to other kernel components. Signed-off-by: Christoph Lameter <christoph@lameter.com> Index: linux-2.6.13-rc3-mm3/include/linux/sched.h =================================================================== --- linux-2.6.13-rc3-mm3.orig/include/linux/sched.h 2005-07-29 12:37:44.000000000 -0700 +++ linux-2.6.13-rc3-mm3/include/linux/sched.h 2005-07-29 12:37:59.000000000 -0700 @@ -890,9 +890,7 @@ #define PF_MEMALLOC 0x00000800 /* Allocating memory */ #define PF_FLUSHER 0x00001000 /* responsible for disk writeback */ #define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ -#define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */ #define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */ -#define PF_FROZEN 0x00010000 /* frozen for system suspend */ #define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */ #define PF_KSWAPD 0x00040000 /* I am kswapd */ #define PF_SWAPOFF 0x00080000 /* I am in swapoff */ Index: linux-2.6.13-rc3-mm3/kernel/power/process.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/kernel/power/process.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/kernel/power/process.c 2005-07-29 12:37:59.000000000 -0700 @@ -18,6 +18,8 @@ */ #define TIMEOUT (6 * HZ) +DECLARE_COMPLETION(thaw); +static atomic_t nr_frozen; static inline int freezeable(struct task_struct * p) { @@ -31,26 +33,36 @@ return 1; } -/* Refrigerator is place where frozen processes are stored :-). */ -void refrigerator(void) +static int freeze_process(struct notifier_block *nl, unsigned long x, void *v) { /* Hmm, should we be allowed to suspend when there are realtime processes around? */ long save; save = current->state; - current->state = TASK_UNINTERRUPTIBLE; - pr_debug("%s entered refrigerator\n", current->comm); + pr_debug("%s frozen\n", current->comm); printk("="); - frozen_process(current); spin_lock_irq(¤t->sighand->siglock); recalc_sigpending(); /* We sent fake signal, clean it up */ + atomic_inc(&nr_frozen); spin_unlock_irq(¤t->sighand->siglock); - while (frozen(current)) - schedule(); - pr_debug("%s left refrigerator\n", current->comm); + wait_for_completion(&thaw); + atomic_dec(&nr_frozen); + notifier_chain_unregister(¤t->todo, nl); + kfree(nl); + pr_debug("%s thawed\n", current->comm); current->state = save; + return 0; +} + +void thaw_processes(void) +{ + printk( "Restarting tasks..." ); + complete_all(&thaw); + while (atomic_read(&nr_frozen) > 0) + schedule(); + printk( " done\n" ); } /* 0 = success, else # of processes that we failed to stop */ @@ -61,19 +73,32 @@ struct task_struct *g, *p; unsigned long flags; + atomic_set(&nr_frozen, 0); + INIT_COMPLETION(thaw); + printk( "Stopping tasks: " ); start_time = jiffies; do { todo = 0; read_lock(&tasklist_lock); do_each_thread(g, p) { + struct notifier_block *n; + if (!freezeable(p)) continue; - if (frozen(p)) - continue; - freeze(p); + /* If there is nothing on the todo list then get the process to freeze itself */ + if (!todo_list_active()) { + n = kmalloc(sizeof(struct notifier_block), GFP_ATOMIC); + if (n) { + n->notifier_call = freeze_process; + n->priority = 0; + notifier_chain_register(&g->todo, n); + } + } + /* Make the process work on its todo list */ spin_lock_irqsave(&p->sighand->siglock, flags); + recalc_sigpending(); signal_wake_up(p, 0); spin_unlock_irqrestore(&p->sighand->siglock, flags); todo++; @@ -83,31 +108,13 @@ if (time_after(jiffies, start_time + TIMEOUT)) { printk( "\n" ); printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo ); + thaw_processes(); return todo; } - } while(todo); + } while(todo < atomic_read(&nr_frozen)); printk( "|\n" ); BUG_ON(in_atomic()); return 0; } -void thaw_processes(void) -{ - struct task_struct *g, *p; - - printk( "Restarting tasks..." ); - read_lock(&tasklist_lock); - do_each_thread(g, p) { - if (!freezeable(p)) - continue; - if (!thaw_process(p)) - printk(KERN_INFO " Strange, %s not stopped\n", p->comm ); - } while_each_thread(g, p); - - read_unlock(&tasklist_lock); - schedule(); - printk( " done\n" ); -} - -EXPORT_SYMBOL(refrigerator); Index: linux-2.6.13-rc3-mm3/Documentation/power/kernel_threads.txt =================================================================== --- linux-2.6.13-rc3-mm3.orig/Documentation/power/kernel_threads.txt 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/Documentation/power/kernel_threads.txt 2005-07-29 12:37:59.000000000 -0700 @@ -4,15 +4,15 @@ Freezer Upon entering a suspended state the system will freeze all -tasks. This is done by delivering pseudosignals. This affects -kernel threads, too. To successfully freeze a kernel thread -the thread has to check for the pseudosignal and enter the -refrigerator. Code to do this looks like this: +tasks. This is done by making all processes execute a notifier. +This affects kernel threads, too. To successfully freeze a kernel thread +the thread has to check for the notifications and call the notifier +chain for the process. Code to do this looks like this: do { hub_events(); wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); - try_to_freeze(); + try_todo_list(); } while (!signal_pending(current)); from drivers/usb/core/hub.c::hub_thread() Index: linux-2.6.13-rc3-mm3/Documentation/power/swsusp.txt =================================================================== --- linux-2.6.13-rc3-mm3.orig/Documentation/power/swsusp.txt 2005-07-29 12:32:11.000000000 -0700 +++ linux-2.6.13-rc3-mm3/Documentation/power/swsusp.txt 2005-07-29 12:37:59.000000000 -0700 @@ -155,7 +155,8 @@ website, and not to the Linux Kernel Mailing List. We are working toward merging suspend2 into the mainline kernel. -Q: A kernel thread must voluntarily freeze itself (call 'refrigerator'). +Q: A kernel thread must work on the todo list (call 'run_todo_list') +to enter the refrigerator. I found some kernel threads that don't do it, and they don't freeze so the system can't sleep. Is this a known behavior? @@ -164,7 +165,7 @@ should be held at that point and it must be safe to sleep there), and add: - try_to_freeze(); + try_todo_list(); If the thread is needed for writing the image to storage, you should instead set the PF_NOFREEZE process flag when creating the thread (and ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/4] Task notifier against mm: s/try_to_freeze/try_todo_list in some driver 2005-07-29 20:34 ` [PATCH 3/4] Task notifier against mm: Make suspend code SMP safe using todo list Christoph Lameter @ 2005-07-29 20:35 ` Christoph Lameter 0 siblings, 0 replies; 14+ messages in thread From: Christoph Lameter @ 2005-07-29 20:35 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm Patch to replace try_to_freeze with try_todo_list Replaces: try_to_freeze -> try_todo_list freezing -> todo_listactive refrigerator -> run_todo_list This patch is incomplete. Drivers may continue using try_to_freeze, freezing and refrigerators since the above mapping is also provided by macros in include/linux/sched.h. At some point--when all drivers have been changed--the macros in include/linux/sched.h may be removed. Signed-off-by: Christoph Lameter <christoph@lameter.com> Index: linux-2.6.13-rc3-mm3/drivers/block/pktcdvd.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/block/pktcdvd.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/block/pktcdvd.c 2005-07-29 12:38:02.000000000 -0700 @@ -1250,8 +1250,7 @@ residue = schedule_timeout(min_sleep_time); VPRINTK("kcdrwd: wake up\n"); - /* make swsusp happy with our thread */ - try_to_freeze(); + try_todo_list(); list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) { if (!pkt->sleep_time) Index: linux-2.6.13-rc3-mm3/drivers/ieee1394/ieee1394_core.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/ieee1394/ieee1394_core.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/ieee1394/ieee1394_core.c 2005-07-29 12:38:03.000000000 -0700 @@ -1044,7 +1044,7 @@ while (1) { if (down_interruptible(&khpsbpkt_sig)) { - if (try_to_freeze()) + if (try_todo_list()) continue; printk("khpsbpkt: received unexpected signal?!\n" ); break; Index: linux-2.6.13-rc3-mm3/drivers/ieee1394/nodemgr.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/ieee1394/nodemgr.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/ieee1394/nodemgr.c 2005-07-29 12:38:03.000000000 -0700 @@ -1510,7 +1510,7 @@ if (down_interruptible(&hi->reset_sem) || down_interruptible(&nodemgr_serialize)) { - if (try_to_freeze()) + if (try_todo_list()) continue; printk("NodeMgr: received unexpected signal?!\n" ); break; Index: linux-2.6.13-rc3-mm3/drivers/input/gameport/gameport.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/input/gameport/gameport.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/input/gameport/gameport.c 2005-07-29 12:38:03.000000000 -0700 @@ -435,7 +435,7 @@ gameport_handle_events(); wait_event_interruptible(gameport_wait, kthread_should_stop() || !list_empty(&gameport_event_list)); - try_to_freeze(); + try_todo_list(); } while (!kthread_should_stop()); printk(KERN_DEBUG "gameport: kgameportd exiting\n"); Index: linux-2.6.13-rc3-mm3/drivers/input/serio/serio.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/input/serio/serio.c 2005-07-29 12:32:06.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/input/serio/serio.c 2005-07-29 12:38:03.000000000 -0700 @@ -371,7 +371,7 @@ serio_handle_events(); wait_event_interruptible(serio_wait, kthread_should_stop() || !list_empty(&serio_event_list)); - try_to_freeze(); + try_todo_list(); } while (!kthread_should_stop()); printk(KERN_DEBUG "serio: kseriod exiting\n"); Index: linux-2.6.13-rc3-mm3/drivers/media/dvb/dvb-core/dvb_frontend.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/media/dvb/dvb-core/dvb_frontend.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/media/dvb/dvb-core/dvb_frontend.c 2005-07-29 12:38:03.000000000 -0700 @@ -394,7 +394,7 @@ break; } - try_to_freeze(); + try_todo_list(); if (down_interruptible(&fepriv->sem)) break; Index: linux-2.6.13-rc3-mm3/drivers/net/irda/stir4200.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/net/irda/stir4200.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/net/irda/stir4200.c 2005-07-29 12:38:03.000000000 -0700 @@ -763,7 +763,7 @@ { #ifdef CONFIG_PM /* if suspending, then power off and wait */ - if (unlikely(freezing(current))) { + if (unlikely(todo_list_active())) { if (stir->receiving) receive_stop(stir); else @@ -771,7 +771,7 @@ write_reg(stir, REG_CTRL1, CTRL1_TXPWD|CTRL1_RXPWD); - refrigerator(); + run_todo_list(); if (change_speed(stir, stir->speed)) break; Index: linux-2.6.13-rc3-mm3/drivers/pcmcia/cs.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/pcmcia/cs.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/pcmcia/cs.c 2005-07-29 12:38:03.000000000 -0700 @@ -683,7 +683,7 @@ } schedule(); - try_to_freeze(); + try_todo_list(); if (!skt->thread) break; Index: linux-2.6.13-rc3-mm3/drivers/usb/core/hub.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/usb/core/hub.c 2005-07-29 12:32:11.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/usb/core/hub.c 2005-07-29 12:38:03.000000000 -0700 @@ -2812,7 +2812,7 @@ wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list) || kthread_should_stop()); - try_to_freeze(); + try_todo_list(); } while (!kthread_should_stop() || !list_empty(&hub_event_list)); pr_debug("%s: khubd exiting\n", usbcore_name); Index: linux-2.6.13-rc3-mm3/drivers/usb/storage/usb.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/usb/storage/usb.c 2005-07-29 12:32:07.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/usb/storage/usb.c 2005-07-29 12:38:03.000000000 -0700 @@ -891,7 +891,7 @@ wait_event_interruptible_timeout(us->delay_wait, test_bit(US_FLIDX_DISCONNECTING, &us->flags), delay_use * HZ); - if (try_to_freeze()) + if (try_todo_list()) goto retry; } Index: linux-2.6.13-rc3-mm3/fs/afs/kafsasyncd.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/afs/kafsasyncd.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/afs/kafsasyncd.c 2005-07-29 12:38:03.000000000 -0700 @@ -116,7 +116,7 @@ remove_wait_queue(&kafsasyncd_sleepq, &myself); set_current_state(TASK_RUNNING); - try_to_freeze(); + try_todo_list(); /* discard pending signals */ afs_discard_my_signals(); Index: linux-2.6.13-rc3-mm3/fs/afs/kafstimod.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/afs/kafstimod.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/afs/kafstimod.c 2005-07-29 12:38:03.000000000 -0700 @@ -91,7 +91,7 @@ complete_and_exit(&kafstimod_dead, 0); } - try_to_freeze(); + try_todo_list(); /* discard pending signals */ afs_discard_my_signals(); Index: linux-2.6.13-rc3-mm3/fs/jbd/journal.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/jbd/journal.c 2005-07-29 12:32:17.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/jbd/journal.c 2005-07-29 12:38:03.000000000 -0700 @@ -153,7 +153,7 @@ } wake_up(&journal->j_wait_done_commit); - if (freezing(current)) { + if (todo_list_active()) { /* * The simpler the better. Flushing journal isn't a * good idea, because that depends on threads that may @@ -161,7 +161,7 @@ */ jbd_debug(1, "Now suspending kjournald\n"); spin_unlock(&journal->j_state_lock); - refrigerator(); + run_todo_list(); spin_lock(&journal->j_state_lock); } else { /* Index: linux-2.6.13-rc3-mm3/fs/jfs/jfs_logmgr.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/jfs/jfs_logmgr.c 2005-07-29 12:32:01.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/jfs/jfs_logmgr.c 2005-07-29 12:38:03.000000000 -0700 @@ -2360,9 +2360,9 @@ lbmStartIO(bp); spin_lock_irq(&log_redrive_lock); } - if (freezing(current)) { + if (todo_list_active()) { spin_unlock_irq(&log_redrive_lock); - refrigerator(); + run_todo_list(); } else { add_wait_queue(&jfs_IO_thread_wait, &wq); set_current_state(TASK_INTERRUPTIBLE); Index: linux-2.6.13-rc3-mm3/fs/lockd/clntproc.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/lockd/clntproc.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/lockd/clntproc.c 2005-07-29 12:38:03.000000000 -0700 @@ -313,7 +313,7 @@ prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE); if (!signalled ()) { schedule_timeout(NLMCLNT_GRACE_WAIT); - try_to_freeze(); + try_todo_list(); if (!signalled ()) status = 0; } Index: linux-2.6.13-rc3-mm3/fs/xfs/linux-2.6/xfs_buf.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/xfs/linux-2.6/xfs_buf.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/xfs/linux-2.6/xfs_buf.c 2005-07-29 12:38:03.000000000 -0700 @@ -1771,9 +1771,9 @@ INIT_LIST_HEAD(&tmp); do { - if (unlikely(freezing(current))) { + if (unlikely(todo_list_active())) { xfsbufd_force_sleep = 1; - refrigerator(); + run_todo_list(); } else { xfsbufd_force_sleep = 0; } Index: linux-2.6.13-rc3-mm3/fs/xfs/linux-2.6/xfs_super.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/fs/xfs/linux-2.6/xfs_super.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/fs/xfs/linux-2.6/xfs_super.c 2005-07-29 12:38:03.000000000 -0700 @@ -482,8 +482,8 @@ for (;;) { set_current_state(TASK_INTERRUPTIBLE); timeleft = schedule_timeout(timeleft); - /* swsusp */ - try_to_freeze(); + + try_todo_list(); if (vfsp->vfs_flag & VFS_UMOUNT) break; Index: linux-2.6.13-rc3-mm3/kernel/sched.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/kernel/sched.c 2005-07-29 12:32:23.000000000 -0700 +++ linux-2.6.13-rc3-mm3/kernel/sched.c 2005-07-29 12:38:03.000000000 -0700 @@ -4524,7 +4524,7 @@ struct list_head *head; migration_req_t *req; - try_to_freeze(); + try_todo_list(); spin_lock_irq(&rq->lock); Index: linux-2.6.13-rc3-mm3/mm/pdflush.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/mm/pdflush.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/mm/pdflush.c 2005-07-29 12:38:03.000000000 -0700 @@ -105,7 +105,7 @@ spin_unlock_irq(&pdflush_lock); schedule(); - if (try_to_freeze()) { + if (try_todo_list()) { spin_lock_irq(&pdflush_lock); continue; } Index: linux-2.6.13-rc3-mm3/mm/vmscan.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/mm/vmscan.c 2005-07-29 12:32:18.000000000 -0700 +++ linux-2.6.13-rc3-mm3/mm/vmscan.c 2005-07-29 12:38:03.000000000 -0700 @@ -1222,7 +1222,7 @@ for ( ; ; ) { unsigned long new_order; - try_to_freeze(); + try_todo_list(); prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE); new_order = pgdat->kswapd_max_order; Index: linux-2.6.13-rc3-mm3/net/rxrpc/krxiod.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/net/rxrpc/krxiod.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/net/rxrpc/krxiod.c 2005-07-29 12:38:03.000000000 -0700 @@ -138,7 +138,7 @@ _debug("### End Work"); - try_to_freeze(); + try_todo_list(); /* discard pending signals */ rxrpc_discard_my_signals(); Index: linux-2.6.13-rc3-mm3/net/rxrpc/krxtimod.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/net/rxrpc/krxtimod.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/net/rxrpc/krxtimod.c 2005-07-29 12:38:03.000000000 -0700 @@ -90,7 +90,7 @@ complete_and_exit(&krxtimod_dead, 0); } - try_to_freeze(); + try_todo_list(); /* discard pending signals */ rxrpc_discard_my_signals(); Index: linux-2.6.13-rc3-mm3/net/sunrpc/svcsock.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/net/sunrpc/svcsock.c 2005-07-12 21:46:46.000000000 -0700 +++ linux-2.6.13-rc3-mm3/net/sunrpc/svcsock.c 2005-07-29 12:38:03.000000000 -0700 @@ -1186,7 +1186,7 @@ arg->len = (pages-1)*PAGE_SIZE; arg->tail[0].iov_len = 0; - try_to_freeze(); + try_todo_list(); if (signalled()) return -EINTR; @@ -1227,7 +1227,7 @@ schedule_timeout(timeout); - try_to_freeze(); + try_todo_list(); spin_lock_bh(&serv->sv_lock); remove_wait_queue(&rqstp->rq_wait, &wait); Index: linux-2.6.13-rc3-mm3/drivers/net/8139too.c =================================================================== --- linux-2.6.13-rc3-mm3.orig/drivers/net/8139too.c 2005-07-29 12:32:00.000000000 -0700 +++ linux-2.6.13-rc3-mm3/drivers/net/8139too.c 2005-07-29 12:38:03.000000000 -0700 @@ -1605,8 +1605,7 @@ timeout = next_tick; do { timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); - /* make swsusp happy with our thread */ - try_to_freeze(); + try_todo_list(); } while (!signal_pending (current) && (timeout > 0)); if (signal_pending (current)) { ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-29 20:33 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Christoph Lameter 2005-07-29 20:34 ` [PATCH 3/4] Task notifier against mm: Make suspend code SMP safe using todo list Christoph Lameter @ 2005-07-30 11:22 ` Pavel Machek 2005-07-30 11:26 ` Pavel Machek 2005-07-30 15:43 ` Christoph Lameter 1 sibling, 2 replies; 14+ messages in thread From: Pavel Machek @ 2005-07-30 11:22 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, akpm Hi! > Introduce a todo notifier in the task_struct so that a task can be told to do > certain things. Abuse the suspend hooks try_to_freeze, freezing and refrigerator > to establish checkpoints where the todo list is processed. This will break software > suspend (next patch fixes and cleans up software suspend). VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 13 EXTRAVERSION =-rc3-mm3 This patch fails: pavel@amd:/usr/src/linux-mm$ cat /tmp/delme | patch -Esp1 1 out of 3 hunks FAILED -- saving rejects to file include/linux/sched.h.rej pavel@amd:/usr/src/linux-mm$ No wonder when -mm already contains: /* * Check if there is a request to freeze a process */ static inline int freezing(struct task_struct *p) { return test_ti_thread_flag(p->thread_info, TIF_FREEZE); } Pavel -- teflon -- maybe it is a trademark, but it should not be. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 11:22 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Pavel Machek @ 2005-07-30 11:26 ` Pavel Machek 2005-07-30 15:43 ` Christoph Lameter 1 sibling, 0 replies; 14+ messages in thread From: Pavel Machek @ 2005-07-30 11:26 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, akpm Hi! > > Introduce a todo notifier in the task_struct so that a task can be told to do > > certain things. Abuse the suspend hooks try_to_freeze, freezing and refrigerator > > to establish checkpoints where the todo list is processed. This will break software > > suspend (next patch fixes and cleans up software suspend). > > VERSION = 2 > PATCHLEVEL = 6 > SUBLEVEL = 13 > EXTRAVERSION =-rc3-mm3 > > This patch fails: > > pavel@amd:/usr/src/linux-mm$ cat /tmp/delme | patch -Esp1 > 1 out of 3 hunks FAILED -- saving rejects to file include/linux/sched.h.rej > pavel@amd:/usr/src/linux-mm$ (Notice that I do not nice 4 patches with changelogs. One patch against known-good version should be enough for testing.) Pavel -- teflon -- maybe it is a trademark, but it should not be. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 11:22 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Pavel Machek 2005-07-30 11:26 ` Pavel Machek @ 2005-07-30 15:43 ` Christoph Lameter 2005-07-30 16:10 ` Pavel Machek 1 sibling, 1 reply; 14+ messages in thread From: Christoph Lameter @ 2005-07-30 15:43 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm On Sat, 30 Jul 2005, Pavel Machek wrote: > No wonder when -mm already contains: > > /* > * Check if there is a request to freeze a process > */ > static inline int freezing(struct task_struct *p) > { > return test_ti_thread_flag(p->thread_info, TIF_FREEZE); > } Yes I told you to remove the TIF_FREEZE patch. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 15:43 ` Christoph Lameter @ 2005-07-30 16:10 ` Pavel Machek 2005-07-30 16:18 ` Christoph Lameter 0 siblings, 1 reply; 14+ messages in thread From: Pavel Machek @ 2005-07-30 16:10 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, akpm Hi! > > /* > > * Check if there is a request to freeze a process > > */ > > static inline int freezing(struct task_struct *p) > > { > > return test_ti_thread_flag(p->thread_info, TIF_FREEZE); > > } > > Yes I told you to remove the TIF_FREEZE patch. Okay, I took 2.6.13-rc3-mm3, removed TIF_FREEZE patch, and applied your series. (This time it applied cleanly). After first suspend machine locked hard at time it should switch back to original console. On the next try, it appeared to lock up, but then I somehow managed to switch consoles... unfortunately it was locked up hard at that point, too. Pavel -- if you have sharp zaurus hardware you don't need... you know my address ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 16:10 ` Pavel Machek @ 2005-07-30 16:18 ` Christoph Lameter 2005-07-30 16:22 ` Pavel Machek 0 siblings, 1 reply; 14+ messages in thread From: Christoph Lameter @ 2005-07-30 16:18 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm On Sat, 30 Jul 2005, Pavel Machek wrote: > > Yes I told you to remove the TIF_FREEZE patch. > > Okay, I took 2.6.13-rc3-mm3, removed TIF_FREEZE patch, and applied > your series. (This time it applied cleanly). After first suspend > machine locked hard at time it should switch back to original > console. On the next try, it appeared to lock up, but then I somehow > managed to switch consoles... unfortunately it was locked up hard at > that point, too. Hmmm. I have only run suspend / resume in text mode so far. Switched back to original console means that you ran X right? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 16:18 ` Christoph Lameter @ 2005-07-30 16:22 ` Pavel Machek 2005-08-01 18:43 ` Christoph Lameter 0 siblings, 1 reply; 14+ messages in thread From: Pavel Machek @ 2005-07-30 16:22 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, akpm Hi! > > > Yes I told you to remove the TIF_FREEZE patch. > > > > Okay, I took 2.6.13-rc3-mm3, removed TIF_FREEZE patch, and applied > > your series. (This time it applied cleanly). After first suspend > > machine locked hard at time it should switch back to original > > console. On the next try, it appeared to lock up, but then I somehow > > managed to switch consoles... unfortunately it was locked up hard at > > that point, too. > > Hmmm. I have only run suspend / resume in text mode so far. Switched back > to original console means that you ran X right? No, I was running text consoles. vesafb in this case. Pavel -- if you have sharp zaurus hardware you don't need... you know my address ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-07-30 16:22 ` Pavel Machek @ 2005-08-01 18:43 ` Christoph Lameter 2005-08-08 9:43 ` Pavel Machek 0 siblings, 1 reply; 14+ messages in thread From: Christoph Lameter @ 2005-08-01 18:43 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel, akpm Got a new suspend patchsset at ftp://ftp.kernel.org:/pub/linux/kernel/people/christoph/suspend/2.6.13-rc4-mm1 Check the series file for the sequence of patches. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-08-01 18:43 ` Christoph Lameter @ 2005-08-08 9:43 ` Pavel Machek 2005-08-08 15:49 ` Christoph Lameter 0 siblings, 1 reply; 14+ messages in thread From: Pavel Machek @ 2005-08-08 9:43 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, akpm Hi! > Got a new suspend patchsset at > > ftp://ftp.kernel.org:/pub/linux/kernel/people/christoph/suspend/2.6.13-rc4-mm1 > > Check the series file for the sequence of patches. Something still goes very wrong after first resume. It seems to work ok for few seconds, then console switch takes 10 seconds to react and cursor stops blinking, and then it is dead. Pavel -- if you have sharp zaurus hardware you don't need... you know my address ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-08-08 9:43 ` Pavel Machek @ 2005-08-08 15:49 ` Christoph Lameter 2005-08-08 22:09 ` Pavel Machek 0 siblings, 1 reply; 14+ messages in thread From: Christoph Lameter @ 2005-08-08 15:49 UTC (permalink / raw) To: Pavel Machek; +Cc: linux-kernel On Mon, 8 Aug 2005, Pavel Machek wrote: > Hi! > > > Got a new suspend patchsset at > > > > ftp://ftp.kernel.org:/pub/linux/kernel/people/christoph/suspend/2.6.13-rc4-mm1 > > > > Check the series file for the sequence of patches. > > Something still goes very wrong after first resume. It seems to work > ok for few seconds, then console switch takes 10 seconds to react and > cursor stops blinking, and then it is dead. Could you get me some more details as to what is happening? This means it: 1. suspends correctly. 2. resumes. 3. Then after 10 seconds there is a crash? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct 2005-08-08 15:49 ` Christoph Lameter @ 2005-08-08 22:09 ` Pavel Machek 0 siblings, 0 replies; 14+ messages in thread From: Pavel Machek @ 2005-08-08 22:09 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel Hi! > > > Got a new suspend patchsset at > > > > > > ftp://ftp.kernel.org:/pub/linux/kernel/people/christoph/suspend/2.6.13-rc4-mm1 > > > > > > Check the series file for the sequence of patches. > > > > Something still goes very wrong after first resume. It seems to work > > ok for few seconds, then console switch takes 10 seconds to react and > > cursor stops blinking, and then it is dead. > > Could you get me some more details as to what is happening? > > This means it: > > 1. suspends correctly. > > 2. resumes. > > 3. Then after 10 seconds there is a crash? More or less. It was more like: then after 10 seconds machine freezes. You press Alt-F1 to switch consoles, nothing happens for 3 seconds, then it switches. [Seems like some problems with console kernel thread to me... Using vesafb and acpi.] Pavel -- if you have sharp zaurus hardware you don't need... you know my address ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2005-08-08 22:09 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-07-29 20:32 [PATCH 1/4] Task notifier against mm: Allow notifier to remove itself Christoph Lameter 2005-07-29 20:33 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Christoph Lameter 2005-07-29 20:34 ` [PATCH 3/4] Task notifier against mm: Make suspend code SMP safe using todo list Christoph Lameter 2005-07-29 20:35 ` [PATCH 4/4] Task notifier against mm: s/try_to_freeze/try_todo_list in some driver Christoph Lameter 2005-07-30 11:22 ` [PATCH 2/4] Task notifier against mm: Implement todo list in task_struct Pavel Machek 2005-07-30 11:26 ` Pavel Machek 2005-07-30 15:43 ` Christoph Lameter 2005-07-30 16:10 ` Pavel Machek 2005-07-30 16:18 ` Christoph Lameter 2005-07-30 16:22 ` Pavel Machek 2005-08-01 18:43 ` Christoph Lameter 2005-08-08 9:43 ` Pavel Machek 2005-08-08 15:49 ` Christoph Lameter 2005-08-08 22:09 ` Pavel Machek
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox