From patchwork Thu Mar 29 07:03:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KAMEZAWA Hiroyuki X-Patchwork-Id: 149365 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AD7D8B6FA5 for ; Thu, 29 Mar 2012 18:05:42 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758700Ab2C2HFk (ORCPT ); Thu, 29 Mar 2012 03:05:40 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:43802 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758027Ab2C2HFi (ORCPT ); Thu, 29 Mar 2012 03:05:38 -0400 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 6C5153EE0BD for ; Thu, 29 Mar 2012 16:05:37 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 52D7245DEB2 for ; Thu, 29 Mar 2012 16:05:37 +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 3758645DEA6 for ; Thu, 29 Mar 2012 16:05:37 +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 20EC9E38002 for ; Thu, 29 Mar 2012 16:05:37 +0900 (JST) Received: from m106.s.css.fujitsu.com (m106.s.css.fujitsu.com [10.240.81.146]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id C5C13E38004 for ; Thu, 29 Mar 2012 16:05:36 +0900 (JST) Received: from m106.css.fujitsu.com (m106 [127.0.0.1]) by m106.s.css.fujitsu.com (Postfix) with ESMTP id 7E1B7A10011; Thu, 29 Mar 2012 16:05:36 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.101.173]) by m106.s.css.fujitsu.com (Postfix) with ESMTP id 41A98A0000F; Thu, 29 Mar 2012 16:05:35 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4F74095B.70105@jp.fujitsu.com> Date: Thu, 29 Mar 2012 16:03:55 +0900 From: KAMEZAWA Hiroyuki User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: KAMEZAWA Hiroyuki CC: Glauber Costa , netdev@vger.kernel.org, David Miller , Andrew Morton Subject: [PATCH 1/3] [BUGFIX] memcg/tcp : fix to see use_hierarchy in tcp memcontrol cgroup References: <4F7408B7.9090706@jp.fujitsu.com> In-Reply-To: <4F7408B7.9090706@jp.fujitsu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now, tcp memory control cgroup ignores memcg's use_hierarchy value and act as use_hierarchy=1 always. After this patch, tcp memcontrol will work as memcg is designed. Note: I know there is a discussion to remove use_hierarchy but this is BUG, now. Signed-off-by: KAMEZAWA Hiroyuki --- include/linux/memcontrol.h | 3 +++ mm/memcontrol.c | 5 +++++ net/ipv4/tcp_memcontrol.c | 2 +- 3 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index f94efd2..e116b7c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -199,6 +199,9 @@ void mem_cgroup_split_huge_fixup(struct page *head); bool mem_cgroup_bad_page_check(struct page *page); void mem_cgroup_print_bad_page(struct page *page); #endif + +bool mem_cgroup_use_hierarchy(struct mem_cgroup *memcg); + #else /* CONFIG_CGROUP_MEM_RES_CTLR */ struct mem_cgroup; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7d698df..467881f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -867,6 +867,11 @@ struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm) return memcg; } +bool mem_cgroup_use_hierarchy(struct mem_cgroup *memcg) +{ + return memcg->use_hierarchy; +} + /** * mem_cgroup_iter - iterate over memory cgroup hierarchy * @root: hierarchy root diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index e795272..32764a6 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c @@ -75,7 +75,7 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) tcp->tcp_memory_pressure = 0; parent_cg = tcp_prot.proto_cgroup(parent); - if (parent_cg) + if (parent_cg && mem_cgroup_use_hierarchy(parent)) res_parent = parent_cg->memory_allocated; res_counter_init(&tcp->tcp_memory_allocated, res_parent);