[PATCH] sched: TASK_NONINTERACTIVE
Changes
3 files changed · +16 −2
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| fs/pipe.c | modified | +5 | −1 | View file |
| include/linux/sched.h | modified | +1 | −0 | View file |
| kernel/sched.c | modified | +10 | −1 | View file |
fs/pipe.c
View filediff --git a/fs/pipe.c b/fs/pipe.c
index 2c7a23d..66aa0b9 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -39,7 +39,11 @@ void pipe_wait(struct inode * inode)
{
DEFINE_WAIT(wait);
- prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE);
+ /*
+ * Pipes are system-local resources, so sleeping on them
+ * is considered a noninteractive wait:
+ */
+ prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE);
up(PIPE_SEM(*inode));
schedule();
finish_wait(PIPE_WAIT(*inode), &wait);
include/linux/sched.h
View filediff --git a/include/linux/sched.h b/include/linux/sched.h
index 8a1fcfe..ac70f84 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -114,6 +114,7 @@ extern unsigned long nr_iowait(void);
#define TASK_TRACED 8
#define EXIT_ZOMBIE 16
#define EXIT_DEAD 32
+#define TASK_NONINTERACTIVE 64
#define __set_task_state(tsk, state_value) \
do { (tsk)->state = (state_value); } while (0)
kernel/sched.c
View filediff --git a/kernel/sched.c b/kernel/sched.c
index 24eed37..6da13bb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1261,6 +1261,16 @@ out_activate:
}
/*
+ * Tasks that have marked their sleep as noninteractive get
+ * woken up without updating their sleep average. (i.e. their
+ * sleep is handled in a priority-neutral manner, no priority
+ * boost and no penalty.)
+ */
+ if (old_state & TASK_NONINTERACTIVE)
+ __activate_task(p, rq);
+ else
+ activate_task(p, rq, cpu == this_cpu);
+ /*
* Sync wakeups (i.e. those types of wakeups where the waker
* has indicated that it will leave the CPU in short order)
* don't trigger a preemption, if the woken up task will run on
@@ -1268,7 +1278,6 @@ out_activate:
* the waker guarantees that the freshly woken up task is going
* to be considered on this CPU.)
*/
- activate_task(p, rq, cpu == this_cpu);
if (!sync || cpu != this_cpu) {
if (TASK_PREEMPTS_CURR(p, rq))
resched_task(rq->curr);