6443346923fc423b335fb52e6f9f255af5e3fc44
[kernel-bfs] / kernel-bfs-2.6.28 / debian / patches / mm-drop_swap_cache_aggressively.patch
1 While it may be nice to have a copy of pages on swap once written there, the
2 more garbage we leave in the swapspace the slower any further writes and
3 reads to and from it are. Just free swapcache whenever we can.
4
5 -ck
6
7 ---
8  include/linux/swap.h |    2 +-
9  mm/memory.c          |    2 +-
10  mm/swapfile.c        |    9 ++++-----
11  mm/vmscan.c          |    2 +-
12  4 files changed, 7 insertions(+), 8 deletions(-)
13
14 Index: linux-2.6.34-ck1/mm/memory.c
15 ===================================================================
16 --- linux-2.6.34-ck1.orig/mm/memory.c   2010-05-18 12:24:33.852194874 +1000
17 +++ linux-2.6.34-ck1/mm/memory.c        2010-05-18 12:26:16.646319673 +1000
18 @@ -2713,7 +2713,7 @@ static int do_swap_page(struct mm_struct
19         page_add_anon_rmap(page, vma, address);
20  
21         swap_free(entry);
22 -       if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
23 +       if ((vma->vm_flags & VM_LOCKED) || PageMlocked(page))
24                 remove_exclusive_swap_page(page);
25         unlock_page(page);
26  
27 Index: linux-2.6.34-ck1/mm/swapfile.c
28 ===================================================================
29 @@ -712,8 +712,7 @@ int free_swap_and_cache(swp_entry_t entr
30                 one_user = (page_count(page) == 2);
31                 /* Only cache user (+us), or swap space full? Free it! */
32                 /* Also recheck PageSwapCache after page is locked (above) */
33 -               if (PageSwapCache(page) && !PageWriteback(page) &&
34 -                                       (one_user || vm_swap_full())) {
35 +               if (PageSwapCache(page) && !PageWriteback(page)) {
36                         delete_from_swap_cache(page);
37                         SetPageDirty(page);
38                 }
39 Index: linux-2.6.34-ck1/mm/vmscan.c
40 ===================================================================
41 --- linux-2.6.34-ck1.orig/mm/vmscan.c   2010-05-18 12:26:16.371569589 +1000
42 +++ linux-2.6.34-ck1/mm/vmscan.c        2010-05-18 12:26:16.647319427 +1000
43 @@ -821,7 +821,7 @@ cull_mlocked:
44  
45  activate_locked:
46                 /* Not a candidate for swapping, so reclaim swap space. */
47 -               if (PageSwapCache(page) && vm_swap_full())
48 +               if (PageSwapCache(page))
49                         remove_exclusive_swap_page_ref(page);
50                 VM_BUG_ON(PageActive(page));
51                 SetPageActive(page);
52 Index: linux-2.6.34-ck1/include/linux/swap.h
53 ===================================================================
54 --- linux-2.6.34-ck1.orig/include/linux/swap.h  2010-05-18 12:26:16.508569731 +1000
55 +++ linux-2.6.34-ck1/include/linux/swap.h       2010-05-18 12:26:16.647319427 +1000
56 @@ -189,7 +189,7 @@ struct swap_list_t {
57         int next;       /* swapfile to be used next */
58  };
59  
60 -/* Swap 50% full? Release swapcache more aggressively.. */
61 +/* Swap 50% full? */
62  #define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
63  
64  /* linux/mm/page_alloc.c */
65