memcg: clean up networking headers file inclusion
PATCH v2 1/1 memcg: clean up networking headers file inclusion
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped inside CONFIG_MEMCG_KMEM without CONFIG_INET is reusable for generic CONFIG_MEMCG_KMEM, right?
---
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?
Almost right.
Review
Quoted 9 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM) static bool mem_cgroup_is_root(struct mem_cgroup *memcg);
This one is. ^^^^
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 19 lines · Glauber Costa
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?Almost right.
Quoted 8 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)
Quoted 3 lines
Quoted 1 line
static bool
mem_cgroup_is_root(struct mem_cgroup *memcg);This one is. ^^^^
But this is just a forward declaration. And btw. it makes my compiler complain about:mm/memcontrol.c:421: warning: a??mem_cgroup_is_roota?? declared inline after being called mm/memcontrol.c:421: warning: previous declaration of a??mem_cgroup_is_roota?? was here
But I didn't care much yet. It is probaly that my compiler is too old to be clever about this.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 24 lines · Michal Hocko
Quoted 19 lines · Glauber Costa
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?Almost right.
Quoted 8 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)Quoted 3 lines
Quoted 1 line
static bool
mem_cgroup_is_root(struct mem_cgroup *memcg);This one is. ^^^^
Quoted 8 lines
But this is just a forward declaration. And btw. it makes my compiler complain about:
mm/memcontrol.c:421: warning: ‘mem_cgroup_is_root’ declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of ‘mem_cgroup_is_root’ was hereBut I didn't care much yet. It is probaly that my compiler is too old to be clever about this.
Weird, this code is in tree for a long time.
So, *right now* this code is used only for inet code, so I won't oppose your patch on this basis. I'll reuse it for kmem, but I am happy to just rebase it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 30 lines · Glauber Costa
Quoted 29 lines · Michal Hocko
Quoted 19 lines · Glauber Costa
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?Almost right.
Quoted 8 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)Quoted 3 lines
Quoted 1 line
static bool
mem_cgroup_is_root(struct mem_cgroup *memcg);This one is. ^^^^
But this is just a forward declaration. And btw. it makes my compiler complain about:
mm/memcontrol.c:421: warning: a??mem_cgroup_is_roota?? declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of a??mem_cgroup_is_roota?? was here
Quoted 4 lines
Quoted 3 lines
But I didn't care much yet. It is probaly that my compiler is too old to be clever about this.
Weird, this code is in tree for a long time.
Yes I think it is just compiler issue. Anyway the trivial patch bellow does the trick.
---
PATCH v3 1/1 memcg: clean up networking headers file inclusion
In reply to Glauber CostaOn Fri 14-09-12 15:35:50, Glauber Costa wrote:
[...]
Quoted 3 lines
So, *right now* this code is used only for inet code, so I won't oppose your patch on this basis. I'll reuse it for kmem, but I am happy to just rebase it.
Hmm, I guess I was too strict after all. memcg_init_kmem doesn't need CONFIG_INET gueard as both mem_cgroup_sockets_{init,destroy} are defined empty for !CONFIG_INET. All other functions guarded in INET&&KMEM combo seem to be networking specific.
Updated patch bellow:
---
Quoted 31 lines · Michal Hocko
Quoted 30 lines · Glauber Costa
Quoted 29 lines · Michal Hocko
Quoted 19 lines · Glauber Costa
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?Almost right.
Quoted 8 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)Quoted 3 lines
Quoted 1 line
static bool
mem_cgroup_is_root(struct mem_cgroup *memcg);This one is. ^^^^
But this is just a forward declaration. And btw. it makes my compiler complain about:
mm/memcontrol.c:421: warning: ‘mem_cgroup_is_root’ declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of ‘mem_cgroup_is_root’ was here
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
But I didn't care much yet. It is probaly that my compiler is too old to be clever about this.
Weird, this code is in tree for a long time.
Yes I think it is just compiler issue. Anyway the trivial patch bellow does the trick.
That seems to be alright, and it works for me as well.
Quoted 46 lines
---
From28a803e6e07c5b7ae6b88d7b26801666781aa899Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Fri, 14 Sep 2012 13:56:32 +0200
Subject: [PATCH] memcg: movemem_cgroup_is_rootupwards
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitkmem code uses this function and it is better to not use forward declarations for static inline functions as some (older) compilers don't like it:
gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux)
mm/memcontrol.c:421: warning: ‘mem_cgroup_is_root’ declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of ‘mem_cgroup_is_root’ was hereSigned-off-by Michal Hocko <[email protected]>--- mm/memcontrol.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)mm/memcontrol.c +5
-1@@ -415,10 +415,14 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s) return container_of(s, struct mem_cgroup, css); } +static inline bool mem_cgroup_is_root (struct mem_cgroup *memcg) +{ +return (memcg == root_mem_cgroup); +} +/* Writing them here to avoid exposing memcg's inner layout */ #if defined(CONFIG_INET ) && defined(CONFIG_MEMCG_KMEM ) -static bool mem_cgroup_is_root (struct mem_cgroup *memcg);void sock_update_memcg (struct sock *sk) {if (mem_cgroup_sockets_enabled) {@@ -1014,11 +1018,6 @@ void mem_cgroup_iter_break(struct mem_cgroup *root, iter !=NULL ; \
mm/memcontrol.c void mem_cgroup_iter_break(struct mem_cgroup *root, · line 1023
Quoted 10 lines
mm/memcontrol.c +0
-5iter = mem_cgroup_iter(NULL, iter, NULL)) -static inline bool mem_cgroup_is_root (struct mem_cgroup *memcg) -{ -return (memcg == root_mem_cgroup); -} -void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx) {struct mem_cgroup *memcg;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 35 lines · Glauber Costa
Quoted 34 lines · Michal Hocko
Quoted 33 lines · Glauber Costa
Quoted 32 lines · Michal Hocko
Quoted 19 lines · Glauber Costa
Quoted 6 lines · Michal Hocko
Hi,
so I did some more changes to ifdefery of sock kmem part. The patch is below.
Glauber please have a look at it. I do not think any of the functionality wrapped insideCONFIG_MEMCG_KMEMwithoutCONFIG_INETis reusable for genericCONFIG_MEMCG_KMEM, right?Almost right.
Quoted 8 lines
}
/* Writing them here to avoid exposing memcg's inner layout */
(quoted diff) +1
-3-#ifdef CONFIG_MEMCG_KMEM -#include <net/sock.h> -#include <net/ip.h> +#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)Quoted 3 lines
Quoted 1 line
static bool
mem_cgroup_is_root(struct mem_cgroup *memcg);This one is. ^^^^
But this is just a forward declaration. And btw. it makes my compiler complain about:
mm/memcontrol.c:421: warning: a??mem_cgroup_is_roota?? declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of a??mem_cgroup_is_roota?? was hereBut I didn't care much yet. It is probaly that my compiler is too old to be clever about this.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Weird, this code is in tree for a long time.
Yes I think it is just compiler issue. Anyway the trivial patch bellow does the trick.
That seems to be alright, and it works for me as well.
OK, I will post it on top of the last version.
Quoted 59 lines
Quoted 58 lines
---
From28a803e6e07c5b7ae6b88d7b26801666781aa899Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Fri, 14 Sep 2012 13:56:32 +0200
Subject: [PATCH] memcg: movemem_cgroup_is_rootupwards
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitkmem code uses this function and it is better to not use forward declarations for static inline functions as some (older) compilers don't like it:
gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux)
mm/memcontrol.c:421: warning: a??mem_cgroup_is_roota?? declared inline after being calledmm/memcontrol.c:421: warning: previous declaration of a??mem_cgroup_is_roota?? was hereSigned-off-by Michal Hocko <[email protected]>--- mm/memcontrol.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)mm/memcontrol.c +5
-6@@ -415,10 +415,14 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s) return container_of(s, struct mem_cgroup, css); } +static inline bool mem_cgroup_is_root (struct mem_cgroup *memcg) +{ +return (memcg == root_mem_cgroup); +} +/* Writing them here to avoid exposing memcg's inner layout */ #if defined(CONFIG_INET ) && defined(CONFIG_MEMCG_KMEM ) -static bool mem_cgroup_is_root (struct mem_cgroup *memcg);void sock_update_memcg (struct sock *sk) {if (mem_cgroup_sockets_enabled) {@@ -1014,11 +1018,6 @@ void mem_cgroup_iter_break(struct mem_cgroup *root, iter !=NULL ; \ iter = mem_cgroup_iter(NULL, iter, NULL)) -static inline bool mem_cgroup_is_root (struct mem_cgroup *memcg) -{ -return (memcg == root_mem_cgroup); -} -void mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx) {struct mem_cgroup *memcg;
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 36 lines · Michal Hocko
On Fri 14-09-12 15:35:50, Glauber Costa wrote:
[...]Quoted 3 lines
So, *right now* this code is used only for inet code, so I won't oppose your patch on this basis. I'll reuse it for kmem, but I am happy to just rebase it.
Hmm, I guess I was too strict after all.
memcg_init_kmemdoesn't needCONFIG_INETgueard as both mem_cgroup_sockets_{init,destroy} are defined empty for !CONFIG_INET. All other functions guarded in INET&&KMEM combo seem to be networking specific.
Updated patch bellow:
---
From4dca5e135b4dcc08464bbd70761d094f99ed83b1Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Tue, 11 Sep 2012 10:38:42 +0200
Subject: [PATCH] memcg: clean up networking headers file inclusionMemory controller doesn't need anything from the networking stack unless
CONFIG_MEMCG_KMEMis selected.
Now we are includingnet/sock.handnet/tcp_memcontrol.hunconditionally which is not necessary. Moreover structmem_cgroupcontainstcp_memeven ifCONFIG_MEMCG_KMEMandCONFIG_INETare not selected which is not necessary.
While we are at it, let's clean up KMEM sock code ifdefs to require bothCONFIG_KMEMandCONFIG_INETas it doesn't make much sense to compile this code if there is no possible user for it.Tested with
-CONFIG_INET&&CONFIG_MEMCG_KMEM
- !CONFIG_INET &&CONFIG_MEMCG_KMEM
-CONFIG_INET&& !CONFIG_MEMCG_KMEM
- !CONFIG_INET && !CONFIG_MEMCG_KMEMChanges since V2:
-memcg_init_kmemandkmem_cgroup_destroydon't needCONFIG_INET
Quoted 6 lines
Changes since V1:
- depend on bothCONFIG_INETandCONFIG_MEMCG_KMEMfor bothmem_cgroup->tcp_memand the sock specific codeSigned-off-by Sachin Kamat <[email protected]>Signed-off-by Michal Hocko <[email protected]>
Seems safe now. Since the config matrix can get tricky, and we have no pressing time issues with this, I would advise to give it a day in Fengguang's magic system before merging it. Just put it in a temp branch in korg and let it do the job.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 memcg: clean up networking headers file inclusion
In reply to Michal HockoAnd here is another trivial patch on top of the previous patch. I am not sure whether we care about such old compilers but the change itself makes some sense on its own.
---
Quoted 41 lines · Glauber Costa
Quoted 40 lines · Michal Hocko
On Fri 14-09-12 15:35:50, Glauber Costa wrote:
[...]Quoted 3 lines
So, *right now* this code is used only for inet code, so I won't oppose your patch on this basis. I'll reuse it for kmem, but I am happy to just rebase it.
Hmm, I guess I was too strict after all.
memcg_init_kmemdoesn't needCONFIG_INETgueard as both mem_cgroup_sockets_{init,destroy} are defined empty for !CONFIG_INET. All other functions guarded in INET&&KMEM combo seem to be networking specific.
Updated patch bellow:
---
From4dca5e135b4dcc08464bbd70761d094f99ed83b1Mon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Tue, 11 Sep 2012 10:38:42 +0200
Subject: [PATCH] memcg: clean up networking headers file inclusionMemory controller doesn't need anything from the networking stack unless
CONFIG_MEMCG_KMEMis selected.
Now we are includingnet/sock.handnet/tcp_memcontrol.hunconditionally which is not necessary. Moreover structmem_cgroupcontainstcp_memeven ifCONFIG_MEMCG_KMEMandCONFIG_INETare not selected which is not necessary.
While we are at it, let's clean up KMEM sock code ifdefs to require bothCONFIG_KMEMandCONFIG_INETas it doesn't make much sense to compile this code if there is no possible user for it.Tested with
-CONFIG_INET&&CONFIG_MEMCG_KMEM
- !CONFIG_INET &&CONFIG_MEMCG_KMEM
-CONFIG_INET&& !CONFIG_MEMCG_KMEM
- !CONFIG_INET && !CONFIG_MEMCG_KMEMChanges since V2:
-memcg_init_kmemandkmem_cgroup_destroydon't needCONFIG_INETChanges since V1:
- depend on bothCONFIG_INETandCONFIG_MEMCG_KMEMfor bothmem_cgroup->tcp_memand the sock specific code
Quoted 7 lines
Quoted 2 lines
Signed-off-by Sachin Kamat <[email protected]>Signed-off-by Michal Hocko <[email protected]>Seems safe now. Since the config matrix can get tricky, and we have no pressing time issues with this, I would advise to give it a day in Fengguang's magic system before merging it. Just put it in a temp branch in korg and let it do the job.
OK done. It is cleanups/memcg-sock-include.
Fengguang, do you think we can (ab)use your build test coverity to testgit://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git cleanups/memcg-sock-include
Thanks a lot!
I will repost both patches later (and hopefully I will not forget about other people on the CC list list like now...)
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines
Quoted 4 lines
Seems safe now. Since the config matrix can get tricky, and we have no pressing time issues with this, I would advise to give it a day in Fengguang's magic system before merging it. Just put it in a temp branch in korg and let it do the job.
OK done. It is cleanups/memcg-sock-include.
Fengguang, do you think we can (ab)use your build test coverity to test
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.gitcleanups/memcg-sock-includeThanks a lot!
Feel free to take advantage of it to your heart's content! Actually one of my biggest joy of working (hard) is to see users being able to make utmost use of the resulted system or feature :)
The tests will auto start shortly after you push the branch.
Thanks,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Wu Fengguang
Quoted 7 lines
Quoted 4 lines
Seems safe now. Since the config matrix can get tricky, and we have no pressing time issues with this, I would advise to give it a day in Fengguang's magic system before merging it. Just put it in a temp branch in korg and let it do the job.
OK done. It is cleanups/memcg-sock-include.
Quoted 8 lines
Quoted 4 lines
Fengguang, do you think we can (ab)use your build test coverity to test
git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.gitcleanups/memcg-sock-includeThanks a lot!
Feel free to take advantage of it to your heart's content! Actually one of my biggest joy of working (hard) is to see users being able to make utmost use of the resulted system or feature :)
Thanks a lot and I really appraciate that!
Quoted 1 line
The tests will auto start shortly after you push the branch.
OK, the branch should be there so it probably need few minutes to sync.
Quoted 3 lines
Thanks,
Fengguang
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainermm/memcontrol.c line 58
Quoted 12 lines · On Fri, 14 Sep 2012 14:08:49 +0200 Michal Hocko <[email protected]> wrote:
mm/memcontrol.c +4
-0@@ -50,8 +50,12 @@#include <linux/cpu.h> #include <linux/oom.h> #include "internal.h" + +#if defined(CONFIG_MEMCG_KMEM ) && defined(CONFIG_INET )#include <net/sock.h> +#include <net/ip.h> #include <net/tcp_memcontrol.h> +#endif
That wasn't a cleanup!
Why not just unconditionally include them? That will impact compile time a teeny bit, but the code is cleaner.
And it's safer, too - conditionally including header files make it more likely that people will accidentally break the build by not testing all relevant CONFIG_foo combinations.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v4 1/1 memcg: cleanup kmem tcp ifdefs
Quoted 18 lines · Andrew Morton
mm/memcontrol.c line 58
Quoted 12 lines · On Fri, 14 Sep 2012 14:08:49 +0200 Michal Hocko <[email protected]> wrote:
mm/memcontrol.c +4
-0@@ -50,8 +50,12 @@#include <linux/cpu.h> #include <linux/oom.h> #include "internal.h" + +#if defined(CONFIG_MEMCG_KMEM ) && defined(CONFIG_INET )#include <net/sock.h> +#include <net/ip.h> #include <net/tcp_memcontrol.h> +#endif That wasn't a cleanup!
Quoted 6 lines
Why not just unconditionally include them? That will impact compile time a teeny bit, but the code is cleaner.
And it's safer, too - conditionally including header files make it more likely that people will accidentally break the build by not testing all relevant
CONFIG_foocombinations.
OK, fair point. Updated patch below:
---