Commit bb63be0a authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

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: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 818db359
...@@ -52,16 +52,13 @@ static struct { ...@@ -52,16 +52,13 @@ static struct {
unsigned long del_total; unsigned long del_total;
unsigned long find_success; unsigned long find_success;
unsigned long find_total; unsigned long find_total;
unsigned long noent_race;
unsigned long exist_race;
} swap_cache_info; } swap_cache_info;
void show_swap_cache_info(void) void show_swap_cache_info(void)
{ {
printk("Swap cache: add %lu, delete %lu, find %lu/%lu, race %lu+%lu\n", printk("Swap cache: add %lu, delete %lu, find %lu/%lu\n",
swap_cache_info.add_total, swap_cache_info.del_total, swap_cache_info.add_total, swap_cache_info.del_total,
swap_cache_info.find_success, swap_cache_info.find_total, swap_cache_info.find_success, swap_cache_info.find_total);
swap_cache_info.noent_race, swap_cache_info.exist_race);
printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10)); printk("Free swap = %lukB\n", nr_swap_pages << (PAGE_SHIFT - 10));
printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10)); printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
} }
...@@ -89,6 +86,7 @@ static int __add_to_swap_cache(struct page *page, swp_entry_t entry, ...@@ -89,6 +86,7 @@ static int __add_to_swap_cache(struct page *page, swp_entry_t entry,
set_page_private(page, entry.val); set_page_private(page, entry.val);
total_swapcache_pages++; total_swapcache_pages++;
__inc_zone_page_state(page, NR_FILE_PAGES); __inc_zone_page_state(page, NR_FILE_PAGES);
INC_CACHE_INFO(add_total);
} }
write_unlock_irq(&swapper_space.tree_lock); write_unlock_irq(&swapper_space.tree_lock);
radix_tree_preload_end(); radix_tree_preload_end();
...@@ -102,10 +100,9 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry, ...@@ -102,10 +100,9 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry,
int error; int error;
BUG_ON(PageLocked(page)); BUG_ON(PageLocked(page));
if (!swap_duplicate(entry)) { if (!swap_duplicate(entry))
INC_CACHE_INFO(noent_race);
return -ENOENT; return -ENOENT;
}
SetPageLocked(page); SetPageLocked(page);
error = __add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL); error = __add_to_swap_cache(page, entry, gfp_mask & GFP_KERNEL);
/* /*
...@@ -114,11 +111,8 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry, ...@@ -114,11 +111,8 @@ static int add_to_swap_cache(struct page *page, swp_entry_t entry,
if (error) { if (error) {
ClearPageLocked(page); ClearPageLocked(page);
swap_free(entry); swap_free(entry);
if (error == -EEXIST)
INC_CACHE_INFO(exist_race);
return error; return error;
} }
INC_CACHE_INFO(add_total);
return 0; return 0;
} }
...@@ -178,11 +172,9 @@ int add_to_swap(struct page * page, gfp_t gfp_mask) ...@@ -178,11 +172,9 @@ int add_to_swap(struct page * page, gfp_t gfp_mask)
case 0: /* Success */ case 0: /* Success */
SetPageUptodate(page); SetPageUptodate(page);
SetPageDirty(page); SetPageDirty(page);
INC_CACHE_INFO(add_total);
return 1; return 1;
case -EEXIST: case -EEXIST:
/* Raced with "speculative" read_swap_cache_async */ /* Raced with "speculative" read_swap_cache_async */
INC_CACHE_INFO(exist_race);
swap_free(entry); swap_free(entry);
continue; continue;
default: default:
...@@ -225,9 +217,7 @@ int move_to_swap_cache(struct page *page, swp_entry_t entry) ...@@ -225,9 +217,7 @@ int move_to_swap_cache(struct page *page, swp_entry_t entry)
if (!swap_duplicate(entry)) if (!swap_duplicate(entry))
BUG(); BUG();
SetPageDirty(page); SetPageDirty(page);
INC_CACHE_INFO(add_total); }
} else if (err == -EEXIST)
INC_CACHE_INFO(exist_race);
return err; return err;
} }
......
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