Skip to content

Commit 7f2cbdc

Browse files
ebiedermdavem330
authored andcommitted
tcp_memcontrol: Cleanup/fix cg_proto->memory_pressure handling.
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>
1 parent 86d9be2 commit 7f2cbdc

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

‎include/net/sock.h‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ enum cg_proto_flags {
10351035
};
10361036

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

11571156
for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
1158-
if (cg_proto->memory_pressure)
1159-
cg_proto->memory_pressure = 0;
1157+
cg_proto->memory_pressure = 0;
11601158
}
11611159

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

11731171
for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
1174-
cg_proto->enter_memory_pressure(sk);
1172+
cg_proto->memory_pressure = 1;
11751173
}
11761174

11771175
sk->sk_prot->enter_memory_pressure(sk);

‎net/ipv4/tcp_memcontrol.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
#include <linux/memcontrol.h>
77
#include <linux/module.h>
88

9-
static void memcg_tcp_enter_memory_pressure(struct sock *sk)
10-
{
11-
if (sk->sk_cgrp->memory_pressure)
12-
sk->sk_cgrp->memory_pressure = 1;
13-
}
14-
EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);
15-
169
int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
1710
{
1811
/*

0 commit comments

Comments
 (0)