static void hkey_poll_stop(void) { if (hkey_poll_task) { if (frozen(hkey_poll_task) || freezing(hkey_poll_task)) thaw_process(hkey_poll_task); kthread_stop(hkey_poll_task); hkey_poll_task = NULL; mutex_lock(&hkey_poll_mutex); /* at this point, the thread did exit */ mutex_unlock(&hkey_poll_mutex); } }
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" ); }
static void hkey_poll_stop(void) { if (hkey_poll_task) { if (frozen(hkey_poll_task) || freezing(hkey_poll_task)) #if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) thaw_process(hkey_poll_task); #else wake_up_process(hkey_poll_task); #endif kthread_stop(hkey_poll_task); hkey_poll_task = NULL; mutex_lock(&hkey_poll_mutex); /* at this point, the thread did exit */ mutex_unlock(&hkey_poll_mutex); } }
static void thaw_tasks(int thaw_user_space) { struct task_struct *g, *p; read_lock(&tasklist_lock); do_each_thread(g, p) { if (!freezeable(p)) continue; if (is_user_space(p) == !thaw_user_space) continue; if (!thaw_process(p)) printk(KERN_WARNING " Strange, %s not stopped\n", p->comm ); } while_each_thread(g, p); read_unlock(&tasklist_lock); }
/* * Simple selection loop. We chose the process with the highest * number of 'points'. We expect the caller will lock the tasklist. * * (not docbooked, we don't want this one cluttering up the manual) */ static struct task_struct *select_bad_process(unsigned int *ppoints, unsigned long totalpages, struct mem_cgroup *mem, const nodemask_t *nodemask) { struct task_struct *g, *p; struct task_struct *chosen = NULL; *ppoints = 0; do_each_thread(g, p) { unsigned int points; if (p->exit_state) continue; if (oom_unkillable_task(p, mem, nodemask)) continue; /* * This task already has access to memory reserves and is * being killed. Don't allow any other task access to the * memory reserve. * * Note: this may have a chance of deadlock if it gets * blocked waiting for another task which itself is waiting * for memory. Is there a better alternative? */ if (test_tsk_thread_flag(p, TIF_MEMDIE)) { if (unlikely(frozen(p))) thaw_process(p); return ERR_PTR(-1UL); } if (!p->mm) continue; if (p->flags & PF_EXITING) { /* * If p is the current task and is in the process of * releasing memory, we allow the "kill" to set * TIF_MEMDIE, which will allow it to gain access to * memory reserves. Otherwise, it may stall forever. * * The loop isn't broken here, however, in case other * threads are found to have already been oom killed. */ if (p == current) { chosen = p; *ppoints = 1000; } else { /* * If this task is not being ptraced on exit, * then wait for it to finish before killing * some other task unnecessarily. */ if (!(p->group_leader->ptrace & PT_TRACE_EXIT)) return ERR_PTR(-1UL); } } points = oom_badness(p, mem, nodemask, totalpages); if (points > *ppoints) { chosen = p; *ppoints = points; } } while_each_thread(g, p);
void wake_timer_func(unsigned long arg) { printk(KERN_ERR "Waking up task waiting on wake lock\n"); thaw_process(arg); }