summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 14:46:52 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-09 14:46:52 -0800
commit38e5781bbf8e82c1635ea845e0d07b2228a5ac7a (patch)
tree69ced9c509c864a67122c5e1337f14cd1d9e988d /mm
parent979ecef5b89a8003902299566d9cdc08de34a3ee (diff)
parenta8c1f65c79cbbb2f7da782d4c9d15639a9b94b27 (diff)
downloadlinux-3.10-38e5781bbf8e82c1635ea845e0d07b2228a5ac7a.tar.gz
linux-3.10-38e5781bbf8e82c1635ea845e0d07b2228a5ac7a.tar.bz2
linux-3.10-38e5781bbf8e82c1635ea845e0d07b2228a5ac7a.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: igmp: Avoid zero delay when receiving odd mixture of IGMP queries netdev: make net_device_ops const bcm63xx: make ethtool_ops const usbnet: make ethtool_ops const net: Fix build with INET disabled. net: introduce netif_addr_lock_nested() and call if when appropriate net: correct lock name in dev_[uc/mc]_sync documentations. net: sk_update_clone is only used in net/core/sock.c 8139cp: fix missing napi_gro_flush. pktgen: set correct max and min in pktgen_setup_inject() smsc911x: Unconditionally include linux/smscphy.h in smsc911x.h asix: fix infinite loop in rx_fixup() net: Default UDP and UNIX diag to 'n'. r6040: fix typo in use of MCR0 register bits net: fix sock_clone reference mismatch with tcp memcontrol
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 00d4fa27d3e..d87aa3510c5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -381,16 +381,25 @@ static void mem_cgroup_put(struct mem_cgroup *memcg);
static bool mem_cgroup_is_root(struct mem_cgroup *memcg);
void sock_update_memcg(struct sock *sk)
{
- /* A socket spends its whole life in the same cgroup */
- if (sk->sk_cgrp) {
- WARN_ON(1);
- return;
- }
if (static_branch(&memcg_socket_limit_enabled)) {
struct mem_cgroup *memcg;
BUG_ON(!sk->sk_prot->proto_cgroup);
+ /* Socket cloning can throw us here with sk_cgrp already
+ * filled. It won't however, necessarily happen from
+ * process context. So the test for root memcg given
+ * the current task's memcg won't help us in this case.
+ *
+ * Respecting the original socket's memcg is a better
+ * decision in this case.
+ */
+ if (sk->sk_cgrp) {
+ BUG_ON(mem_cgroup_is_root(sk->sk_cgrp->memcg));
+ mem_cgroup_get(sk->sk_cgrp->memcg);
+ return;
+ }
+
rcu_read_lock();
memcg = mem_cgroup_from_task(current);
if (!mem_cgroup_is_root(memcg)) {