aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2005-09-10 03:26:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-10 13:06:22 -0400
commitd79fc0fc6645b0cf5cd980da76942ca6d6300fa4 (patch)
treee74aca1df1d37dbd7af66636a4e39a3f7e1af479
parent95cdf3b799a481969a48d69a1a52916ad5da6694 (diff)
[PATCH] sched: TASK_NONINTERACTIVE
This patch implements a task state bit (TASK_NONINTERACTIVE), which can be used by blocking points to mark the task's wait as "non-interactive". This does not mean the task will be considered a CPU-hog - the wait will simply not have an effect on the waiting task's priority - positive or negative alike. Right now only pipe_wait() will make use of it, because it's a common source of not-so-interactive waits (kernel compilation jobs, etc.). Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/pipe.c6
-rw-r--r--include/linux/sched.h1
-rw-r--r--kernel/sched.c11
3 files changed, 16 insertions, 2 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 2c7a23dde2d8..66aa0b938d6a 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -39,7 +39,11 @@ void pipe_wait(struct inode * inode)
39{ 39{
40 DEFINE_WAIT(wait); 40 DEFINE_WAIT(wait);
41 41
42 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE); 42 /*
43 * Pipes are system-local resources, so sleeping on them
44 * is considered a noninteractive wait:
45 */
46 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE);
43 up(PIPE_SEM(*inode)); 47 up(PIPE_SEM(*inode));
44 schedule(); 48 schedule();
45 finish_wait(PIPE_WAIT(*inode), &wait); 49 finish_wait(PIPE_WAIT(*inode), &wait);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8a1fcfe80fc7..ac70f845b5b1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -114,6 +114,7 @@ extern unsigned long nr_iowait(void);
114#define TASK_TRACED 8 114#define TASK_TRACED 8
115#define EXIT_ZOMBIE 16 115#define EXIT_ZOMBIE 16
116#define EXIT_DEAD 32 116#define EXIT_DEAD 32
117#define TASK_NONINTERACTIVE 64
117 118
118#define __set_task_state(tsk, state_value) \ 119#define __set_task_state(tsk, state_value) \
119 do { (tsk)->state = (state_value); } while (0) 120 do { (tsk)->state = (state_value); } while (0)
diff --git a/kernel/sched.c b/kernel/sched.c
index 24eed372d280..6da13bba3e23 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1261,6 +1261,16 @@ out_activate:
1261 } 1261 }
1262 1262
1263 /* 1263 /*
1264 * Tasks that have marked their sleep as noninteractive get
1265 * woken up without updating their sleep average. (i.e. their
1266 * sleep is handled in a priority-neutral manner, no priority
1267 * boost and no penalty.)
1268 */
1269 if (old_state & TASK_NONINTERACTIVE)
1270 __activate_task(p, rq);
1271 else
1272 activate_task(p, rq, cpu == this_cpu);
1273 /*
1264 * Sync wakeups (i.e. those types of wakeups where the waker 1274 * Sync wakeups (i.e. those types of wakeups where the waker
1265 * has indicated that it will leave the CPU in short order) 1275 * has indicated that it will leave the CPU in short order)
1266 * don't trigger a preemption, if the woken up task will run on 1276 * don't trigger a preemption, if the woken up task will run on
@@ -1268,7 +1278,6 @@ out_activate:
1268 * the waker guarantees that the freshly woken up task is going 1278 * the waker guarantees that the freshly woken up task is going
1269 * to be considered on this CPU.) 1279 * to be considered on this CPU.)
1270 */ 1280 */
1271 activate_task(p, rq, cpu == this_cpu);
1272 if (!sync || cpu != this_cpu) { 1281 if (!sync || cpu != this_cpu) {
1273 if (TASK_PREEMPTS_CURR(p, rq)) 1282 if (TASK_PREEMPTS_CURR(p, rq))
1274 resched_task(rq->curr); 1283 resched_task(rq->curr);