From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kamezawa Hiroyuki Subject: Re: [PATCH 04/12] memcg, kmem: fix reference count handling on the error path Date: Tue, 09 Apr 2013 11:51:39 +0900 Message-ID: <5163823B.4020109@jp.fujitsu.com> References: <5162648B.9070802@huawei.com> <516264D6.3090100@huawei.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <516264D6.3090100-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Li Zefan Cc: Andrew Morton , Tejun Heo , Glauber Costa , Johannes Weiner , LKML , Cgroups , linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org (2013/04/08 15:33), Li Zefan wrote: > From: Michal Hocko > > mem_cgroup_css_online calls mem_cgroup_put if memcg_init_kmem > fails. This is not correct because only memcg_propagate_kmem takes an > additional reference while mem_cgroup_sockets_init is allowed to fail as > well (although no current implementation fails) but it doesn't take any > reference. This all suggests that it should be memcg_propagate_kmem that > should clean up after itself so this patch moves mem_cgroup_put over > there. > > Unfortunately this is not that easy (as pointed out by Li Zefan) because > memcg_kmem_mark_dead marks the group dead (KMEM_ACCOUNTED_DEAD) if it > is marked active (KMEM_ACCOUNTED_ACTIVE) which is the case even if > memcg_propagate_kmem fails so the additional reference is dropped in > that case in kmem_cgroup_destroy which means that the reference would be > dropped two times. > > The easiest way then would be to simply remove mem_cgrroup_put from > mem_cgroup_css_online and rely on kmem_cgroup_destroy doing the right > thing. > > Signed-off-by: Li Zefan > Signed-off-by: Michal Hocko > Cc: # 3.8.x Acked-by: KAMEZAWA Hiroyuki From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx125.postini.com [74.125.245.125]) by kanga.kvack.org (Postfix) with SMTP id 8C7D56B0005 for ; Mon, 8 Apr 2013 22:51:59 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id D6AE53EE0C8 for ; Tue, 9 Apr 2013 11:51:57 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id B6B8645DEBE for ; Tue, 9 Apr 2013 11:51:57 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 9D2BF45DEB6 for ; Tue, 9 Apr 2013 11:51:57 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 761571DB8043 for ; Tue, 9 Apr 2013 11:51:57 +0900 (JST) Received: from m1000.s.css.fujitsu.com (m1000.s.css.fujitsu.com [10.240.81.136]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 22B711DB803E for ; Tue, 9 Apr 2013 11:51:57 +0900 (JST) Message-ID: <5163823B.4020109@jp.fujitsu.com> Date: Tue, 09 Apr 2013 11:51:39 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: [PATCH 04/12] memcg, kmem: fix reference count handling on the error path References: <5162648B.9070802@huawei.com> <516264D6.3090100@huawei.com> In-Reply-To: <516264D6.3090100@huawei.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Li Zefan Cc: Andrew Morton , Tejun Heo , Glauber Costa , Johannes Weiner , LKML , Cgroups , linux-mm@kvack.org (2013/04/08 15:33), Li Zefan wrote: > From: Michal Hocko > > mem_cgroup_css_online calls mem_cgroup_put if memcg_init_kmem > fails. This is not correct because only memcg_propagate_kmem takes an > additional reference while mem_cgroup_sockets_init is allowed to fail as > well (although no current implementation fails) but it doesn't take any > reference. This all suggests that it should be memcg_propagate_kmem that > should clean up after itself so this patch moves mem_cgroup_put over > there. > > Unfortunately this is not that easy (as pointed out by Li Zefan) because > memcg_kmem_mark_dead marks the group dead (KMEM_ACCOUNTED_DEAD) if it > is marked active (KMEM_ACCOUNTED_ACTIVE) which is the case even if > memcg_propagate_kmem fails so the additional reference is dropped in > that case in kmem_cgroup_destroy which means that the reference would be > dropped two times. > > The easiest way then would be to simply remove mem_cgrroup_put from > mem_cgroup_css_online and rely on kmem_cgroup_destroy doing the right > thing. > > Signed-off-by: Li Zefan > Signed-off-by: Michal Hocko > Cc: # 3.8.x Acked-by: KAMEZAWA Hiroyuki -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936742Ab3DICwA (ORCPT ); Mon, 8 Apr 2013 22:52:00 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:60554 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934470Ab3DICv7 (ORCPT ); Mon, 8 Apr 2013 22:51:59 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.8.4 Message-ID: <5163823B.4020109@jp.fujitsu.com> Date: Tue, 09 Apr 2013 11:51:39 +0900 From: Kamezawa Hiroyuki User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Li Zefan CC: Andrew Morton , Tejun Heo , Glauber Costa , Johannes Weiner , LKML , Cgroups , linux-mm@kvack.org Subject: Re: [PATCH 04/12] memcg, kmem: fix reference count handling on the error path References: <5162648B.9070802@huawei.com> <516264D6.3090100@huawei.com> In-Reply-To: <516264D6.3090100@huawei.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2013/04/08 15:33), Li Zefan wrote: > From: Michal Hocko > > mem_cgroup_css_online calls mem_cgroup_put if memcg_init_kmem > fails. This is not correct because only memcg_propagate_kmem takes an > additional reference while mem_cgroup_sockets_init is allowed to fail as > well (although no current implementation fails) but it doesn't take any > reference. This all suggests that it should be memcg_propagate_kmem that > should clean up after itself so this patch moves mem_cgroup_put over > there. > > Unfortunately this is not that easy (as pointed out by Li Zefan) because > memcg_kmem_mark_dead marks the group dead (KMEM_ACCOUNTED_DEAD) if it > is marked active (KMEM_ACCOUNTED_ACTIVE) which is the case even if > memcg_propagate_kmem fails so the additional reference is dropped in > that case in kmem_cgroup_destroy which means that the reference would be > dropped two times. > > The easiest way then would be to simply remove mem_cgrroup_put from > mem_cgroup_css_online and rely on kmem_cgroup_destroy doing the right > thing. > > Signed-off-by: Li Zefan > Signed-off-by: Michal Hocko > Cc: # 3.8.x Acked-by: KAMEZAWA Hiroyuki