* [PATCH] [RFC] Throttle swappiness for interactive tasks
@ 2007-04-18 12:10 अभिजित भोपटकर (Abhijit Bhopatkar)
2007-04-18 17:04 ` Chris Snook
2007-04-18 20:52 ` Rik van Riel
0 siblings, 2 replies; 6+ messages in thread
From: अभिजित भोपटकर (Abhijit Bhopatkar) @ 2007-04-18 12:10 UTC (permalink / raw)
To: Linux Kernel list, Linus Torvalds, akpm, jgarzik
The mm structures of interactive tasks are marked and
the pages belonging to them are never shifted to inactive
list in lru algorithm. Thus keeping interactive tasks in
memory as long as possible.
The interactivity is already determined by schedular so
we reuse that knowledge to mark the mm structures.
Signed-off-by: Abhijit Bhopatkar <bainonline@gmail.com>
---
include/linux/init_task.h | 1 +
include/linux/sched.h | 4 ++++
kernel/sched.c | 4 ++++
mm/rmap.c | 5 +++++
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index a2d95ff..12ba3c1 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -54,6 +54,7 @@
.page_table_lock = __SPIN_LOCK_UNLOCKED(name.page_table_lock), \
.mmlist = LIST_HEAD_INIT(name.mmlist), \
.cpu_vm_mask = CPU_MASK_ALL, \
+ .interactive = 0, \
}
#define INIT_SIGNALS(sig) { \
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 49fe299..1f233e7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -373,6 +373,10 @@ struct mm_struct {
/* aio bits */
rwlock_t ioctx_list_lock;
struct kioctx *ioctx_list;
+
+ /* interactivity flag */
+ unsigned char interactive;
+
};
struct sighand_struct {
diff --git a/kernel/sched.c b/kernel/sched.c
index b9a6837..72caf94 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -746,6 +746,10 @@ static inline int __normal_prio(struct task_struct *p)
prio = MAX_RT_PRIO;
if (prio > MAX_PRIO-1)
prio = MAX_PRIO-1;
+
+ /* Update interactivity flag in mm if interactive. */
+ if(p->mm && TASK_INTERACTIVE(p))
+ p->mm->interactive = 1;
return prio;
}
diff --git a/mm/rmap.c b/mm/rmap.c
index b82146e..0735168 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -317,6 +317,11 @@ static int page_referenced_one(struct page *page,
rwsem_is_locked(&mm->mmap_sem))
referenced++;
+ /* Pretend the page is referenced if the task is
+ interactive. */
+ if (mm != current->mm && mm->interactive)
+ referenced++;
+
(*mapcount)--;
pte_unmap_unlock(pte, ptl);
out:
--
1.4.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] [RFC] Throttle swappiness for interactive tasks
2007-04-18 12:10 [PATCH] [RFC] Throttle swappiness for interactive tasks अभिजित भोपटकर (Abhijit Bhopatkar)
@ 2007-04-18 17:04 ` Chris Snook
2007-04-18 20:52 ` Rik van Riel
1 sibling, 0 replies; 6+ messages in thread
From: Chris Snook @ 2007-04-18 17:04 UTC (permalink / raw)
To: "अभिजित भोपटकर (Abhijit Bhopatkar)"
Cc: Linux Kernel list, Linus Torvalds, akpm, jgarzik
अभिजित भोपटकर (Abhijit Bhopatkar) wrote:
> The mm structures of interactive tasks are marked and
> the pages belonging to them are never shifted to inactive
> list in lru algorithm. Thus keeping interactive tasks in
> memory as long as possible.
> The interactivity is already determined by schedular so
> we reuse that knowledge to mark the mm structures.
>
> Signed-off-by: Abhijit Bhopatkar <bainonline@gmail.com>
> ---
Lying to the VM doesn't seem like the best way to handle this. A lot of tasks,
including interactive ones have some/many pages that they touch once during
startup, and don't touch again for a very long time, if ever. We want these
pages swapped out long before the box swaps out the working set of our
non-interactive processes.
I like the general idea of swap priority influenced by scheduler priority, but
if we're going to do that, we should do it in a general way that's independent
of scheduler implementation, so it'll be useful to soft real-time users and
still relevant if (when?) we replace the current scheduler with something else
lacking a special "interactive" flag.
-- Chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [RFC] Throttle swappiness for interactive tasks
2007-04-18 12:10 [PATCH] [RFC] Throttle swappiness for interactive tasks अभिजित भोपटकर (Abhijit Bhopatkar)
2007-04-18 17:04 ` Chris Snook
@ 2007-04-18 20:52 ` Rik van Riel
[not found] ` <2ff216280704182014h6ff2eed3g4301ee8d1bfbed14@mail.gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Rik van Riel @ 2007-04-18 20:52 UTC (permalink / raw)
To: "अभिजित भोपटकर (Abhijit Bhopatkar)"
Cc: Linux Kernel list, Linus Torvalds, akpm, jgarzik
अभिजित भोपटकर (Abhijit Bhopatkar) wrote:
> The mm structures of interactive tasks are marked and
> the pages belonging to them are never shifted to inactive
> list in lru algorithm. Thus keeping interactive tasks in
> memory as long as possible.
> The interactivity is already determined by schedular so
> we reuse that knowledge to mark the mm structures.
Aside from the obvious question of whether the idea is good,
there are some practical problems with your patch:
1) the mm->interactive flag is never cleared, even if the
task stops being interactive
2) what if the interactive tasks use up more memory than
the system has? Will you OOM kill instead of swapping
out part of an interactive task?
3) the scheduler can change its idea about which task is
interactive and which task isn't very rapidly, while
disk IO is very slow - the scheduler's classification
may not be useful on swap timescales
4) a currently completely idle task can still be marked
interactive in the scheduler, even if it has been
idle for days. Such a task is an obvious good
candidate for swapout, isn't it?
--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is. Each group
calls the other unpatriotic.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-04-19 7:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-18 12:10 [PATCH] [RFC] Throttle swappiness for interactive tasks अभिजित भोपटकर (Abhijit Bhopatkar)
2007-04-18 17:04 ` Chris Snook
2007-04-18 20:52 ` Rik van Riel
[not found] ` <2ff216280704182014h6ff2eed3g4301ee8d1bfbed14@mail.gmail.com>
2007-04-19 4:29 ` Rik van Riel
2007-04-19 5:22 ` Abhijit Bhopatkar
2007-04-19 7:07 ` Rik van Riel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox