* Re: [PATCHv4 09/11] memcg: Use *_dec_not_zero instead of *_add_unless
2011-07-27 9:47 ` [PATCHv4 09/11] memcg: Use *_dec_not_zero instead of *_add_unless Sven Eckelmann
@ 2011-07-27 11:58 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2011-07-27 11:58 UTC (permalink / raw)
To: Sven Eckelmann
Cc: linux-arch, linux-kernel, Balbir Singh, Daisuke Nishimura,
KAMEZAWA Hiroyuki, linux-mm
On Wed 27-07-11 11:47:48, Sven Eckelmann wrote:
> atomic_dec_not_zero is defined for each architecture through
> <linux/atomic.h> to provide the functionality of
> atomic_add_unless(x, -1, 0).
yes, I like it because atomic_dec_* is more consistent (at least from
the code reading) with atomic_inc used by mem_cgroup_mark_under_oom
which.
>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Cc: linux-mm@kvack.org
Acked-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/memcontrol.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 5f84d23..00a7580 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1909,10 +1909,10 @@ static void mem_cgroup_unmark_under_oom(struct mem_cgroup *mem)
> /*
> * When a new child is created while the hierarchy is under oom,
> * mem_cgroup_oom_lock() may not be called. We have to use
> - * atomic_add_unless() here.
> + * atomic_dec_not_zero() here.
> */
> for_each_mem_cgroup_tree(iter, mem)
> - atomic_add_unless(&iter->under_oom, -1, 0);
> + atomic_dec_not_zero(&iter->under_oom);
> }
>
> static DEFINE_SPINLOCK(memcg_oom_lock);
> --
> 1.7.5.4
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread