Skip to content

Commit

Permalink
net: decrement memcg jump label when limit, not usage, is changed
Browse files Browse the repository at this point in the history
The logic of the current code is that whenever we destroy
a cgroup that had its limit set (set meaning different than
maximum), we should decrement the jump_label counter.
Otherwise we assume it was never incremented.

But what the code actually does is test for RES_USAGE
instead of RES_LIMIT. Usage being different than maximum
is likely to be true most of the time.

The effect of this is that the key must become negative,
and since the jump_label test says:

        !!atomic_read(&key->enabled);

we'll have jump_labels still on when no one else is
using this functionality.

Signed-off-by: Glauber Costa <glommer@parallels.com>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Glauber Costa authored and David S. Miller committed Jan 12, 2012
1 parent cf778b0 commit 1398eee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/ipv4/tcp_memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
tcp = tcp_from_cgproto(cg_proto);
percpu_counter_destroy(&tcp->tcp_sockets_allocated);

val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_USAGE);
val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_LIMIT);

if (val != RESOURCE_MAX)
jump_label_dec(&memcg_socket_limit_enabled);
Expand Down

0 comments on commit 1398eee

Please sign in to comment.