aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index bb972d254dff..4c69ac165e6b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -226,6 +226,7 @@ struct cg_proto;
226 * @sk_ack_backlog: current listen backlog 226 * @sk_ack_backlog: current listen backlog
227 * @sk_max_ack_backlog: listen backlog set in listen() 227 * @sk_max_ack_backlog: listen backlog set in listen()
228 * @sk_priority: %SO_PRIORITY setting 228 * @sk_priority: %SO_PRIORITY setting
229 * @sk_cgrp_prioidx: socket group's priority map index
229 * @sk_type: socket type (%SOCK_STREAM, etc) 230 * @sk_type: socket type (%SOCK_STREAM, etc)
230 * @sk_protocol: which protocol this socket belongs in this network family 231 * @sk_protocol: which protocol this socket belongs in this network family
231 * @sk_peer_pid: &struct pid for this socket's peer 232 * @sk_peer_pid: &struct pid for this socket's peer
@@ -921,7 +922,7 @@ inline void sk_refcnt_debug_release(const struct sock *sk)
921#define sk_refcnt_debug_release(sk) do { } while (0) 922#define sk_refcnt_debug_release(sk) do { } while (0)
922#endif /* SOCK_REFCNT_DEBUG */ 923#endif /* SOCK_REFCNT_DEBUG */
923 924
924#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM 925#if defined(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) && defined(CONFIG_NET)
925extern struct jump_label_key memcg_socket_limit_enabled; 926extern struct jump_label_key memcg_socket_limit_enabled;
926static inline struct cg_proto *parent_cg_proto(struct proto *proto, 927static inline struct cg_proto *parent_cg_proto(struct proto *proto,
927 struct cg_proto *cg_proto) 928 struct cg_proto *cg_proto)
@@ -1007,9 +1008,8 @@ static inline void memcg_memory_allocated_add(struct cg_proto *prot,
1007 struct res_counter *fail; 1008 struct res_counter *fail;
1008 int ret; 1009 int ret;
1009 1010
1010 ret = res_counter_charge(prot->memory_allocated, 1011 ret = res_counter_charge_nofail(prot->memory_allocated,
1011 amt << PAGE_SHIFT, &fail); 1012 amt << PAGE_SHIFT, &fail);
1012
1013 if (ret < 0) 1013 if (ret < 0)
1014 *parent_status = OVER_LIMIT; 1014 *parent_status = OVER_LIMIT;
1015} 1015}
@@ -1053,12 +1053,11 @@ sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status)
1053} 1053}
1054 1054
1055static inline void 1055static inline void
1056sk_memory_allocated_sub(struct sock *sk, int amt, int parent_status) 1056sk_memory_allocated_sub(struct sock *sk, int amt)
1057{ 1057{
1058 struct proto *prot = sk->sk_prot; 1058 struct proto *prot = sk->sk_prot;
1059 1059
1060 if (mem_cgroup_sockets_enabled && sk->sk_cgrp && 1060 if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
1061 parent_status != OVER_LIMIT) /* Otherwise was uncharged already */
1062 memcg_memory_allocated_sub(sk->sk_cgrp, amt); 1061 memcg_memory_allocated_sub(sk->sk_cgrp, amt);
1063 1062
1064 atomic_long_sub(amt, prot->memory_allocated); 1063 atomic_long_sub(amt, prot->memory_allocated);