[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080630112347.76ed11a7.kamezawa.hiroyu@jp.fujitsu.com>
Date: Mon, 30 Jun 2008 11:23:47 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: Hugh Dickins <hugh@...itas.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Balbir Singh <balbir@...ibm.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] memcg: fix shmem_unuse_inode charging
On Sun, 29 Jun 2008 01:13:20 +0100 (BST)
Hugh Dickins <hugh@...itas.com> wrote:
> The mem_cgroup_cache_charge in shmem_unuse_inode has been moved after
> the radix_tree_preload, so generating a BUG: sleeping function called
> from invalid context. Move it back, uncharging where necessary.
>
> Signed-off-by: Hugh Dickins <hugh@...itas.com>
Sure, thanks,
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> ---
> Should follow mmotm's memcg-remove-refcnt-from-page_cgroup.patch
>
> mm/shmem.c | 28 ++++++++++++----------------
> 1 file changed, 12 insertions(+), 16 deletions(-)
>
> --- mmotm/mm/shmem.c 2008-06-27 13:39:20.000000000 +0100
> +++ linux/mm/shmem.c 2008-06-27 17:25:41.000000000 +0100
> @@ -922,27 +922,24 @@ found:
> error = 1;
> if (!inode)
> goto out;
> - error = radix_tree_preload(GFP_KERNEL);
> - if (error)
> - goto out;
> - /*
> - * Because we use GFP_NOWAIT in add_to_page_cache(), we can see -ENOMEM
> - * failure because of memory pressure in memory resource controller.
> - * Then, precharge page while we can wait, uncharge at failure will be
> - * automatically done in add_to_page_cache()
> - */
> + /* Precharge page using GFP_KERNEL while we can wait */
> error = mem_cgroup_cache_charge(page, current->mm, GFP_KERNEL);
> if (error)
> - goto preload_out;
> -
> + goto out;
> + error = radix_tree_preload(GFP_KERNEL);
> + if (error) {
> + mem_cgroup_uncharge_cache_page(page);
> + goto out;
> + }
> error = 1;
>
> spin_lock(&info->lock);
> ptr = shmem_swp_entry(info, idx, NULL);
> - if (ptr && ptr->val == entry.val)
> - error = add_to_page_cache(page, inode->i_mapping, idx,
> - GFP_NOWAIT);
> - else /* we don't have to account this page. */
> + if (ptr && ptr->val == entry.val) {
> + error = add_to_page_cache(page, inode->i_mapping,
> + idx, GFP_NOWAIT);
> + /* does mem_cgroup_uncharge_cache_page on error */
> + } else /* we must compensate for our precharge above */
> mem_cgroup_uncharge_cache_page(page);
>
> if (error == -EEXIST) {
> @@ -969,7 +966,6 @@ found:
> if (ptr)
> shmem_swp_unmap(ptr);
> spin_unlock(&info->lock);
> -preload_out:
> radix_tree_preload_end();
> out:
> unlock_page(page);
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists