From 35c754d79f4da80d5e8972f6403dd26f7962fd88 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Thu, 7 Feb 2008 00:14:05 -0800 Subject: memory controller BUG_ON() Move mem_controller_cache_charge() above radix_tree_preload(). radix_tree_preload() disables preemption, even though the gfp_mask passed contains __GFP_WAIT, we cannot really do __GFP_WAIT allocations, thus we hit a BUG_ON() in kmem_cache_alloc(). This patch moves mem_controller_cache_charge() to above radix_tree_preload() for cache charging. Signed-off-by: Balbir Singh Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/swap_state.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'mm/swap_state.c') diff --git a/mm/swap_state.c b/mm/swap_state.c index 581b609e748..6ce0669aced 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -75,13 +75,13 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask) BUG_ON(!PageLocked(page)); BUG_ON(PageSwapCache(page)); BUG_ON(PagePrivate(page)); - error = radix_tree_preload(gfp_mask); - if (!error) { - error = mem_cgroup_cache_charge(page, current->mm, gfp_mask); - if (error) - goto out; + error = mem_cgroup_cache_charge(page, current->mm, gfp_mask); + if (error) + goto out; + error = radix_tree_preload(gfp_mask); + if (!error) { write_lock_irq(&swapper_space.tree_lock); error = radix_tree_insert(&swapper_space.page_tree, entry.val, page); @@ -97,7 +97,8 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp_mask) } write_unlock_irq(&swapper_space.tree_lock); radix_tree_preload_end(); - } + } else + mem_cgroup_uncharge_page(page); out: return error; } -- cgit v1.2.3