Commit 107e7ba5 authored by Måns Rullgård's avatar Måns Rullgård Committed by Linus Torvalds

[PATCH] SysRq-n changes RT tasks to normal

Teach sysrq-N to switch all rt-policy tasks to SCHED_OTHER.  For recovering
from (and diagnosing) userspace bugs.
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4b448974
......@@ -216,6 +216,16 @@ static struct sysrq_key_op sysrq_kill_op = {
/* END SIGNAL SYSRQ HANDLERS BLOCK */
static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs,
struct tty_struct *tty)
{
normalize_rt_tasks();
}
static struct sysrq_key_op sysrq_unrt_op = {
.handler = sysrq_handle_unrt,
.help_msg = "Nice",
.action_msg = "Nice All RT Tasks"
};
/* Key Operations table and lock */
static spinlock_t sysrq_key_table_lock = SPIN_LOCK_UNLOCKED;
......@@ -250,7 +260,7 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
#endif
/* l */ NULL,
/* m */ &sysrq_showmem_op,
/* n */ NULL,
/* n */ &sysrq_unrt_op,
/* o */ NULL, /* This will often be registered
as 'Off' at init time */
/* p */ &sysrq_showregs_op,
......
......@@ -1105,6 +1105,12 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm)
extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
#ifdef CONFIG_MAGIC_SYSRQ
extern void normalize_rt_tasks(void);
#endif
#endif /* __KERNEL__ */
#endif
......@@ -4607,3 +4607,35 @@ void __might_sleep(char *file, int line)
}
EXPORT_SYMBOL(__might_sleep);
#endif
#ifdef CONFIG_MAGIC_SYSRQ
void normalize_rt_tasks(void)
{
struct task_struct *p;
prio_array_t *array;
unsigned long flags;
runqueue_t *rq;
read_lock_irq(&tasklist_lock);
for_each_process (p) {
if (!rt_task(p))
continue;
rq = task_rq_lock(p, &flags);
array = p->array;
if (array)
deactivate_task(p, task_rq(p));
__setscheduler(p, SCHED_NORMAL, 0);
if (array) {
__activate_task(p, task_rq(p));
resched_task(rq->curr);
}
task_rq_unlock(rq, &flags);
}
read_unlock_irq(&tasklist_lock);
}
EXPORT_SYMBOL(normalize_rt_tasks);
#endif /* CONFIG_MAGIC_SYSRQ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment