Skip to content

Commit

Permalink
tcp_memcontrol: Cleanup/fix cg_proto->memory_pressure handling.
Browse files Browse the repository at this point in the history
kill memcg_tcp_enter_memory_pressure.  The only function of
memcg_tcp_enter_memory_pressure was to reduce deal with the
unnecessary abstraction that was tcp_memcontrol.  Now that struct
tcp_memcontrol is gone remove this unnecessary function, the
unnecessary function pointer, and modify sk_enter_memory_pressure to
set this field directly, just as sk_leave_memory_pressure cleas this
field directly.

This fixes a small bug I intruduced when killing struct tcp_memcontrol
that caused memcg_tcp_enter_memory_pressure to never be called and
thus failed to ever set cg_proto->memory_pressure.

Remove the cg_proto enter_memory_pressure function as it now serves
no useful purpose.

Don't test cg_proto->memory_presser in sk_leave_memory_pressure before
clearing it.  The test was originally there to ensure that the pointer
was non-NULL.  Now that cg_proto is not a pointer the pointer does not
matter.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Dec 6, 2013
1 parent 86d9be2 commit 7f2cbdc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
6 changes: 2 additions & 4 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,6 @@ enum cg_proto_flags {
};

struct cg_proto {
void (*enter_memory_pressure)(struct sock *sk);
struct res_counter memory_allocated; /* Current allocated memory. */
struct percpu_counter sockets_allocated; /* Current number of sockets. */
int memory_pressure;
Expand Down Expand Up @@ -1155,8 +1154,7 @@ static inline void sk_leave_memory_pressure(struct sock *sk)
struct proto *prot = sk->sk_prot;

for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
if (cg_proto->memory_pressure)
cg_proto->memory_pressure = 0;
cg_proto->memory_pressure = 0;
}

}
Expand All @@ -1171,7 +1169,7 @@ static inline void sk_enter_memory_pressure(struct sock *sk)
struct proto *prot = sk->sk_prot;

for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
cg_proto->enter_memory_pressure(sk);
cg_proto->memory_pressure = 1;
}

sk->sk_prot->enter_memory_pressure(sk);
Expand Down
7 changes: 0 additions & 7 deletions net/ipv4/tcp_memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
#include <linux/memcontrol.h>
#include <linux/module.h>

static void memcg_tcp_enter_memory_pressure(struct sock *sk)
{
if (sk->sk_cgrp->memory_pressure)
sk->sk_cgrp->memory_pressure = 1;
}
EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);

int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
/*
Expand Down

0 comments on commit 7f2cbdc

Please sign in to comment.