staging:lowmemkiller add Fudgeswap

fudgeswap acts as follows:

If set to non zero (defualt is 512k):
	Check for the amount of SWAP_FREE space avalible
	If > 0KB is avalible:
		if fudgeswap > swapfree:
			other_file += swapfree
		else:
			other_file += fugeswap

In short: we will add in fugeswap as long as its less then the free swap

Setting this to a very large positive number will indicate swap ought
to be fully used as free (and will slow the system down)

smaller numbers will allow you to put some pressure on SWAP without
slowing the system down as much.

small negitive numbers will allow the system to be faster at the same
minfree level.

default is 512 to give a very little bit of pressure to use some swap
but this can be modified at runtime via:
/sys/module/lowmemorykiller/parameters/fugeswap
originally by ezterry
 Please enter the commit message for your changes. Lines starting
This commit is contained in:
SecureCRT 2012-08-20 15:24:37 +08:00
parent 3d343ac32a
commit 7c50bd921f

View File

@ -41,6 +41,11 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
#ifdef CONFIG_SWAP
#include <linux/fs.h>
#include <linux/swap.h>
#endif
static uint32_t lowmem_debug_level = 2;
static int lowmem_adj[6] = {
0,
@ -64,6 +69,10 @@ static struct task_struct *lowmem_deathpending;
static unsigned long lowmem_deathpending_timeout;
static struct kobject *lowmem_kobj;
#ifdef CONFIG_SWAP
static int fudgeswap = 512;
#endif
#define lowmem_print(level, x...) \
do { \
if (lowmem_debug_level >= (level)) \
@ -122,7 +131,19 @@ static inline void get_free_ram(int *other_free, int *other_file)
*other_free = global_page_state(NR_FREE_PAGES);
*other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM);
#ifdef CONFIG_SWAP
if(fudgeswap != 0){
struct sysinfo si;
si_swapinfo(&si);
if(si.freeswap > 0){
if(fudgeswap > si.freeswap)
other_file += si.freeswap;
else
other_file += fudgeswap;
}
}
#endif
if (offlining) {
/* Discount all free space in the section being offlined */
for_each_zone(zone) {
@ -347,6 +368,9 @@ module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR);
module_param_named(notify_trigger, lowmem_minfree_notif_trigger, uint,
S_IRUGO | S_IWUSR);
#ifdef CONFIG_SWAP
module_param_named(fudgeswap, fudgeswap, int, S_IRUGO | S_IWUSR);
#endif
module_init(lowmem_init);
module_exit(lowmem_exit);