diff options
author | Hugh Dickins <hugh@veritas.com> | 2008-02-05 01:28:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:15 -0500 |
commit | bb63be0a091c512fb566ee235eb8320d5831b6e2 (patch) | |
tree | 3fc58d190902417429228c3066b6093a848c5974 /mm/swap_state.c | |
parent | 818db35992c249dc32c1d86daf7d533fb0952f5d (diff) |
tmpfs: move swap_state stats update
Both unionfs and memcgroups pose challenges to tmpfs and shmem. To help fix,
it's best to move the swap swizzling functions from swap_state.c to shmem.c.
As a preliminary to that, move swap stats updating down into
__add_to_swap_cache, which will remain internal to swap_state.c.
Well, actually, just move down the incrementation of add_total: remove
noent_race and exist_race completely, they are relics of my 2.4.11 testing.
Alt-SysRq-m users will be thrilled if 2.6.25 is at last free of "race M+N"s.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r-- | mm/swap_state.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c index e7875642e2cf..18fce3613e5a 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -52,16 +52,13 @@ static struct { | |||
52 | unsigned long del_total; | 52 | unsigned long del_total; |
53 | unsigned long find_success; | 53 | unsigned long find_success; |
54 | unsigned long find_total; | 54 | unsigned long find_total; |
55 | unsigned long noent_race; | ||
56 | unsigned long exist_race; | ||
57 | } swap_cache_info; | 55 | } swap_cache_info; |
58 | 56 | ||
59 | void show_swap_cache_info(void) | 57 | void show_swap_cache_info(void) |
60 | { | 58 | { |
61 | printk("Swap cache: add %lu, delete %lu, find %lu/%lu, race %lu+%lu\n", | 59 | printk("Swap cache: add %lu, delete %lu, find %lu/%lu\n", |
62 | swap_cache_info.add_total, swap_cache_info.del_total, | 60 | swap_cache_info.add_total, swap_cache_info.del_total, |
63 | swap_cache_info.find_success, swap_cache_info.find_total, | 61 | swap_cache_info.find_success, swap_cache_info.find_total); |
64 | swap_cache_info.noent_race, swap_cache_info.exist_race); | ||
65 | printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10)); | 62 | printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10)); |
66 | printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10)); | 63 | printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10)); |
67 | } | 64 | } |
@@ -89,6 +86,7 @@ static int __add_to_swap_cache(struct page *page, swp_entry_t entry, | |||
89 | set_page_private(page, entry.val); | 86 | set_page_private(page, entry.val); |
90 | total_swapcache_pages++; | 87 | total_swapcache_pages++; |
91 | __inc_zone_page_state(page, NR_FILE_PAGES); | 88 | __inc_zone_page_state(page, NR_FILE_PAGES); |
89 | INC_CACHE_INFO(add_total); | ||
92 | } | 90 | } |
93 | write_unlock_irq(&swapper_space.tree_lock); | 91 | write_unlock_irq(&swapper_space.tree_lock); |
94 | radix_tree_preload_end(); | 92 | radix_tree_preload_end(); |
@@ -102,10 +100,9 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry, | |||
102 | int error; | 100 | int error; |
103 | 101 | ||
104 | BUG_ON(PageLocked(page)); | 102 | BUG_ON(PageLocked(page)); |
105 | if (!swap_duplicate(entry)) { | 103 | if (!swap_duplicate(entry)) |
106 | INC_CACHE_INFO(noent_race); | ||
107 | return -ENOENT; | 104 | return -ENOENT; |
108 | } | 105 | |
109 | SetPageLocked(page); | 106 | SetPageLocked(page); |
110 | error = __add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL); | 107 | error = __add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL); |
111 | /* | 108 | /* |
@@ -114,11 +111,8 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry, | |||
114 | if (error) { | 111 | if (error) { |
115 | ClearPageLocked(page); | 112 | ClearPageLocked(page); |
116 | swap_free(entry); | 113 | swap_free(entry); |
117 | if (error == -EEXIST) | ||
118 | INC_CACHE_INFO(exist_race); | ||
119 | return error; | 114 | return error; |
120 | } | 115 | } |
121 | INC_CACHE_INFO(add_total); | ||
122 | return 0; | 116 | return 0; |
123 | } | 117 | } |
124 | 118 | ||
@@ -178,11 +172,9 @@ int add_to_swap(struct page * page, gfp_t gfp_mask) | |||
178 | case 0: /* Success */ | 172 | case 0: /* Success */ |
179 | SetPageUptodate(page); | 173 | SetPageUptodate(page); |
180 | SetPageDirty(page); | 174 | SetPageDirty(page); |
181 | INC_CACHE_INFO(add_total); | ||
182 | return 1; | 175 | return 1; |
183 | case -EEXIST: | 176 | case -EEXIST: |
184 | /* Raced with "speculative" read_swap_cache_async */ | 177 | /* Raced with "speculative" read_swap_cache_async */ |
185 | INC_CACHE_INFO(exist_race); | ||
186 | swap_free(entry); | 178 | swap_free(entry); |
187 | continue; | 179 | continue; |
188 | default: | 180 | default: |
@@ -225,9 +217,7 @@ int move_to_swap_cache(struct page *page, swp_entry_t entry) | |||
225 | if (!swap_duplicate(entry)) | 217 | if (!swap_duplicate(entry)) |
226 | BUG(); | 218 | BUG(); |
227 | SetPageDirty(page); | 219 | SetPageDirty(page); |
228 | INC_CACHE_INFO(add_total); | 220 | } |
229 | } else if (err == -EEXIST) | ||
230 | INC_CACHE_INFO(exist_race); | ||
231 | return err; | 221 | return err; |
232 | } | 222 | } |
233 | 223 | ||