From: Glauber Costa <hidden> Date: 2012-01-20 14:57:35
Hi Dave,
Please consider adding the following fixes to
your tree.
The first is a remaining build bug, that managed to survive
the bunch of randconfigs I tested with from my last fix (It
still breaks without CONFIG_NET, which is likely selected
by a bunch of other options).
The other two patches are a fix for a bug I verified in
my followup testings in the controller itself, that causes
a charge/uncharge mismatch under certain circumnstances.
Thanks
Glauber Costa (3):
net: fix socket memcg build with !CONFIG_NET
cgroup: make sure memcg margin is 0 when over limit
net: introduce res_counter_charge_nofail() for socket allocations
include/linux/res_counter.h | 11 ++++++++++-
include/net/sock.h | 12 +++++-------
kernel/res_counter.c | 25 +++++++++++++++++++++++++
mm/memcontrol.c | 4 ++--
net/core/sock.c | 4 ++--
5 files changed, 44 insertions(+), 12 deletions(-)
--
1.7.7.4
From: Glauber Costa <hidden> Date: 2012-01-20 14:57:48
There is still a build bug with the sock memcg code, that triggers
with !CONFIG_NET, that survived my series of randconfig builds.
Signed-off-by: Glauber Costa <redacted>
Reported-by: Randy Dunlap <redacted>
CC: Hiroyouki Kamezawa <redacted>
---
include/net/sock.h | 2 +-
mm/memcontrol.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
From: Glauber Costa <hidden> Date: 2012-01-20 15:03:20
For the memcg sock code, we'll need to register allocations
that are temporarily over limit. Let's make sure that margin
is 0 in this case.
I am keeping this as a separate patch, so that if any weirdness
interaction appears in the future, we can now exactly what caused
it.
Suggested by Johannes Weiner
Signed-off-by: Glauber Costa <redacted>
CC: KAMEZAWA Hiroyuki <redacted>
CC: Johannes Weiner <redacted>
CC: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
---
include/linux/res_counter.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
From: Glauber Costa <hidden> Date: 2012-01-20 15:03:22
There is a case in __sk_mem_schedule(), where an allocation
is beyond the maximum, but yet we are allowed to proceed.
It happens under the following condition:
sk->sk_wmem_queued + size >= sk->sk_sndbuf
The network code won't revert the allocation in this case,
meaning that at some point later it'll try to do it. Since
this is never communicated to the underlying res_counter
code, there is an inbalance in res_counter uncharge operation.
I see two ways of fixing this:
1) storing the information about those allocations somewhere
in memcg, and then deducting from that first, before
we start draining the res_counter,
2) providing a slightly different allocation function for
the res_counter, that matches the original behavior of
the network code more closely.
I decided to go for #2 here, believing it to be more elegant,
since #1 would require us to do basically that, but in a more
obscure way.
Signed-off-by: Glauber Costa <redacted>
Cc: KAMEZAWA Hiroyuki <redacted>
Cc: Johannes Weiner <redacted>
Cc: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
CC: Laurent Chavey <redacted>
---
include/linux/res_counter.h | 6 ++++++
include/net/sock.h | 10 ++++------
kernel/res_counter.c | 25 +++++++++++++++++++++++++
net/core/sock.c | 4 ++--
4 files changed, 37 insertions(+), 8 deletions(-)
On Fri, Jan 20, 2012 at 06:57:16PM +0400, Glauber Costa wrote:
There is a case in __sk_mem_schedule(), where an allocation
is beyond the maximum, but yet we are allowed to proceed.
It happens under the following condition:
sk->sk_wmem_queued + size >= sk->sk_sndbuf
The network code won't revert the allocation in this case,
meaning that at some point later it'll try to do it. Since
this is never communicated to the underlying res_counter
code, there is an inbalance in res_counter uncharge operation.
I see two ways of fixing this:
1) storing the information about those allocations somewhere
in memcg, and then deducting from that first, before
we start draining the res_counter,
2) providing a slightly different allocation function for
the res_counter, that matches the original behavior of
the network code more closely.
I decided to go for #2 here, believing it to be more elegant,
since #1 would require us to do basically that, but in a more
obscure way.
Signed-off-by: Glauber Costa <redacted>
Cc: KAMEZAWA Hiroyuki <redacted>
Cc: Johannes Weiner <redacted>
Cc: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
CC: Laurent Chavey <redacted>
On Fri, Jan 20, 2012 at 06:57:15PM +0400, Glauber Costa wrote:
For the memcg sock code, we'll need to register allocations
that are temporarily over limit. Let's make sure that margin
is 0 in this case.
I am keeping this as a separate patch, so that if any weirdness
interaction appears in the future, we can now exactly what caused
it.
Suggested by Johannes Weiner
Signed-off-by: Glauber Costa <redacted>
CC: KAMEZAWA Hiroyuki <redacted>
CC: Johannes Weiner <redacted>
CC: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
From: David Miller <davem@davemloft.net> Date: 2012-01-20 19:17:13
From: Glauber Costa <redacted>
Date: Fri, 20 Jan 2012 18:57:14 +0400
There is still a build bug with the sock memcg code, that triggers
with !CONFIG_NET, that survived my series of randconfig builds.
Signed-off-by: Glauber Costa <redacted>
Reported-by: Randy Dunlap <rdunlap-/UHa2rfvQTnk1uMJSBkQmQ@public.gmane.org>
CC: Hiroyouki Kamezawa <redacted>
Why are you undoing the static branch optimization? That was a one of
the things that made me agree to even putting this code in.
Find a way to fix this without removing the static branch.
From: Glauber Costa <hidden> Date: 2012-01-21 14:18:21
On 01/20/2012 11:14 PM, David Miller wrote:
From: Glauber Costa<redacted>
Date: Fri, 20 Jan 2012 18:57:14 +0400
quoted
There is still a build bug with the sock memcg code, that triggers
with !CONFIG_NET, that survived my series of randconfig builds.
Signed-off-by: Glauber Costa<redacted>
Reported-by: Randy Dunlap<rdunlap-/UHa2rfvQTnk1uMJSBkQmQ@public.gmane.org>
CC: Hiroyouki Kamezawa<redacted>
Why are you undoing the static branch optimization? That was a one of
the things that made me agree to even putting this code in.
Find a way to fix this without removing the static branch.
Dave,
I am not removing the static branch. This is just a macro, that expands
to the static branch when the options are in place, and to 0 if they are
not.
if (0) { } is certainly be removed to the compiler, so the code is out
anyway.
From: David Miller <davem@davemloft.net> Date: 2012-01-22 19:36:07
From: Glauber Costa <redacted>
Date: Sat, 21 Jan 2012 18:17:26 +0400
I am not removing the static branch. This is just a macro, that
expands to the static branch when the options are in place, and to 0
if they are not.
if (0) { } is certainly be removed to the compiler, so the code is out
anyway.
That's rather non-intuitive, oh well.
I'll apply this, but all of this stuff is an ifdef mess.
From: Johannes Weiner <hannes@cmpxchg.org> Date: 2012-01-24 08:13:12
On Fri, Jan 20, 2012 at 06:57:15PM +0400, Glauber Costa wrote:
For the memcg sock code, we'll need to register allocations
that are temporarily over limit. Let's make sure that margin
is 0 in this case.
I am keeping this as a separate patch, so that if any weirdness
interaction appears in the future, we can now exactly what caused
it.
Suggested by Johannes Weiner
Signed-off-by: Glauber Costa <redacted>
CC: KAMEZAWA Hiroyuki <redacted>
CC: Johannes Weiner <redacted>
CC: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
From: Johannes Weiner <hannes@cmpxchg.org> Date: 2012-01-24 08:15:58
On Fri, Jan 20, 2012 at 06:57:16PM +0400, Glauber Costa wrote:
There is a case in __sk_mem_schedule(), where an allocation
is beyond the maximum, but yet we are allowed to proceed.
It happens under the following condition:
sk->sk_wmem_queued + size >= sk->sk_sndbuf
The network code won't revert the allocation in this case,
meaning that at some point later it'll try to do it. Since
this is never communicated to the underlying res_counter
code, there is an inbalance in res_counter uncharge operation.
I see two ways of fixing this:
1) storing the information about those allocations somewhere
in memcg, and then deducting from that first, before
we start draining the res_counter,
2) providing a slightly different allocation function for
the res_counter, that matches the original behavior of
the network code more closely.
I decided to go for #2 here, believing it to be more elegant,
since #1 would require us to do basically that, but in a more
obscure way.
Signed-off-by: Glauber Costa <redacted>
Cc: KAMEZAWA Hiroyuki <redacted>
Cc: Johannes Weiner <redacted>
Cc: Michal Hocko <redacted>
CC: Tejun Heo <redacted>
CC: Li Zefan <redacted>
CC: Laurent Chavey <redacted>