From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx189.postini.com [74.125.245.189]) by kanga.kvack.org (Postfix) with SMTP id 3333C6B0062 for ; Tue, 26 Jun 2012 23:49:39 -0400 (EDT) Date: Tue, 26 Jun 2012 23:49:15 -0400 (EDT) From: Zhouping Liu Subject: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> In-Reply-To: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: Li Zefan , Tejun Heo , CAI Qian , LKML hi, all when I used memory cgroup in latest mainline, the following error occurred: # mount -t cgroup -o memory xxx /cgroup/ # ll /cgroup/memory.memsw.* -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes # cat /cgroup/memory.memsw.* cat: /cgroup/memory.memsw.failcnt: Operation not supported cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported I'm confusing why it can't read memory.memsw.* files. as commit:a42c390cfa0c said, CGROUP_MEM_RES_CTLR_SWAP_ENABLED and swapaccount kernel parameter control memcg swap accounting, but I confirmed the two options all don't be set: # cat /usr/lib/modules/3.5.0-rc4+/source/.config | grep CGROUP_MEM CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y # CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED is not set CONFIG_CGROUP_MEM_RES_CTLR_KMEM=y # cat /proc/cmdline BOOT_IMAGE=/vmlinuz-3.5.0-rc4+ root=/dev/mapper/vg_amd--pike--06-lv_root ro rd.lvm.lv=vg_amd-pike-06/lv_swap rd.md=0 LANG=en_US.UTF-8 console=ttyS0,115200n81 KEYTABLE=us SYSFONT=True rd.luks=0 rd.dm=0 rd.lvm.lv=vg_amd-pike-06/lv_root so I have two problems here: 1. when kernel neither set 'CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED' nor 'swapaccount' options, why memcg have memory.memsw.* files ? 2. why we can't read memory.memsw.* ? Addition info: when I open CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED option, the above issues are gone. also I tested v3.4.0, there aren't the two issues, so please take a look. -- Thanks, Zhouping -- 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: from psmtp.com (na3sys010amx135.postini.com [74.125.245.135]) by kanga.kvack.org (Postfix) with SMTP id 38FD06B005C for ; Wed, 27 Jun 2012 11:48:32 -0400 (EDT) Date: Wed, 27 Jun 2012 17:48:27 +0200 From: Michal Hocko Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627154827.GA4420@tiehlicka.suse.cz> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Zhouping Liu Cc: linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML On Tue 26-06-12 23:49:15, Zhouping Liu wrote: > hi, all > > when I used memory cgroup in latest mainline, the following error occurred: > > # mount -t cgroup -o memory xxx /cgroup/ > # ll /cgroup/memory.memsw.* > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > # cat /cgroup/memory.memsw.* > cat: /cgroup/memory.memsw.failcnt: Operation not supported > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > I'm confusing why it can't read memory.memsw.* files. Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even if the feature is turned off when any attempt to open the file returns EOPNOTSUPP which is exactly what you are seeing. This is a deliberate decision see: b6d9270d (memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). Does this help to explain your problem? Do you actually see any problem with this behavior? Thanks -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx144.postini.com [74.125.245.144]) by kanga.kvack.org (Postfix) with SMTP id CAA976B0069 for ; Wed, 27 Jun 2012 16:04:54 -0400 (EDT) Received: by pbbrp2 with SMTP id rp2so2475489pbb.14 for ; Wed, 27 Jun 2012 13:04:54 -0700 (PDT) Date: Wed, 27 Jun 2012 13:04:51 -0700 (PDT) From: David Rientjes Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627154827.GA4420@tiehlicka.suse.cz> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Zhouping Liu , linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML , Andrew Morton On Wed, 27 Jun 2012, Michal Hocko wrote: > > # mount -t cgroup -o memory xxx /cgroup/ > > # ll /cgroup/memory.memsw.* > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > > # cat /cgroup/memory.memsw.* > > cat: /cgroup/memory.memsw.failcnt: Operation not supported > > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > > > I'm confusing why it can't read memory.memsw.* files. > > Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even > if the feature is turned off when any attempt to open the file returns > EOPNOTSUPP which is exactly what you are seeing. > This is a deliberate decision see: b6d9270d (memcg: always create memsw > files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). > You mean af36f906c0f4? > Does this help to explain your problem? Do you actually see any problem > with this behavior? > I think it's a crappy solution and one that is undocumented in Documentation/cgroups/memory.txt. If you can only enable swap accounting at boot either via .config or the command line then these files should never be added for CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when do_swap_account is 0. It's much easier to test if the feature is enabled by checking for the presence of these files at the memcg mount point rather than doing an open(2) and checking for -EOPNOTSUPP, which isn't even a listed error code. I don't care how much cleaner it makes the internal memcg code. -- 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: from psmtp.com (na3sys010amx181.postini.com [74.125.245.181]) by kanga.kvack.org (Postfix) with SMTP id 940416B0069 for ; Wed, 27 Jun 2012 16:09:31 -0400 (EDT) Received: by dakp5 with SMTP id p5so2263643dak.14 for ; Wed, 27 Jun 2012 13:09:30 -0700 (PDT) Date: Wed, 27 Jun 2012 13:09:26 -0700 From: Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627200926.GR15811@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Hello, Michal, David. On Wed, Jun 27, 2012 at 01:04:51PM -0700, David Rientjes wrote: > I think it's a crappy solution and one that is undocumented in > Documentation/cgroups/memory.txt. If you can only enable swap accounting > at boot either via .config or the command line then these files should > never be added for CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when > do_swap_account is 0. It's much easier to test if the feature is enabled > by checking for the presence of these files at the memcg mount point > rather than doing an open(2) and checking for -EOPNOTSUPP, which isn't > even a listed error code. I don't care how much cleaner it makes the > internal memcg code. Yeah, it's kinda ugly. Taking a step back, do we really need be able to configure out memsw? How much vmlinux bloat or runtime overhead are we talking about? I don't think config options need to be this granular. Thanks. -- tejun -- 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: from psmtp.com (na3sys010amx135.postini.com [74.125.245.135]) by kanga.kvack.org (Postfix) with SMTP id E95896B005A for ; Wed, 27 Jun 2012 16:21:29 -0400 (EDT) Received: by dakp5 with SMTP id p5so2279377dak.14 for ; Wed, 27 Jun 2012 13:21:29 -0700 (PDT) Date: Wed, 27 Jun 2012 13:21:27 -0700 (PDT) From: David Rientjes Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627200926.GR15811@google.com> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton On Wed, 27 Jun 2012, Tejun Heo wrote: > Yeah, it's kinda ugly. Taking a step back, do we really need be able > to configure out memsw? How much vmlinux bloat or runtime overhead > are we talking about? I don't think config options need to be this > granular. > Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP since configuring them would imply there is some limit to be enforced. But to answer your question: text data bss dec hex filename 25777 3644 4128 33549 830d memcontrol.o.swap_disabled 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled Is it really too painful to not create these files when CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is written? -- 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: from psmtp.com (na3sys010amx176.postini.com [74.125.245.176]) by kanga.kvack.org (Postfix) with SMTP id CF3AD6B005A for ; Wed, 27 Jun 2012 16:24:35 -0400 (EDT) Received: by pbbrp2 with SMTP id rp2so2501736pbb.14 for ; Wed, 27 Jun 2012 13:24:35 -0700 (PDT) Date: Wed, 27 Jun 2012 13:24:30 -0700 From: Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627202430.GS15811@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki Hello, On Wed, Jun 27, 2012 at 01:21:27PM -0700, David Rientjes wrote: > Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so Right. > even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into > CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP > since configuring them would imply there is some limit to be enforced. > > But to answer your question: > > text data bss dec hex filename > 25777 3644 4128 33549 830d memcontrol.o.swap_disabled > 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled I still wish it's folded into CONFIG_MEMCG and conditionalized just on CONFIG_SWAP tho. > Is it really too painful to not create these files when > CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow > them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is > written? Not at all, that was the first version anyway, which (IIRC) KAME didn't like and suggested always creating those files. KAME, what do you think? Thanks. -- tejun -- 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: from psmtp.com (na3sys010amx124.postini.com [74.125.245.124]) by kanga.kvack.org (Postfix) with SMTP id 2FC6E6B005C for ; Wed, 27 Jun 2012 16:26:28 -0400 (EDT) Received: by pbbrp2 with SMTP id rp2so2503979pbb.14 for ; Wed, 27 Jun 2012 13:26:27 -0700 (PDT) Date: Wed, 27 Jun 2012 13:26:24 -0700 (PDT) From: David Rientjes Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627202430.GS15811@google.com> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki On Wed, 27 Jun 2012, Tejun Heo wrote: > > text data bss dec hex filename > > 25777 3644 4128 33549 830d memcontrol.o.swap_disabled > > 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled > > I still wish it's folded into CONFIG_MEMCG and conditionalized just on > CONFIG_SWAP tho. > Agreed. -- 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: from psmtp.com (na3sys010amx142.postini.com [74.125.245.142]) by kanga.kvack.org (Postfix) with SMTP id 993F56B005A for ; Thu, 28 Jun 2012 00:06:35 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 85ADC3EE0AE for ; Thu, 28 Jun 2012 13:06:33 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 6ADB945DE52 for ; Thu, 28 Jun 2012 13:06:33 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 55DF845DE4D for ; Thu, 28 Jun 2012 13:06:33 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 4655C1DB8038 for ; Thu, 28 Jun 2012 13:06:33 +0900 (JST) Received: from ml14.s.css.fujitsu.com (ml14.s.css.fujitsu.com [10.240.81.134]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id F05001DB803C for ; Thu, 28 Jun 2012 13:06:32 +0900 (JST) Message-ID: <4FEBD7C0.7090906@jp.fujitsu.com> Date: Thu, 28 Jun 2012 13:04:16 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> In-Reply-To: <20120627202430.GS15811@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton (2012/06/28 5:24), Tejun Heo wrote: > Hello, > > On Wed, Jun 27, 2012 at 01:21:27PM -0700, David Rientjes wrote: >> Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so > > Right. > >> even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into >> CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP >> since configuring them would imply there is some limit to be enforced. >> >> But to answer your question: >> >> text data bss dec hex filename >> 25777 3644 4128 33549 830d memcontrol.o.swap_disabled >> 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled > > I still wish it's folded into CONFIG_MEMCG and conditionalized just on > CONFIG_SWAP tho. > In old days, memsw controller was not very stable. So, we devided the config. And, it makes size of memory for swap-device double (adds 2bytes per swapent.) That is the problem. >> Is it really too painful to not create these files when >> CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow >> them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is >> written? > > Not at all, that was the first version anyway, which (IIRC) KAME > didn't like and suggested always creating those files. KAME, what do > you think? > IIRC...at that time, we made decision, cgroup has no feature to 'create files dynamically'. Then, we made it in static, decision was done at compile time and ignores "do_swap_account". Now, IIUC, we have the feature. So, it's may be a time to create the file with regard to "do_swap_account", making decision at boot time. Thanks, -Kame -- 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: from psmtp.com (na3sys010amx129.postini.com [74.125.245.129]) by kanga.kvack.org (Postfix) with SMTP id 200BA6B005A for ; Thu, 28 Jun 2012 08:36:16 -0400 (EDT) Date: Thu, 28 Jun 2012 14:36:11 +0200 From: Michal Hocko Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628123611.GA16042@tiehlicka.suse.cz> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Zhouping Liu , linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki , aneesh.kumar@linux.vnet.ibm.com [Adding Kame and Aneesh to CC] On Wed 27-06-12 13:04:51, David Rientjes wrote: > On Wed, 27 Jun 2012, Michal Hocko wrote: > > > > # mount -t cgroup -o memory xxx /cgroup/ > > > # ll /cgroup/memory.memsw.* > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > > > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > > > # cat /cgroup/memory.memsw.* > > > cat: /cgroup/memory.memsw.failcnt: Operation not supported > > > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > > > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > > > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > > > > > I'm confusing why it can't read memory.memsw.* files. > > > > Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even > > if the feature is turned off when any attempt to open the file returns > > EOPNOTSUPP which is exactly what you are seeing. > > This is a deliberate decision see: b6d9270d (memcg: always create memsw > > files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). > > > > You mean af36f906c0f4? Ahh, right. The other one was from the mm tree. Sorry about the confusion. > > Does this help to explain your problem? Do you actually see any problem > > with this behavior? > > > > I think it's a crappy solution and one that is undocumented in > Documentation/cgroups/memory.txt. Yes the documentation part is really missing. I don't think the current state is ideal as well... > If you can only enable swap accounting at boot either via .config > or the command line then these files should never be added for > CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when do_swap_account is 0. Yes, I think we can enhance the internal implementation to support configurable files (hugetlb controler would benefit from it as well because the exported files depend on the supported/configured huge page sizes). What about something like (totally untested) patch bellow? If this sounds like a reasonable thing to support I can spin a regular patch... --- diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index d3f5fba..3fc7859 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -527,6 +527,7 @@ struct cgroup_subsys { /* base cftypes, automatically [de]registered with subsys itself */ struct cftype *base_cftypes; + bool (*cftype_enabled)(const char *name); struct cftype_set base_cftset; /* should be defined only by modular subsystems */ diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 0f3527d..0d1a25d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, int err, ret = 0; for (cft = cfts; cft->name[0] != '\0'; cft++) { + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) + continue; + if (is_add) err = cgroup_add_file(cgrp, subsys, cft); else diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a2677e0..45b65ba 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -72,6 +72,13 @@ static int really_do_swap_account __initdata = 1; static int really_do_swap_account __initdata = 0; #endif +bool mem_cgroup_file_enabled(const char *name) +{ + if (!strncmp("memsw.", name, 6)) + return do_swap_account; + return true; +} + #else #define do_swap_account 0 #endif @@ -5521,6 +5528,9 @@ struct cgroup_subsys mem_cgroup_subsys = { .cancel_attach = mem_cgroup_cancel_attach, .attach = mem_cgroup_move_task, .base_cftypes = mem_cgroup_files, +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP + .cftype_enabled = mem_cgroup_file_enabled, +#endif .early_init = 0, .use_id = 1, .__DEPRECATED_clear_css_refs = true, -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx192.postini.com [74.125.245.192]) by kanga.kvack.org (Postfix) with SMTP id 6FD826B005A for ; Thu, 28 Jun 2012 14:30:04 -0400 (EDT) Received: by pbbrp2 with SMTP id rp2so4165907pbb.14 for ; Thu, 28 Jun 2012 11:30:03 -0700 (PDT) Date: Thu, 28 Jun 2012 11:29:34 -0700 From: Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628182934.GD22641@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120628123611.GA16042@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120628123611.GA16042@tiehlicka.suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: David Rientjes , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki , aneesh.kumar@linux.vnet.ibm.com Hello, Michal. On Thu, Jun 28, 2012 at 02:36:11PM +0200, Michal Hocko wrote: > @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, > int err, ret = 0; > > for (cft = cfts; cft->name[0] != '\0'; cft++) { > + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) > + continue; > + > if (is_add) > err = cgroup_add_file(cgrp, subsys, cft); > else I hope we could avoid this dynamic decision. That was one of the main reasons behind doing the cftype thing. It's better to be able to "declare" these kind of things rather than being able to implement fully flexible dynamic logic. Too much flexibility often doesn't achieve much while being a hindrance to evolution of code base (trying to improve / simplify X - ooh... there's this single wacko corner case YYY here which is really different from all other users). really_do_swap_account can't change once booted, right? Why not just separate out memsw cfts into a separate array and call cgroup_add_cftypes() from init path? Can't we do that from enable_swap_cgroup()? Thanks. -- tejun -- 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: from psmtp.com (na3sys010amx200.postini.com [74.125.245.200]) by kanga.kvack.org (Postfix) with SMTP id B06D96B005A for ; Thu, 28 Jun 2012 14:31:50 -0400 (EDT) Received: by dakp5 with SMTP id p5so3965442dak.14 for ; Thu, 28 Jun 2012 11:31:50 -0700 (PDT) Date: Thu, 28 Jun 2012 11:31:45 -0700 From: Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628183145.GE22641@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FEBD7C0.7090906@jp.fujitsu.com> Sender: owner-linux-mm@kvack.org List-ID: To: Kamezawa Hiroyuki Cc: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Hello, KAME. On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > >I still wish it's folded into CONFIG_MEMCG and conditionalized just on > >CONFIG_SWAP tho. > > > > In old days, memsw controller was not very stable. So, we devided the config. > And, it makes size of memory for swap-device double (adds 2bytes per swapent.) > That is the problem. I see. Do you think it's now reasonable to drop the separate config option? Having memcg enabled but swap unaccounted sounds half-broken to me. > IIRC...at that time, we made decision, cgroup has no feature to > 'create files dynamically'. Then, we made it in static, decision was done > at compile time and ignores "do_swap_account". > > Now, IIUC, we have the feature. So, it's may be a time to create the file > with regard to "do_swap_account", making decision at boot time. Heh, yeah, maybe I'm confused about how it happened. Anyways, let's get it fixed. Thanks! -- tejun -- 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: from psmtp.com (na3sys010amx171.postini.com [74.125.245.171]) by kanga.kvack.org (Postfix) with SMTP id 1D7EA6B005A for ; Thu, 28 Jun 2012 20:14:06 -0400 (EDT) Received: from m1.gw.fujitsu.co.jp (unknown [10.0.50.71]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 1BB563EE0BC for ; Fri, 29 Jun 2012 09:14:04 +0900 (JST) Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 0257645DE59 for ; Fri, 29 Jun 2012 09:14:04 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.fujitsu.co.jp [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id DE7A345DE56 for ; Fri, 29 Jun 2012 09:14:03 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id CC0A01DB8051 for ; Fri, 29 Jun 2012 09:14:03 +0900 (JST) Received: from m1001.s.css.fujitsu.com (m1001.s.css.fujitsu.com [10.240.81.139]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 82EC91DB804A for ; Fri, 29 Jun 2012 09:14:03 +0900 (JST) Message-ID: <4FECF2B4.5040500@jp.fujitsu.com> Date: Fri, 29 Jun 2012 09:11:32 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120628123611.GA16042@tiehlicka.suse.cz> <20120628182934.GD22641@google.com> In-Reply-To: <20120628182934.GD22641@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: Michal Hocko , David Rientjes , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , aneesh.kumar@linux.vnet.ibm.com (2012/06/29 3:29), Tejun Heo wrote: > Hello, Michal. > > On Thu, Jun 28, 2012 at 02:36:11PM +0200, Michal Hocko wrote: >> @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, >> int err, ret = 0; >> >> for (cft = cfts; cft->name[0] != '\0'; cft++) { >> + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) >> + continue; >> + >> if (is_add) >> err = cgroup_add_file(cgrp, subsys, cft); >> else > > I hope we could avoid this dynamic decision. That was one of the main > reasons behind doing the cftype thing. It's better to be able to > "declare" these kind of things rather than being able to implement > fully flexible dynamic logic. Too much flexibility often doesn't > achieve much while being a hindrance to evolution of code base (trying > to improve / simplify X - ooh... there's this single wacko corner case > YYY here which is really different from all other users). > > really_do_swap_account can't change once booted, right? Why not just > separate out memsw cfts into a separate array and call > cgroup_add_cftypes() from init path? Can't we do that from > enable_swap_cgroup()? > Yes, that's will be good. Thanks, -Kame -- 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: from psmtp.com (na3sys010amx173.postini.com [74.125.245.173]) by kanga.kvack.org (Postfix) with SMTP id 5202C6B0062 for ; Fri, 29 Jun 2012 03:19:33 -0400 (EDT) Message-ID: <4FED5661.1030102@parallels.com> Date: Fri, 29 Jun 2012 11:16:49 +0400 From: Glauber Costa MIME-Version: 1.0 Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> In-Reply-To: <4FEBD7C0.7090906@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Kamezawa Hiroyuki Cc: Tejun Heo , David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton On 06/28/2012 08:04 AM, Kamezawa Hiroyuki wrote: >> >> I still wish it's folded into CONFIG_MEMCG and conditionalized just on >> CONFIG_SWAP tho. >> > > In old days, memsw controller was not very stable. So, we devided the > config. > And, it makes size of memory for swap-device double (adds 2bytes per > swapent.) > That is the problem. That's the tendency to happen with anything new, since we want to add it without disrupting what's already in there. I am not very fond of config options explosions myself, so I am for removing it. -- 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: from psmtp.com (na3sys010amx160.postini.com [74.125.245.160]) by kanga.kvack.org (Postfix) with SMTP id ACBEE6B005A for ; Fri, 29 Jun 2012 23:48:07 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id AE2173EE0AE for ; Sat, 30 Jun 2012 12:48:05 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 961C545DEAD for ; Sat, 30 Jun 2012 12:48:05 +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 8008D45DE9E for ; Sat, 30 Jun 2012 12:48:05 +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 7162C1DB803C for ; Sat, 30 Jun 2012 12:48:05 +0900 (JST) Received: from m1001.s.css.fujitsu.com (m1001.s.css.fujitsu.com [10.240.81.139]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 211541DB8038 for ; Sat, 30 Jun 2012 12:48:05 +0900 (JST) Message-ID: <4FEE7665.6020409@jp.fujitsu.com> Date: Sat, 30 Jun 2012 12:45:41 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> <20120628183145.GE22641@google.com> In-Reply-To: <20120628183145.GE22641@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tejun Heo Cc: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton (2012/06/29 3:31), Tejun Heo wrote: > Hello, KAME. > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: >>> I still wish it's folded into CONFIG_MEMCG and conditionalized just on >>> CONFIG_SWAP tho. >>> >> >> In old days, memsw controller was not very stable. So, we devided the config. >> And, it makes size of memory for swap-device double (adds 2bytes per swapent.) >> That is the problem. > > I see. Do you think it's now reasonable to drop the separate config > option? Having memcg enabled but swap unaccounted sounds half-broken > to me. > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in the next week. Thanks, -Kame -- 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: from psmtp.com (na3sys010amx152.postini.com [74.125.245.152]) by kanga.kvack.org (Postfix) with SMTP id 6467E6B0005 for ; Mon, 21 Jan 2013 03:39:16 -0500 (EST) Date: Mon, 21 Jan 2013 03:39:07 -0500 (EST) From: Zhouping Liu Message-ID: <389106003.8637801.1358757547754.JavaMail.root@redhat.com> In-Reply-To: <4FEE7665.6020409@jp.fujitsu.com> Subject: Re: memcg: cat: memory.memsw.* : Operation not supported MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Kamezawa Hiroyuki Cc: David Rientjes , Michal Hocko , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo ----- Original Message ----- > From: "Kamezawa Hiroyuki" > To: "Tejun Heo" > Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , > linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" > , "Andrew Morton" > Sent: Saturday, June 30, 2012 11:45:41 AM > Subject: Re: memcg: cat: memory.memsw.* : Operation not supported > > (2012/06/29 3:31), Tejun Heo wrote: > > Hello, KAME. > > > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > >>> I still wish it's folded into CONFIG_MEMCG and conditionalized > >>> just on > >>> CONFIG_SWAP tho. > >>> > >> > >> In old days, memsw controller was not very stable. So, we devided > >> the config. > >> And, it makes size of memory for swap-device double (adds 2bytes > >> per swapent.) > >> That is the problem. > > > > I see. Do you think it's now reasonable to drop the separate > > config > > option? Having memcg enabled but swap unaccounted sounds > > half-broken > > to me. > > > > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in > the next week. Hello Kame and All, Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) do you have any updates for the issue? I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: [root@dhcp-8-128 ~] cat .config | grep -i memcg CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y # CONFIG_MEMCG_SWAP_ENABLED is not set CONFIG_MEMCG_KMEM=y [root@dhcp-8-128 ~] uname -r 3.8.0-rc4+ [root@dhcp-8-128 ~] cat memory.memsw.* cat: memory.memsw.failcnt: Operation not supported cat: memory.memsw.limit_in_bytes: Operation not supported cat: memory.memsw.max_usage_in_bytes: Operation not supported cat: memory.memsw.usage_in_bytes: Operation not supported As David said, we should not export memory.memsw.* files if we disable CONFIG_MEMCG_SWAP_ENABLED, or return -EINVAL, right? (please correct me if I'm wrong) -- Thanks, Zhouping -- 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: from psmtp.com (na3sys010amx110.postini.com [74.125.245.110]) by kanga.kvack.org (Postfix) with SMTP id AFB9A6B0004 for ; Mon, 21 Jan 2013 05:56:28 -0500 (EST) Date: Mon, 21 Jan 2013 11:56:24 +0100 From: Michal Hocko Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121105624.GF7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <389106003.8637801.1358757547754.JavaMail.root@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo On Mon 21-01-13 03:39:07, Zhouping Liu wrote: > > > ----- Original Message ----- > > From: "Kamezawa Hiroyuki" > > To: "Tejun Heo" > > Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , > > linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" > > , "Andrew Morton" > > Sent: Saturday, June 30, 2012 11:45:41 AM > > Subject: Re: memcg: cat: memory.memsw.* : Operation not supported > > > > (2012/06/29 3:31), Tejun Heo wrote: > > > Hello, KAME. > > > > > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > > >>> I still wish it's folded into CONFIG_MEMCG and conditionalized > > >>> just on > > >>> CONFIG_SWAP tho. > > >>> > > >> > > >> In old days, memsw controller was not very stable. So, we devided > > >> the config. > > >> And, it makes size of memory for swap-device double (adds 2bytes > > >> per swapent.) > > >> That is the problem. > > > > > > I see. Do you think it's now reasonable to drop the separate > > > config > > > option? Having memcg enabled but swap unaccounted sounds > > > half-broken > > > to me. > > > > > > > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in > > the next week. > > Hello Kame and All, > > Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) > > do you have any updates for the issue? > > I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed > CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: > > [root@dhcp-8-128 ~] cat .config | grep -i memcg > CONFIG_MEMCG=y > CONFIG_MEMCG_SWAP=y > # CONFIG_MEMCG_SWAP_ENABLED is not set > CONFIG_MEMCG_KMEM=y > [root@dhcp-8-128 ~] uname -r > 3.8.0-rc4+ > [root@dhcp-8-128 ~] cat memory.memsw.* > cat: memory.memsw.failcnt: Operation not supported > cat: memory.memsw.limit_in_bytes: Operation not supported > cat: memory.memsw.max_usage_in_bytes: Operation not supported > cat: memory.memsw.usage_in_bytes: Operation not supported Ohh, this one got lost. I thought Kame was working on that. Anyway the patch bellow should work: --- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx202.postini.com [74.125.245.202]) by kanga.kvack.org (Postfix) with SMTP id 1FA9F6B0004 for ; Mon, 21 Jan 2013 06:12:11 -0500 (EST) Date: Mon, 21 Jan 2013 12:12:06 +0100 From: Michal Hocko Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121111206.GG7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130121105624.GF7798@dhcp22.suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo And we can put another clean up patch on top of the fix: --- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx158.postini.com [74.125.245.158]) by kanga.kvack.org (Postfix) with SMTP id 2A7CE6B0004 for ; Mon, 21 Jan 2013 08:29:20 -0500 (EST) Message-ID: <50FD4245.3070402@redhat.com> Date: Mon, 21 Jan 2013 21:27:33 +0800 From: Zhouping Liu MIME-Version: 1.0 Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> In-Reply-To: <20130121105624.GF7798@dhcp22.suse.cz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo On 01/21/2013 06:56 PM, Michal Hocko wrote: > On Mon 21-01-13 03:39:07, Zhouping Liu wrote: >> >> ----- Original Message ----- >>> From: "Kamezawa Hiroyuki" >>> To: "Tejun Heo" >>> Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , >>> linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" >>> , "Andrew Morton" >>> Sent: Saturday, June 30, 2012 11:45:41 AM >>> Subject: Re: memcg: cat: memory.memsw.* : Operation not supported >>> >>> (2012/06/29 3:31), Tejun Heo wrote: >>>> Hello, KAME. >>>> >>>> On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: >>>>>> I still wish it's folded into CONFIG_MEMCG and conditionalized >>>>>> just on >>>>>> CONFIG_SWAP tho. >>>>>> >>>>> In old days, memsw controller was not very stable. So, we devided >>>>> the config. >>>>> And, it makes size of memory for swap-device double (adds 2bytes >>>>> per swapent.) >>>>> That is the problem. >>>> I see. Do you think it's now reasonable to drop the separate >>>> config >>>> option? Having memcg enabled but swap unaccounted sounds >>>> half-broken >>>> to me. >>>> >>> Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in >>> the next week. >> Hello Kame and All, >> >> Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) >> >> do you have any updates for the issue? >> >> I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed >> CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: >> >> [root@dhcp-8-128 ~] cat .config | grep -i memcg >> CONFIG_MEMCG=y >> CONFIG_MEMCG_SWAP=y >> # CONFIG_MEMCG_SWAP_ENABLED is not set >> CONFIG_MEMCG_KMEM=y >> [root@dhcp-8-128 ~] uname -r >> 3.8.0-rc4+ >> [root@dhcp-8-128 ~] cat memory.memsw.* >> cat: memory.memsw.failcnt: Operation not supported >> cat: memory.memsw.limit_in_bytes: Operation not supported >> cat: memory.memsw.max_usage_in_bytes: Operation not supported >> cat: memory.memsw.usage_in_bytes: Operation not supported > Ohh, this one got lost. I thought Kame was working on that. > Anyway the patch bellow should work: > --- > From 5f8141bf7d27014cfbc7b450f13f6146b5ab099d Mon Sep 17 00:00:00 2001 > From: Michal Hocko > Date: Mon, 21 Jan 2013 11:33:26 +0100 > Subject: [PATCH] memcg: Do not create memsw files if swap accounting is > disabled > > Zhouping Liu has reported that memsw files are exported even though > swap accounting is runtime disabled if CONFIG_MEMCG_SWAP is enabled. > This behavior has been introduced by af36f906 (memcg: always create > memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP) and it causes any > attempt to open the file to return EOPNOTSUPP. Although EOPNOTSUPP > should say be clear that memsw operations are not supported in the given > configuration it is fair to say that this behavior could be quite > confusing. > > Let's tear memsw files out of default cgroup files and add > them only if the swap accounting is really enabled (either by > CONFIG_MEMCG_SWAP_ENABLED or swapaccount=1 boot parameter). We can > hook into mem_cgroup_init which is called when the memcg subsystem is > initialized and which happens after boot command line is processed. Thanks for your quick patch, your patch looks good for me. I tested it with or without CONFIG_MEMCG_SWAP_ENABLED=y, and also tested it with swapaccount=1 kernel parameters, all are okay. Tested-by: Zhouping Liu Thanks, Zhouping -- 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: from psmtp.com (na3sys010amx143.postini.com [74.125.245.143]) by kanga.kvack.org (Postfix) with SMTP id F15776B0004 for ; Mon, 21 Jan 2013 08:46:51 -0500 (EST) Date: Mon, 21 Jan 2013 14:46:46 +0100 From: Michal Hocko Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121134646.GL7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> <50FD4245.3070402@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50FD4245.3070402@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo On Mon 21-01-13 21:27:33, Zhouping Liu wrote: > On 01/21/2013 06:56 PM, Michal Hocko wrote: [...] > > From 5f8141bf7d27014cfbc7b450f13f6146b5ab099d Mon Sep 17 00:00:00 2001 > >From: Michal Hocko > >Date: Mon, 21 Jan 2013 11:33:26 +0100 > >Subject: [PATCH] memcg: Do not create memsw files if swap accounting is > > disabled > > > >Zhouping Liu has reported that memsw files are exported even though > >swap accounting is runtime disabled if CONFIG_MEMCG_SWAP is enabled. > >This behavior has been introduced by af36f906 (memcg: always create > >memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP) and it causes any > >attempt to open the file to return EOPNOTSUPP. Although EOPNOTSUPP > >should say be clear that memsw operations are not supported in the given > >configuration it is fair to say that this behavior could be quite > >confusing. > > > >Let's tear memsw files out of default cgroup files and add > >them only if the swap accounting is really enabled (either by > >CONFIG_MEMCG_SWAP_ENABLED or swapaccount=1 boot parameter). We can > >hook into mem_cgroup_init which is called when the memcg subsystem is > >initialized and which happens after boot command line is processed. > > Thanks for your quick patch, your patch looks good for me. > > I tested it with or without CONFIG_MEMCG_SWAP_ENABLED=y, > and also tested it with swapaccount=1 kernel parameters, all are okay. > > Tested-by: Zhouping Liu Thanks for testing! -- Michal Hocko SUSE Labs -- 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 S1755957Ab2F0Dtl (ORCPT ); Tue, 26 Jun 2012 23:49:41 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:56733 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754645Ab2F0Dtk (ORCPT ); Tue, 26 Jun 2012 23:49:40 -0400 Date: Tue, 26 Jun 2012 23:49:15 -0400 (EDT) From: Zhouping Liu To: linux-mm@kvack.org Cc: Li Zefan , Tejun Heo , CAI Qian , LKML Subject: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> In-Reply-To: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Originating-IP: [10.66.12.116] X-Mailer: Zimbra 7.1.2_GA_3268 (ZimbraWebClient - FF3.0 (Linux)/7.1.2_GA_3268) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, all when I used memory cgroup in latest mainline, the following error occurred: # mount -t cgroup -o memory xxx /cgroup/ # ll /cgroup/memory.memsw.* -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes # cat /cgroup/memory.memsw.* cat: /cgroup/memory.memsw.failcnt: Operation not supported cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported I'm confusing why it can't read memory.memsw.* files. as commit:a42c390cfa0c said, CGROUP_MEM_RES_CTLR_SWAP_ENABLED and swapaccount kernel parameter control memcg swap accounting, but I confirmed the two options all don't be set: # cat /usr/lib/modules/3.5.0-rc4+/source/.config | grep CGROUP_MEM CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y # CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED is not set CONFIG_CGROUP_MEM_RES_CTLR_KMEM=y # cat /proc/cmdline BOOT_IMAGE=/vmlinuz-3.5.0-rc4+ root=/dev/mapper/vg_amd--pike--06-lv_root ro rd.lvm.lv=vg_amd-pike-06/lv_swap rd.md=0 LANG=en_US.UTF-8 console=ttyS0,115200n81 KEYTABLE=us SYSFONT=True rd.luks=0 rd.dm=0 rd.lvm.lv=vg_amd-pike-06/lv_root so I have two problems here: 1. when kernel neither set 'CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED' nor 'swapaccount' options, why memcg have memory.memsw.* files ? 2. why we can't read memory.memsw.* ? Addition info: when I open CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED option, the above issues are gone. also I tested v3.4.0, there aren't the two issues, so please take a look. -- Thanks, Zhouping From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757927Ab2F0Psb (ORCPT ); Wed, 27 Jun 2012 11:48:31 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39396 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756740Ab2F0Psa (ORCPT ); Wed, 27 Jun 2012 11:48:30 -0400 Date: Wed, 27 Jun 2012 17:48:27 +0200 From: Michal Hocko To: Zhouping Liu Cc: linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627154827.GA4420@tiehlicka.suse.cz> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 26-06-12 23:49:15, Zhouping Liu wrote: > hi, all > > when I used memory cgroup in latest mainline, the following error occurred: > > # mount -t cgroup -o memory xxx /cgroup/ > # ll /cgroup/memory.memsw.* > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > # cat /cgroup/memory.memsw.* > cat: /cgroup/memory.memsw.failcnt: Operation not supported > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > I'm confusing why it can't read memory.memsw.* files. Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even if the feature is turned off when any attempt to open the file returns EOPNOTSUPP which is exactly what you are seeing. This is a deliberate decision see: b6d9270d (memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). Does this help to explain your problem? Do you actually see any problem with this behavior? Thanks -- Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757452Ab2F0UEz (ORCPT ); Wed, 27 Jun 2012 16:04:55 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:52196 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753768Ab2F0UEy (ORCPT ); Wed, 27 Jun 2012 16:04:54 -0400 Date: Wed, 27 Jun 2012 13:04:51 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: Zhouping Liu , linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627154827.GA4420@tiehlicka.suse.cz> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jun 2012, Michal Hocko wrote: > > # mount -t cgroup -o memory xxx /cgroup/ > > # ll /cgroup/memory.memsw.* > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > > # cat /cgroup/memory.memsw.* > > cat: /cgroup/memory.memsw.failcnt: Operation not supported > > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > > > I'm confusing why it can't read memory.memsw.* files. > > Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even > if the feature is turned off when any attempt to open the file returns > EOPNOTSUPP which is exactly what you are seeing. > This is a deliberate decision see: b6d9270d (memcg: always create memsw > files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). > You mean af36f906c0f4? > Does this help to explain your problem? Do you actually see any problem > with this behavior? > I think it's a crappy solution and one that is undocumented in Documentation/cgroups/memory.txt. If you can only enable swap accounting at boot either via .config or the command line then these files should never be added for CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when do_swap_account is 0. It's much easier to test if the feature is enabled by checking for the presence of these files at the memcg mount point rather than doing an open(2) and checking for -EOPNOTSUPP, which isn't even a listed error code. I don't care how much cleaner it makes the internal memcg code. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757610Ab2F0UJd (ORCPT ); Wed, 27 Jun 2012 16:09:33 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49433 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756761Ab2F0UJb (ORCPT ); Wed, 27 Jun 2012 16:09:31 -0400 Date: Wed, 27 Jun 2012 13:09:26 -0700 From: Tejun Heo To: David Rientjes Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627200926.GR15811@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Michal, David. On Wed, Jun 27, 2012 at 01:04:51PM -0700, David Rientjes wrote: > I think it's a crappy solution and one that is undocumented in > Documentation/cgroups/memory.txt. If you can only enable swap accounting > at boot either via .config or the command line then these files should > never be added for CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when > do_swap_account is 0. It's much easier to test if the feature is enabled > by checking for the presence of these files at the memcg mount point > rather than doing an open(2) and checking for -EOPNOTSUPP, which isn't > even a listed error code. I don't care how much cleaner it makes the > internal memcg code. Yeah, it's kinda ugly. Taking a step back, do we really need be able to configure out memsw? How much vmlinux bloat or runtime overhead are we talking about? I don't think config options need to be this granular. Thanks. -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757536Ab2F0UVb (ORCPT ); Wed, 27 Jun 2012 16:21:31 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:62321 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753418Ab2F0UV3 (ORCPT ); Wed, 27 Jun 2012 16:21:29 -0400 Date: Wed, 27 Jun 2012 13:21:27 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Tejun Heo cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627200926.GR15811@google.com> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jun 2012, Tejun Heo wrote: > Yeah, it's kinda ugly. Taking a step back, do we really need be able > to configure out memsw? How much vmlinux bloat or runtime overhead > are we talking about? I don't think config options need to be this > granular. > Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP since configuring them would imply there is some limit to be enforced. But to answer your question: text data bss dec hex filename 25777 3644 4128 33549 830d memcontrol.o.swap_disabled 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled Is it really too painful to not create these files when CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is written? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755294Ab2F0UYg (ORCPT ); Wed, 27 Jun 2012 16:24:36 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:58617 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587Ab2F0UYf (ORCPT ); Wed, 27 Jun 2012 16:24:35 -0400 Date: Wed, 27 Jun 2012 13:24:30 -0700 From: Tejun Heo To: David Rientjes Cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120627202430.GS15811@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Jun 27, 2012 at 01:21:27PM -0700, David Rientjes wrote: > Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so Right. > even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into > CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP > since configuring them would imply there is some limit to be enforced. > > But to answer your question: > > text data bss dec hex filename > 25777 3644 4128 33549 830d memcontrol.o.swap_disabled > 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled I still wish it's folded into CONFIG_MEMCG and conditionalized just on CONFIG_SWAP tho. > Is it really too painful to not create these files when > CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow > them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is > written? Not at all, that was the first version anyway, which (IIRC) KAME didn't like and suggested always creating those files. KAME, what do you think? Thanks. -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757594Ab2F0U03 (ORCPT ); Wed, 27 Jun 2012 16:26:29 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:34521 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753427Ab2F0U01 (ORCPT ); Wed, 27 Jun 2012 16:26:27 -0400 Date: Wed, 27 Jun 2012 13:26:24 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Tejun Heo cc: Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki Subject: Re: memcg: cat: memory.memsw.* : Operation not supported In-Reply-To: <20120627202430.GS15811@google.com> Message-ID: References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jun 2012, Tejun Heo wrote: > > text data bss dec hex filename > > 25777 3644 4128 33549 830d memcontrol.o.swap_disabled > > 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled > > I still wish it's folded into CONFIG_MEMCG and conditionalized just on > CONFIG_SWAP tho. > Agreed. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751187Ab2F1EGg (ORCPT ); Thu, 28 Jun 2012 00:06:36 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:42584 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744Ab2F1EGf (ORCPT ); Thu, 28 Jun 2012 00:06:35 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4FEBD7C0.7090906@jp.fujitsu.com> Date: Thu, 28 Jun 2012 13:04:16 +0900 From: Kamezawa Hiroyuki User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Tejun Heo CC: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> In-Reply-To: <20120627202430.GS15811@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2012/06/28 5:24), Tejun Heo wrote: > Hello, > > On Wed, Jun 27, 2012 at 01:21:27PM -0700, David Rientjes wrote: >> Well it also has a prerequisite that memcg doesn't have: CONFIG_SWAP, so > > Right. > >> even if CONFIG_CGROUP_MEM_RES_CTLR_SWAP is folded into >> CONFIG_CGROUP_MEM_RES_CTLR, then these should still depend on CONFIG_SWAP >> since configuring them would imply there is some limit to be enforced. >> >> But to answer your question: >> >> text data bss dec hex filename >> 25777 3644 4128 33549 830d memcontrol.o.swap_disabled >> 27294 4476 4128 35898 8c3a memcontrol.o.swap_enabled > > I still wish it's folded into CONFIG_MEMCG and conditionalized just on > CONFIG_SWAP tho. > In old days, memsw controller was not very stable. So, we devided the config. And, it makes size of memory for swap-device double (adds 2bytes per swapent.) That is the problem. >> Is it really too painful to not create these files when >> CONFIG_CGROUP_MEM_RES_CTLR_SWAP is disabled? If so, can we at least allow >> them to be opened but return -EINVAL if memory.memsw.limit_in_bytes is >> written? > > Not at all, that was the first version anyway, which (IIRC) KAME > didn't like and suggested always creating those files. KAME, what do > you think? > IIRC...at that time, we made decision, cgroup has no feature to 'create files dynamically'. Then, we made it in static, decision was done at compile time and ignores "do_swap_account". Now, IIUC, we have the feature. So, it's may be a time to create the file with regard to "do_swap_account", making decision at boot time. Thanks, -Kame From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754296Ab2F1MgS (ORCPT ); Thu, 28 Jun 2012 08:36:18 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35912 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140Ab2F1MgP (ORCPT ); Thu, 28 Jun 2012 08:36:15 -0400 Date: Thu, 28 Jun 2012 14:36:11 +0200 From: Michal Hocko To: David Rientjes Cc: Zhouping Liu , linux-mm@kvack.org, Li Zefan , Tejun Heo , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki , aneesh.kumar@linux.vnet.ibm.com Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628123611.GA16042@tiehlicka.suse.cz> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Adding Kame and Aneesh to CC] On Wed 27-06-12 13:04:51, David Rientjes wrote: > On Wed, 27 Jun 2012, Michal Hocko wrote: > > > > # mount -t cgroup -o memory xxx /cgroup/ > > > # ll /cgroup/memory.memsw.* > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.failcnt > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.limit_in_bytes > > > -rw-r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.max_usage_in_bytes > > > -r--r--r--. 1 root root 0 Jun 26 23:17 /cgroup/memory.memsw.usage_in_bytes > > > # cat /cgroup/memory.memsw.* > > > cat: /cgroup/memory.memsw.failcnt: Operation not supported > > > cat: /cgroup/memory.memsw.limit_in_bytes: Operation not supported > > > cat: /cgroup/memory.memsw.max_usage_in_bytes: Operation not supported > > > cat: /cgroup/memory.memsw.usage_in_bytes: Operation not supported > > > > > > I'm confusing why it can't read memory.memsw.* files. > > > > Those files are exported if CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y even > > if the feature is turned off when any attempt to open the file returns > > EOPNOTSUPP which is exactly what you are seeing. > > This is a deliberate decision see: b6d9270d (memcg: always create memsw > > files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP). > > > > You mean af36f906c0f4? Ahh, right. The other one was from the mm tree. Sorry about the confusion. > > Does this help to explain your problem? Do you actually see any problem > > with this behavior? > > > > I think it's a crappy solution and one that is undocumented in > Documentation/cgroups/memory.txt. Yes the documentation part is really missing. I don't think the current state is ideal as well... > If you can only enable swap accounting at boot either via .config > or the command line then these files should never be added for > CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n or when do_swap_account is 0. Yes, I think we can enhance the internal implementation to support configurable files (hugetlb controler would benefit from it as well because the exported files depend on the supported/configured huge page sizes). What about something like (totally untested) patch bellow? If this sounds like a reasonable thing to support I can spin a regular patch... --- diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index d3f5fba..3fc7859 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -527,6 +527,7 @@ struct cgroup_subsys { /* base cftypes, automatically [de]registered with subsys itself */ struct cftype *base_cftypes; + bool (*cftype_enabled)(const char *name); struct cftype_set base_cftset; /* should be defined only by modular subsystems */ diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 0f3527d..0d1a25d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, int err, ret = 0; for (cft = cfts; cft->name[0] != '\0'; cft++) { + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) + continue; + if (is_add) err = cgroup_add_file(cgrp, subsys, cft); else diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a2677e0..45b65ba 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -72,6 +72,13 @@ static int really_do_swap_account __initdata = 1; static int really_do_swap_account __initdata = 0; #endif +bool mem_cgroup_file_enabled(const char *name) +{ + if (!strncmp("memsw.", name, 6)) + return do_swap_account; + return true; +} + #else #define do_swap_account 0 #endif @@ -5521,6 +5528,9 @@ struct cgroup_subsys mem_cgroup_subsys = { .cancel_attach = mem_cgroup_cancel_attach, .attach = mem_cgroup_move_task, .base_cftypes = mem_cgroup_files, +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP + .cftype_enabled = mem_cgroup_file_enabled, +#endif .early_init = 0, .use_id = 1, .__DEPRECATED_clear_css_refs = true, -- Michal Hocko SUSE Labs SUSE LINUX s.r.o. Lihovarska 1060/12 190 00 Praha 9 Czech Republic From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755730Ab2F1SaG (ORCPT ); Thu, 28 Jun 2012 14:30:06 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:49069 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751275Ab2F1SaE (ORCPT ); Thu, 28 Jun 2012 14:30:04 -0400 Date: Thu, 28 Jun 2012 11:29:34 -0700 From: Tejun Heo To: Michal Hocko Cc: David Rientjes , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , KAMEZAWA Hiroyuki , aneesh.kumar@linux.vnet.ibm.com Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628182934.GD22641@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120628123611.GA16042@tiehlicka.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120628123611.GA16042@tiehlicka.suse.cz> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Michal. On Thu, Jun 28, 2012 at 02:36:11PM +0200, Michal Hocko wrote: > @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, > int err, ret = 0; > > for (cft = cfts; cft->name[0] != '\0'; cft++) { > + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) > + continue; > + > if (is_add) > err = cgroup_add_file(cgrp, subsys, cft); > else I hope we could avoid this dynamic decision. That was one of the main reasons behind doing the cftype thing. It's better to be able to "declare" these kind of things rather than being able to implement fully flexible dynamic logic. Too much flexibility often doesn't achieve much while being a hindrance to evolution of code base (trying to improve / simplify X - ooh... there's this single wacko corner case YYY here which is really different from all other users). really_do_swap_account can't change once booted, right? Why not just separate out memsw cfts into a separate array and call cgroup_add_cftypes() from init path? Can't we do that from enable_swap_cgroup()? Thanks. -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755922Ab2F1Sbv (ORCPT ); Thu, 28 Jun 2012 14:31:51 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:46524 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752607Ab2F1Sbu (ORCPT ); Thu, 28 Jun 2012 14:31:50 -0400 Date: Thu, 28 Jun 2012 11:31:45 -0700 From: Tejun Heo To: Kamezawa Hiroyuki Cc: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20120628183145.GE22641@google.com> References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FEBD7C0.7090906@jp.fujitsu.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, KAME. On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > >I still wish it's folded into CONFIG_MEMCG and conditionalized just on > >CONFIG_SWAP tho. > > > > In old days, memsw controller was not very stable. So, we devided the config. > And, it makes size of memory for swap-device double (adds 2bytes per swapent.) > That is the problem. I see. Do you think it's now reasonable to drop the separate config option? Having memcg enabled but swap unaccounted sounds half-broken to me. > IIRC...at that time, we made decision, cgroup has no feature to > 'create files dynamically'. Then, we made it in static, decision was done > at compile time and ignores "do_swap_account". > > Now, IIUC, we have the feature. So, it's may be a time to create the file > with regard to "do_swap_account", making decision at boot time. Heh, yeah, maybe I'm confused about how it happened. Anyways, let's get it fixed. Thanks! -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754177Ab2F2AOI (ORCPT ); Thu, 28 Jun 2012 20:14:08 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:34595 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282Ab2F2AOG (ORCPT ); Thu, 28 Jun 2012 20:14:06 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4FECF2B4.5040500@jp.fujitsu.com> Date: Fri, 29 Jun 2012 09:11:32 +0900 From: Kamezawa Hiroyuki User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Tejun Heo CC: Michal Hocko , David Rientjes , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , aneesh.kumar@linux.vnet.ibm.com Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120628123611.GA16042@tiehlicka.suse.cz> <20120628182934.GD22641@google.com> In-Reply-To: <20120628182934.GD22641@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2012/06/29 3:29), Tejun Heo wrote: > Hello, Michal. > > On Thu, Jun 28, 2012 at 02:36:11PM +0200, Michal Hocko wrote: >> @@ -2726,6 +2726,9 @@ static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, >> int err, ret = 0; >> >> for (cft = cfts; cft->name[0] != '\0'; cft++) { >> + if (subsys->cftype_enabled && !subsys->cftype_enabled(cft->name)) >> + continue; >> + >> if (is_add) >> err = cgroup_add_file(cgrp, subsys, cft); >> else > > I hope we could avoid this dynamic decision. That was one of the main > reasons behind doing the cftype thing. It's better to be able to > "declare" these kind of things rather than being able to implement > fully flexible dynamic logic. Too much flexibility often doesn't > achieve much while being a hindrance to evolution of code base (trying > to improve / simplify X - ooh... there's this single wacko corner case > YYY here which is really different from all other users). > > really_do_swap_account can't change once booted, right? Why not just > separate out memsw cfts into a separate array and call > cgroup_add_cftypes() from init path? Can't we do that from > enable_swap_cgroup()? > Yes, that's will be good. Thanks, -Kame From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752503Ab2F2HTh (ORCPT ); Fri, 29 Jun 2012 03:19:37 -0400 Received: from mx2.parallels.com ([64.131.90.16]:45587 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210Ab2F2HTf (ORCPT ); Fri, 29 Jun 2012 03:19:35 -0400 Message-ID: <4FED5661.1030102@parallels.com> Date: Fri, 29 Jun 2012 11:16:49 +0400 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Kamezawa Hiroyuki CC: Tejun Heo , David Rientjes , Michal Hocko , Zhouping Liu , , Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> In-Reply-To: <4FEBD7C0.7090906@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/28/2012 08:04 AM, Kamezawa Hiroyuki wrote: >> >> I still wish it's folded into CONFIG_MEMCG and conditionalized just on >> CONFIG_SWAP tho. >> > > In old days, memsw controller was not very stable. So, we devided the > config. > And, it makes size of memory for swap-device double (adds 2bytes per > swapent.) > That is the problem. That's the tendency to happen with anything new, since we want to add it without disrupting what's already in there. I am not very fond of config options explosions myself, so I am for removing it. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753251Ab2F3DsJ (ORCPT ); Fri, 29 Jun 2012 23:48:09 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:44949 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126Ab2F3DsH (ORCPT ); Fri, 29 Jun 2012 23:48:07 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4FEE7665.6020409@jp.fujitsu.com> Date: Sat, 30 Jun 2012 12:45:41 +0900 From: Kamezawa Hiroyuki User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: Tejun Heo CC: David Rientjes , Michal Hocko , Zhouping Liu , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <2a1a74bf-fbb5-4a6e-b958-44fff8debff2@zmail13.collab.prod.int.phx2.redhat.com> <34bb8049-8007-496c-8ffb-11118c587124@zmail13.collab.prod.int.phx2.redhat.com> <20120627154827.GA4420@tiehlicka.suse.cz> <20120627200926.GR15811@google.com> <20120627202430.GS15811@google.com> <4FEBD7C0.7090906@jp.fujitsu.com> <20120628183145.GE22641@google.com> In-Reply-To: <20120628183145.GE22641@google.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (2012/06/29 3:31), Tejun Heo wrote: > Hello, KAME. > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: >>> I still wish it's folded into CONFIG_MEMCG and conditionalized just on >>> CONFIG_SWAP tho. >>> >> >> In old days, memsw controller was not very stable. So, we devided the config. >> And, it makes size of memory for swap-device double (adds 2bytes per swapent.) >> That is the problem. > > I see. Do you think it's now reasonable to drop the separate config > option? Having memcg enabled but swap unaccounted sounds half-broken > to me. > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in the next week. Thanks, -Kame From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752373Ab3AUIkB (ORCPT ); Mon, 21 Jan 2013 03:40:01 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:57863 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751509Ab3AUIkA (ORCPT ); Mon, 21 Jan 2013 03:40:00 -0500 Date: Mon, 21 Jan 2013 03:39:07 -0500 (EST) From: Zhouping Liu To: Kamezawa Hiroyuki Cc: David Rientjes , Michal Hocko , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo Message-ID: <389106003.8637801.1358757547754.JavaMail.root@redhat.com> In-Reply-To: <4FEE7665.6020409@jp.fujitsu.com> Subject: Re: memcg: cat: memory.memsw.* : Operation not supported MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.16.255.10] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Linux)/7.2.0_GA_2669) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > From: "Kamezawa Hiroyuki" > To: "Tejun Heo" > Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , > linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" > , "Andrew Morton" > Sent: Saturday, June 30, 2012 11:45:41 AM > Subject: Re: memcg: cat: memory.memsw.* : Operation not supported > > (2012/06/29 3:31), Tejun Heo wrote: > > Hello, KAME. > > > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > >>> I still wish it's folded into CONFIG_MEMCG and conditionalized > >>> just on > >>> CONFIG_SWAP tho. > >>> > >> > >> In old days, memsw controller was not very stable. So, we devided > >> the config. > >> And, it makes size of memory for swap-device double (adds 2bytes > >> per swapent.) > >> That is the problem. > > > > I see. Do you think it's now reasonable to drop the separate > > config > > option? Having memcg enabled but swap unaccounted sounds > > half-broken > > to me. > > > > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in > the next week. Hello Kame and All, Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) do you have any updates for the issue? I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: [root@dhcp-8-128 ~] cat .config | grep -i memcg CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y # CONFIG_MEMCG_SWAP_ENABLED is not set CONFIG_MEMCG_KMEM=y [root@dhcp-8-128 ~] uname -r 3.8.0-rc4+ [root@dhcp-8-128 ~] cat memory.memsw.* cat: memory.memsw.failcnt: Operation not supported cat: memory.memsw.limit_in_bytes: Operation not supported cat: memory.memsw.max_usage_in_bytes: Operation not supported cat: memory.memsw.usage_in_bytes: Operation not supported As David said, we should not export memory.memsw.* files if we disable CONFIG_MEMCG_SWAP_ENABLED, or return -EINVAL, right? (please correct me if I'm wrong) -- Thanks, Zhouping From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753095Ab3AUK43 (ORCPT ); Mon, 21 Jan 2013 05:56:29 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39240 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752691Ab3AUK42 (ORCPT ); Mon, 21 Jan 2013 05:56:28 -0500 Date: Mon, 21 Jan 2013 11:56:24 +0100 From: Michal Hocko To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121105624.GF7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <389106003.8637801.1358757547754.JavaMail.root@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 21-01-13 03:39:07, Zhouping Liu wrote: > > > ----- Original Message ----- > > From: "Kamezawa Hiroyuki" > > To: "Tejun Heo" > > Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , > > linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" > > , "Andrew Morton" > > Sent: Saturday, June 30, 2012 11:45:41 AM > > Subject: Re: memcg: cat: memory.memsw.* : Operation not supported > > > > (2012/06/29 3:31), Tejun Heo wrote: > > > Hello, KAME. > > > > > > On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: > > >>> I still wish it's folded into CONFIG_MEMCG and conditionalized > > >>> just on > > >>> CONFIG_SWAP tho. > > >>> > > >> > > >> In old days, memsw controller was not very stable. So, we devided > > >> the config. > > >> And, it makes size of memory for swap-device double (adds 2bytes > > >> per swapent.) > > >> That is the problem. > > > > > > I see. Do you think it's now reasonable to drop the separate > > > config > > > option? Having memcg enabled but swap unaccounted sounds > > > half-broken > > > to me. > > > > > > > Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in > > the next week. > > Hello Kame and All, > > Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) > > do you have any updates for the issue? > > I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed > CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: > > [root@dhcp-8-128 ~] cat .config | grep -i memcg > CONFIG_MEMCG=y > CONFIG_MEMCG_SWAP=y > # CONFIG_MEMCG_SWAP_ENABLED is not set > CONFIG_MEMCG_KMEM=y > [root@dhcp-8-128 ~] uname -r > 3.8.0-rc4+ > [root@dhcp-8-128 ~] cat memory.memsw.* > cat: memory.memsw.failcnt: Operation not supported > cat: memory.memsw.limit_in_bytes: Operation not supported > cat: memory.memsw.max_usage_in_bytes: Operation not supported > cat: memory.memsw.usage_in_bytes: Operation not supported Ohh, this one got lost. I thought Kame was working on that. Anyway the patch bellow should work: --- >>From 5f8141bf7d27014cfbc7b450f13f6146b5ab099d Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Mon, 21 Jan 2013 11:33:26 +0100 Subject: [PATCH] memcg: Do not create memsw files if swap accounting is disabled Zhouping Liu has reported that memsw files are exported even though swap accounting is runtime disabled if CONFIG_MEMCG_SWAP is enabled. This behavior has been introduced by af36f906 (memcg: always create memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP) and it causes any attempt to open the file to return EOPNOTSUPP. Although EOPNOTSUPP should say be clear that memsw operations are not supported in the given configuration it is fair to say that this behavior could be quite confusing. Let's tear memsw files out of default cgroup files and add them only if the swap accounting is really enabled (either by CONFIG_MEMCG_SWAP_ENABLED or swapaccount=1 boot parameter). We can hook into mem_cgroup_init which is called when the memcg subsystem is initialized and which happens after boot command line is processed. Reported-by: Zhouping Liu Signed-off-by: Michal Hocko --- mm/memcontrol.c | 94 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3817460..a2800db 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5988,33 +5988,6 @@ static struct cftype mem_cgroup_files[] = { .read_seq_string = memcg_numa_stat_show, }, #endif -#ifdef CONFIG_MEMCG_SWAP - { - .name = "memsw.usage_in_bytes", - .private = MEMFILE_PRIVATE(_MEMSWAP, RES_USAGE), - .read = mem_cgroup_read, - .register_event = mem_cgroup_usage_register_event, - .unregister_event = mem_cgroup_usage_unregister_event, - }, - { - .name = "memsw.max_usage_in_bytes", - .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE), - .trigger = mem_cgroup_reset, - .read = mem_cgroup_read, - }, - { - .name = "memsw.limit_in_bytes", - .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT), - .write_string = mem_cgroup_write, - .read = mem_cgroup_read, - }, - { - .name = "memsw.failcnt", - .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT), - .trigger = mem_cgroup_reset, - .read = mem_cgroup_read, - }, -#endif #ifdef CONFIG_MEMCG_KMEM { .name = "kmem.limit_in_bytes", @@ -6057,6 +6030,36 @@ static struct cftype mem_cgroup_files[] = { { }, /* terminate */ }; +#ifdef CONFIG_MEMCG_SWAP +static struct cftype memsw_cgroup_files[] = { + { + .name = "memsw.usage_in_bytes", + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_USAGE), + .read = mem_cgroup_read, + .register_event = mem_cgroup_usage_register_event, + .unregister_event = mem_cgroup_usage_unregister_event, + }, + { + .name = "memsw.max_usage_in_bytes", + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_MAX_USAGE), + .trigger = mem_cgroup_reset, + .read = mem_cgroup_read, + }, + { + .name = "memsw.limit_in_bytes", + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT), + .write_string = mem_cgroup_write, + .read = mem_cgroup_read, + }, + { + .name = "memsw.failcnt", + .private = MEMFILE_PRIVATE(_MEMSWAP, RES_FAILCNT), + .trigger = mem_cgroup_reset, + .read = mem_cgroup_read, + }, + { }, /* terminate */ +}; +#endif static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node) { struct mem_cgroup_per_node *pn; @@ -6959,19 +6962,6 @@ struct cgroup_subsys mem_cgroup_subsys = { .use_id = 1, }; -/* - * The rest of init is performed during ->css_alloc() for root css which - * happens before initcalls. hotcpu_notifier() can't be done together as - * it would introduce circular locking by adding cgroup_lock -> cpu hotplug - * dependency. Do it from a subsys_initcall(). - */ -static int __init mem_cgroup_init(void) -{ - hotcpu_notifier(memcg_cpu_hotplug_callback, 0); - return 0; -} -subsys_initcall(mem_cgroup_init); - #ifdef CONFIG_MEMCG_SWAP static int __init enable_swap_account(char *s) { @@ -6984,4 +6974,28 @@ static int __init enable_swap_account(char *s) } __setup("swapaccount=", enable_swap_account); +static void __init memsw_file_init(void) +{ + if (really_do_swap_account) + WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, + memsw_cgroup_files)); +} +#else +static void __init memsw_file_init(void) +{ +} #endif + +/* + * The rest of init is performed during ->css_alloc() for root css which + * happens before initcalls. hotcpu_notifier() can't be done together as + * it would introduce circular locking by adding cgroup_lock -> cpu hotplug + * dependency. Do it from a subsys_initcall(). + */ +static int __init mem_cgroup_init(void) +{ + hotcpu_notifier(memcg_cpu_hotplug_callback, 0); + memsw_file_init(); + return 0; +} +subsys_initcall(mem_cgroup_init); -- 1.7.10.4 -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753233Ab3AULMQ (ORCPT ); Mon, 21 Jan 2013 06:12:16 -0500 Received: from cantor2.suse.de ([195.135.220.15]:54540 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753097Ab3AULMK (ORCPT ); Mon, 21 Jan 2013 06:12:10 -0500 Date: Mon, 21 Jan 2013 12:12:06 +0100 From: Michal Hocko To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121111206.GG7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130121105624.GF7798@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And we can put another clean up patch on top of the fix: --- >>From a81d36002e7dbd976b617d5eadf32265f36038a4 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Mon, 21 Jan 2013 12:05:29 +0100 Subject: [PATCH] memcg: clean up swap accounting initialization code Memcg swap accounting is currently enabled by enable_swap_cgroup when the root cgroup is created. mem_cgroup_init acts as a memcg subsystem initializer which sounds like a much better place for enable_swap_cgroup as well. We already register memsw files from there so it makes a lot of sense to merge those two into a single enable_swap_cgroup function. This patch doesn't introduce any semantical changes. Signed-off-by: Michal Hocko --- mm/memcontrol.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a2800db..878d62c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6221,18 +6221,6 @@ struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) } EXPORT_SYMBOL(parent_mem_cgroup); -#ifdef CONFIG_MEMCG_SWAP -static void __init enable_swap_cgroup(void) -{ - if (!mem_cgroup_disabled() && really_do_swap_account) - do_swap_account = 1; -} -#else -static void __init enable_swap_cgroup(void) -{ -} -#endif - static int mem_cgroup_soft_limit_tree_init(void) { struct mem_cgroup_tree_per_node *rtpn; @@ -6286,7 +6274,6 @@ mem_cgroup_css_alloc(struct cgroup *cont) /* root ? */ if (cont->parent == NULL) { int cpu; - enable_swap_cgroup(); parent = NULL; if (mem_cgroup_soft_limit_tree_init()) goto free_out; @@ -6976,12 +6963,19 @@ __setup("swapaccount=", enable_swap_account); static void __init memsw_file_init(void) { - if (really_do_swap_account) - WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, - memsw_cgroup_files)); + WARN_ON(cgroup_add_cftypes(&mem_cgroup_subsys, memsw_cgroup_files)); +} + +static void __init enable_swap_cgroup(void) +{ + if (!mem_cgroup_disabled() && really_do_swap_account) { + do_swap_account = 1; + memsw_file_init(); + } } + #else -static void __init memsw_file_init(void) +static void __init enable_swap_cgroup(void) { } #endif @@ -6995,7 +6989,7 @@ static void __init memsw_file_init(void) static int __init mem_cgroup_init(void) { hotcpu_notifier(memcg_cpu_hotplug_callback, 0); - memsw_file_init(); + enable_swap_cgroup(); return 0; } subsys_initcall(mem_cgroup_init); -- 1.7.10.4 -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753331Ab3AUNqv (ORCPT ); Mon, 21 Jan 2013 08:46:51 -0500 Received: from cantor2.suse.de ([195.135.220.15]:56263 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993Ab3AUNqu (ORCPT ); Mon, 21 Jan 2013 08:46:50 -0500 Date: Mon, 21 Jan 2013 14:46:46 +0100 From: Michal Hocko To: Zhouping Liu Cc: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported Message-ID: <20130121134646.GL7798@dhcp22.suse.cz> References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> <50FD4245.3070402@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50FD4245.3070402@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 21-01-13 21:27:33, Zhouping Liu wrote: > On 01/21/2013 06:56 PM, Michal Hocko wrote: [...] > > From 5f8141bf7d27014cfbc7b450f13f6146b5ab099d Mon Sep 17 00:00:00 2001 > >From: Michal Hocko > >Date: Mon, 21 Jan 2013 11:33:26 +0100 > >Subject: [PATCH] memcg: Do not create memsw files if swap accounting is > > disabled > > > >Zhouping Liu has reported that memsw files are exported even though > >swap accounting is runtime disabled if CONFIG_MEMCG_SWAP is enabled. > >This behavior has been introduced by af36f906 (memcg: always create > >memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP) and it causes any > >attempt to open the file to return EOPNOTSUPP. Although EOPNOTSUPP > >should say be clear that memsw operations are not supported in the given > >configuration it is fair to say that this behavior could be quite > >confusing. > > > >Let's tear memsw files out of default cgroup files and add > >them only if the swap accounting is really enabled (either by > >CONFIG_MEMCG_SWAP_ENABLED or swapaccount=1 boot parameter). We can > >hook into mem_cgroup_init which is called when the memcg subsystem is > >initialized and which happens after boot command line is processed. > > Thanks for your quick patch, your patch looks good for me. > > I tested it with or without CONFIG_MEMCG_SWAP_ENABLED=y, > and also tested it with swapaccount=1 kernel parameters, all are okay. > > Tested-by: Zhouping Liu Thanks for testing! -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755948Ab3AUP6R (ORCPT ); Mon, 21 Jan 2013 10:58:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63281 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753201Ab3AUP6Q (ORCPT ); Mon, 21 Jan 2013 10:58:16 -0500 Message-ID: <50FD4245.3070402@redhat.com> Date: Mon, 21 Jan 2013 21:27:33 +0800 From: Zhouping Liu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Michal Hocko CC: Kamezawa Hiroyuki , David Rientjes , linux-mm@kvack.org, Li Zefan , CAI Qian , LKML , Andrew Morton , Tejun Heo Subject: Re: memcg: cat: memory.memsw.* : Operation not supported References: <4FEE7665.6020409@jp.fujitsu.com> <389106003.8637801.1358757547754.JavaMail.root@redhat.com> <20130121105624.GF7798@dhcp22.suse.cz> In-Reply-To: <20130121105624.GF7798@dhcp22.suse.cz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/21/2013 06:56 PM, Michal Hocko wrote: > On Mon 21-01-13 03:39:07, Zhouping Liu wrote: >> >> ----- Original Message ----- >>> From: "Kamezawa Hiroyuki" >>> To: "Tejun Heo" >>> Cc: "David Rientjes" , "Michal Hocko" , "Zhouping Liu" , >>> linux-mm@kvack.org, "Li Zefan" , "CAI Qian" , "LKML" >>> , "Andrew Morton" >>> Sent: Saturday, June 30, 2012 11:45:41 AM >>> Subject: Re: memcg: cat: memory.memsw.* : Operation not supported >>> >>> (2012/06/29 3:31), Tejun Heo wrote: >>>> Hello, KAME. >>>> >>>> On Thu, Jun 28, 2012 at 01:04:16PM +0900, Kamezawa Hiroyuki wrote: >>>>>> I still wish it's folded into CONFIG_MEMCG and conditionalized >>>>>> just on >>>>>> CONFIG_SWAP tho. >>>>>> >>>>> In old days, memsw controller was not very stable. So, we devided >>>>> the config. >>>>> And, it makes size of memory for swap-device double (adds 2bytes >>>>> per swapent.) >>>>> That is the problem. >>>> I see. Do you think it's now reasonable to drop the separate >>>> config >>>> option? Having memcg enabled but swap unaccounted sounds >>>> half-broken >>>> to me. >>>> >>> Hmm. Maybe it's ok if we can keep boot option. I'll cook a patch in >>> the next week. >> Hello Kame and All, >> >> Sorry for so delay to open the thread. (please open the link https://lkml.org/lkml/2012/6/26/547 if you don't remember the topic) >> >> do you have any updates for the issue? >> >> I checked the latest version, if we don't open CONFIG_MEMCG_SWAP_ENABLED(commit c255a458055e changed >> CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED as CONFIG_MEMCG_SWAP_ENABLED), the issue still exist: >> >> [root@dhcp-8-128 ~] cat .config | grep -i memcg >> CONFIG_MEMCG=y >> CONFIG_MEMCG_SWAP=y >> # CONFIG_MEMCG_SWAP_ENABLED is not set >> CONFIG_MEMCG_KMEM=y >> [root@dhcp-8-128 ~] uname -r >> 3.8.0-rc4+ >> [root@dhcp-8-128 ~] cat memory.memsw.* >> cat: memory.memsw.failcnt: Operation not supported >> cat: memory.memsw.limit_in_bytes: Operation not supported >> cat: memory.memsw.max_usage_in_bytes: Operation not supported >> cat: memory.memsw.usage_in_bytes: Operation not supported > Ohh, this one got lost. I thought Kame was working on that. > Anyway the patch bellow should work: > --- > From 5f8141bf7d27014cfbc7b450f13f6146b5ab099d Mon Sep 17 00:00:00 2001 > From: Michal Hocko > Date: Mon, 21 Jan 2013 11:33:26 +0100 > Subject: [PATCH] memcg: Do not create memsw files if swap accounting is > disabled > > Zhouping Liu has reported that memsw files are exported even though > swap accounting is runtime disabled if CONFIG_MEMCG_SWAP is enabled. > This behavior has been introduced by af36f906 (memcg: always create > memsw files if CONFIG_CGROUP_MEM_RES_CTLR_SWAP) and it causes any > attempt to open the file to return EOPNOTSUPP. Although EOPNOTSUPP > should say be clear that memsw operations are not supported in the given > configuration it is fair to say that this behavior could be quite > confusing. > > Let's tear memsw files out of default cgroup files and add > them only if the swap accounting is really enabled (either by > CONFIG_MEMCG_SWAP_ENABLED or swapaccount=1 boot parameter). We can > hook into mem_cgroup_init which is called when the memcg subsystem is > initialized and which happens after boot command line is processed. Thanks for your quick patch, your patch looks good for me. I tested it with or without CONFIG_MEMCG_SWAP_ENABLED=y, and also tested it with swapaccount=1 kernel parameters, all are okay. Tested-by: Zhouping Liu Thanks, Zhouping