The swap token is only useful in conditions of swap thrash, and actually worsens the common case by causing more swapping. Make it only have an effect when swap is more than half full. -ck --- include/linux/swap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: linux-3.4-ck3/include/linux/swap.h =================================================================== --- linux-3.4-ck3.orig/include/linux/swap.h 2012-06-01 21:37:23.000000000 +1000 +++ linux-3.4-ck3/include/linux/swap.h 2012-07-03 14:00:42.019315907 +1000 @@ -361,9 +361,10 @@ extern void grab_swap_token(struct mm_st extern void __put_swap_token(struct mm_struct *); extern void disable_swap_token(struct mem_cgroup *memcg); +/* Only allow swap token to have effect if swap is full */ static inline int has_swap_token(struct mm_struct *mm) { - return (mm == swap_token_mm); + return (mm == swap_token_mm && vm_swap_full()); } static inline void put_swap_token(struct mm_struct *mm)