Commit 1caf076b authored by Hideo Aoki's avatar Hideo Aoki Committed by Linus Torvalds

[PATCH] vm thrashing control tuning

This patch adds "swap_token_timeout" parameter in /proc/sys/vm.  The
parameter means expired time of token.  Unit of the value is HZ, and the
default value is the same as current SWAP_TOKEN_TIMEOUT (i.e.  HZ * 300).
Signed-off-by: default avatarHideo Aoki <aoki@sdl.hitachi.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2850479a
...@@ -1295,6 +1295,14 @@ block_dump ...@@ -1295,6 +1295,14 @@ block_dump
block_dump enables block I/O debugging when set to a nonzero value. More block_dump enables block I/O debugging when set to a nonzero value. More
information on block I/O debugging is in Documentation/laptop-mode.txt. information on block I/O debugging is in Documentation/laptop-mode.txt.
swap_token_timeout
------------------
This file contains valid hold time of swap out protection token. The Linux
VM has token based thrashing control mechanism and uses the token to prevent
unnecessary page faults in thrashing situation. The unit of the value is
second. The value would be useful to tune thrashing behavior.
2.5 /proc/sys/dev - Device specific parameters 2.5 /proc/sys/dev - Device specific parameters
---------------------------------------------- ----------------------------------------------
......
...@@ -31,7 +31,7 @@ Currently, these files are in /proc/sys/vm: ...@@ -31,7 +31,7 @@ Currently, these files are in /proc/sys/vm:
dirty_ratio, dirty_background_ratio, dirty_expire_centisecs, dirty_ratio, dirty_background_ratio, dirty_expire_centisecs,
dirty_writeback_centisecs, vfs_cache_pressure, laptop_mode, dirty_writeback_centisecs, vfs_cache_pressure, laptop_mode,
block_dump: block_dump, swap_token_timeout:
See Documentation/filesystems/proc.txt See Documentation/filesystems/proc.txt
......
...@@ -230,6 +230,7 @@ extern spinlock_t swaplock; ...@@ -230,6 +230,7 @@ extern spinlock_t swaplock;
/* linux/mm/thrash.c */ /* linux/mm/thrash.c */
extern struct mm_struct * swap_token_mm; extern struct mm_struct * swap_token_mm;
extern unsigned long swap_token_default_timeout;
extern void grab_swap_token(void); extern void grab_swap_token(void);
extern void __put_swap_token(struct mm_struct *); extern void __put_swap_token(struct mm_struct *);
......
...@@ -167,6 +167,7 @@ enum ...@@ -167,6 +167,7 @@ enum
VM_HUGETLB_GROUP=25, /* permitted hugetlb group */ VM_HUGETLB_GROUP=25, /* permitted hugetlb group */
VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */ VM_VFS_CACHE_PRESSURE=26, /* dcache/icache reclaim pressure */
VM_LEGACY_VA_LAYOUT=27, /* legacy/compatibility virtual address space layout */ VM_LEGACY_VA_LAYOUT=27, /* legacy/compatibility virtual address space layout */
VM_SWAP_TOKEN_TIMEOUT=28, /* default time for token time out */
}; };
......
...@@ -783,6 +783,7 @@ static ctl_table vm_table[] = { ...@@ -783,6 +783,7 @@ static ctl_table vm_table[] = {
.strategy = &sysctl_intvec, .strategy = &sysctl_intvec,
.extra1 = &zero, .extra1 = &zero,
}, },
#ifdef CONFIG_SWAP
{ {
.ctl_name = VM_VFS_CACHE_PRESSURE, .ctl_name = VM_VFS_CACHE_PRESSURE,
.procname = "vfs_cache_pressure", .procname = "vfs_cache_pressure",
...@@ -805,6 +806,15 @@ static ctl_table vm_table[] = { ...@@ -805,6 +806,15 @@ static ctl_table vm_table[] = {
.extra1 = &zero, .extra1 = &zero,
}, },
#endif #endif
{
.ctl_name = VM_SWAP_TOKEN_TIMEOUT,
.procname = "swap_token_timeout",
.data = &swap_token_default_timeout,
.maxlen = sizeof(swap_token_default_timeout),
.mode = 0644,
.proc_handler = &proc_dointvec_jiffies,
.strategy = &sysctl_jiffies,
},
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
...@@ -915,6 +925,7 @@ static ctl_table fs_table[] = { ...@@ -915,6 +925,7 @@ static ctl_table fs_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec, .proc_handler = &proc_dointvec,
}, },
#endif
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
......
...@@ -20,6 +20,7 @@ struct mm_struct * swap_token_mm = &init_mm; ...@@ -20,6 +20,7 @@ struct mm_struct * swap_token_mm = &init_mm;
#define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2) #define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
#define SWAP_TOKEN_TIMEOUT (HZ * 300) #define SWAP_TOKEN_TIMEOUT (HZ * 300)
unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
/* /*
* Take the token away if the process had no page faults * Take the token away if the process had no page faults
...@@ -75,10 +76,10 @@ void grab_swap_token(void) ...@@ -75,10 +76,10 @@ void grab_swap_token(void)
if ((reason = should_release_swap_token(mm))) { if ((reason = should_release_swap_token(mm))) {
unsigned long eligible = jiffies; unsigned long eligible = jiffies;
if (reason == SWAP_TOKEN_TIMED_OUT) { if (reason == SWAP_TOKEN_TIMED_OUT) {
eligible += SWAP_TOKEN_TIMEOUT; eligible += swap_token_default_timeout;
} }
mm->swap_token_time = eligible; mm->swap_token_time = eligible;
swap_token_timeout = jiffies + SWAP_TOKEN_TIMEOUT; swap_token_timeout = jiffies + swap_token_default_timeout;
swap_token_mm = current->mm; swap_token_mm = current->mm;
} }
spin_unlock(&swap_token_lock); spin_unlock(&swap_token_lock);
......
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