diff for duplicates of <20151113054408.GA2104@cmpxchg.org> diff --git a/a/1.txt b/N1/1.txt index 2b6bdaf..55a1a6b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -67,332 +67,3 @@ index 8cc7613..f954e2a 100644 } --- -From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001 -From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org> -Date: Tue, 10 Nov 2015 17:14:41 -0500 -Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks - -There won't be a tcp control soft limit, so integrating the memcg code -into the global skmem limiting scheme complicates things -unnecessarily. Replace this with simple and clear charge and uncharge -calls--hidden behind a jump label--to account skb memory. - -Note that this is not purely aesthetic: as a result of shoehorning the -per-memcg code into the same memory accounting functions that handle -the global level, the old code would compare the per-memcg consumption -against the smaller of the per-memcg limit and the global limit. This -allowed the total consumption of multiple sockets to exceed the global -limit, as long as the individual sockets stayed within bounds. After -this change, the code will always compare the per-memcg consumption to -the per-memcg limit, and the global consumption to the global limit, -and thus close this loophole. - -Without a soft limit, the per-memcg memory pressure state in sockets -is generally questionable. However, we did it until now, so we -continue to enter it when the hard limit is hit, and packets are -dropped, to let other sockets in the cgroup know that they shouldn't -grow their transmit windows, either. However, keep it simple in the -new callback model and leave memory pressure lazily when the next -packet is accepted (as opposed to doing it synchroneously when packets -are processed). When packets are dropped, network performance will -already be in the toilet, so that should be a reasonable trade-off. - -As described above, consumption is now checked on the per-memcg level -and the global level separately. Likewise, memory pressure states are -maintained on both the per-memcg level and the global level, and a -socket is considered under pressure when either level asserts as much. - -Signed-off-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org> ---- - include/linux/memcontrol.h | 12 ++++----- - include/net/sock.h | 64 ++++++---------------------------------------- - include/net/tcp.h | 5 ++-- - mm/memcontrol.c | 32 +++++++++++++++++++++++ - net/core/sock.c | 26 +++++++++++-------- - net/ipv4/tcp_output.c | 7 +++-- - 6 files changed, 70 insertions(+), 76 deletions(-) - -diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h -index 96ca3d3..906dfff 100644 ---- a/include/linux/memcontrol.h -+++ b/include/linux/memcontrol.h -@@ -676,12 +676,6 @@ void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx) - } - #endif /* CONFIG_MEMCG */ - --enum { -- UNDER_LIMIT, -- SOFT_LIMIT, -- OVER_LIMIT, --}; -- - #ifdef CONFIG_CGROUP_WRITEBACK - - struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg); -@@ -711,6 +705,12 @@ static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb, - struct sock; - void sock_update_memcg(struct sock *sk); - void sock_release_memcg(struct sock *sk); -+bool mem_cgroup_charge_skmem(struct cg_proto *proto, unsigned int nr_pages); -+void mem_cgroup_uncharge_skmem(struct cg_proto *proto, unsigned int nr_pages); -+static inline bool mem_cgroup_under_socket_pressure(struct cg_proto *proto) -+{ -+ return proto->memory_pressure; -+} - #endif /* CONFIG_INET && CONFIG_MEMCG_KMEM */ - - #ifdef CONFIG_MEMCG_KMEM -diff --git a/include/net/sock.h b/include/net/sock.h -index 2eefc99..f954e2a 100644 ---- a/include/net/sock.h -+++ b/include/net/sock.h -@@ -1126,8 +1126,9 @@ static inline bool sk_under_memory_pressure(const struct sock *sk) - if (!sk->sk_prot->memory_pressure) - return false; - -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- return !!sk->sk_cgrp->memory_pressure; -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp && -+ mem_cgroup_under_socket_pressure(sk->sk_cgrp)) -+ return true; - - return !!*sk->sk_prot->memory_pressure; - } -@@ -1141,9 +1142,6 @@ static inline void sk_leave_memory_pressure(struct sock *sk) - - if (*memory_pressure) - *memory_pressure = 0; -- -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- sk->sk_cgrp->memory_pressure = 0; - } - - static inline void sk_enter_memory_pressure(struct sock *sk) -@@ -1151,76 +1149,30 @@ static inline void sk_enter_memory_pressure(struct sock *sk) - if (!sk->sk_prot->enter_memory_pressure) - return; - -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- sk->sk_cgrp->memory_pressure = 1; -- - sk->sk_prot->enter_memory_pressure(sk); - } - - static inline long sk_prot_mem_limits(const struct sock *sk, int index) - { -- long limit = sk->sk_prot->sysctl_mem[index]; -- -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- limit = min_t(long, limit, sk->sk_cgrp->memory_allocated.limit); -- -- return limit; --} -- --static inline void memcg_memory_allocated_add(struct cg_proto *prot, -- unsigned long amt, -- int *parent_status) --{ -- struct page_counter *counter; -- -- if (page_counter_try_charge(&prot->memory_allocated, amt, &counter)) -- return; -- -- page_counter_charge(&prot->memory_allocated, amt); -- *parent_status = OVER_LIMIT; --} -- --static inline void memcg_memory_allocated_sub(struct cg_proto *prot, -- unsigned long amt) --{ -- page_counter_uncharge(&prot->memory_allocated, amt); -+ return sk->sk_prot->sysctl_mem[index]; - } - - static inline long - sk_memory_allocated(const struct sock *sk) - { -- struct proto *prot = sk->sk_prot; -- -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- return page_counter_read(&sk->sk_cgrp->memory_allocated); -- -- return atomic_long_read(prot->memory_allocated); -+ return atomic_long_read(sk->sk_prot->memory_allocated); - } - - static inline long --sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status) -+sk_memory_allocated_add(struct sock *sk, int amt) - { -- struct proto *prot = sk->sk_prot; -- -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { -- memcg_memory_allocated_add(sk->sk_cgrp, amt, parent_status); -- /* update the root cgroup regardless */ -- atomic_long_add_return(amt, prot->memory_allocated); -- return page_counter_read(&sk->sk_cgrp->memory_allocated); -- } -- -- return atomic_long_add_return(amt, prot->memory_allocated); -+ return atomic_long_add_return(amt, sk->sk_prot->memory_allocated); - } - - static inline void - sk_memory_allocated_sub(struct sock *sk, int amt) - { -- struct proto *prot = sk->sk_prot; -- -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- memcg_memory_allocated_sub(sk->sk_cgrp, amt); -- -- atomic_long_sub(amt, prot->memory_allocated); -+ atomic_long_sub(amt, sk->sk_prot->memory_allocated); - } - - static inline void sk_sockets_allocated_dec(struct sock *sk) -diff --git a/include/net/tcp.h b/include/net/tcp.h -index f80e74c..04517d6 100644 ---- a/include/net/tcp.h -+++ b/include/net/tcp.h -@@ -292,8 +292,9 @@ extern int tcp_memory_pressure; - /* optimized version of sk_under_memory_pressure() for TCP sockets */ - static inline bool tcp_under_memory_pressure(const struct sock *sk) - { -- if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -- return !!sk->sk_cgrp->memory_pressure; -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp && -+ mem_cgroup_under_socket_pressure(sk->sk_cgrp)) -+ return true; - - return tcp_memory_pressure; - } -diff --git a/mm/memcontrol.c b/mm/memcontrol.c -index 57f4539..3462a52 100644 ---- a/mm/memcontrol.c -+++ b/mm/memcontrol.c -@@ -338,6 +338,38 @@ struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg) - } - EXPORT_SYMBOL(tcp_proto_cgroup); - -+/** -+ * mem_cgroup_charge_skmem - charge socket memory -+ * @proto: proto to charge -+ * @nr_pages: number of pages to charge -+ * -+ * Charges @nr_pages to @proto. Returns %true if the charge fit within -+ * @proto's configured limit, %false if the charge had to be forced. -+ */ -+bool mem_cgroup_charge_skmem(struct cg_proto *proto, unsigned int nr_pages) -+{ -+ struct page_counter *counter; -+ -+ if (page_counter_try_charge(&proto->memory_allocated, -+ nr_pages, &counter)) { -+ proto->memory_pressure = 0; -+ return true; -+ } -+ page_counter_charge(&proto->memory_allocated, nr_pages); -+ proto->memory_pressure = 1; -+ return false; -+} -+ -+/** -+ * mem_cgroup_uncharge_skmem - uncharge socket memory -+ * @proto - proto to uncharge -+ * @nr_pages - number of pages to uncharge -+ */ -+void mem_cgroup_uncharge_skmem(struct cg_proto *proto, unsigned int nr_pages) -+{ -+ page_counter_uncharge(&proto->memory_allocated, nr_pages); -+} -+ - #endif - - #ifdef CONFIG_MEMCG_KMEM -diff --git a/net/core/sock.c b/net/core/sock.c -index 04e54bc..5b1b96f 100644 ---- a/net/core/sock.c -+++ b/net/core/sock.c -@@ -2066,27 +2066,27 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind) - struct proto *prot = sk->sk_prot; - int amt = sk_mem_pages(size); - long allocated; -- int parent_status = UNDER_LIMIT; - - sk->sk_forward_alloc += amt * SK_MEM_QUANTUM; - -- allocated = sk_memory_allocated_add(sk, amt, &parent_status); -+ allocated = sk_memory_allocated_add(sk, amt); -+ -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp && -+ !mem_cgroup_charge_skmem(sk->sk_cgrp, amt)) -+ goto suppress_allocation; - - /* Under limit. */ -- if (parent_status == UNDER_LIMIT && -- allocated <= sk_prot_mem_limits(sk, 0)) { -+ if (allocated <= sk_prot_mem_limits(sk, 0)) { - sk_leave_memory_pressure(sk); - return 1; - } - -- /* Under pressure. (we or our parents) */ -- if ((parent_status > SOFT_LIMIT) || -- allocated > sk_prot_mem_limits(sk, 1)) -+ /* Under pressure. */ -+ if (allocated > sk_prot_mem_limits(sk, 1)) - sk_enter_memory_pressure(sk); - -- /* Over hard limit (we or our parents) */ -- if ((parent_status == OVER_LIMIT) || -- (allocated > sk_prot_mem_limits(sk, 2))) -+ /* Over hard limit. */ -+ if (allocated > sk_prot_mem_limits(sk, 2)) - goto suppress_allocation; - - /* guarantee minimum buffer size under pressure */ -@@ -2135,6 +2135,9 @@ suppress_allocation: - - sk_memory_allocated_sub(sk, amt); - -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -+ mem_cgroup_uncharge_skmem(sk->sk_cgrp, amt); -+ - return 0; - } - EXPORT_SYMBOL(__sk_mem_schedule); -@@ -2150,6 +2153,9 @@ void __sk_mem_reclaim(struct sock *sk, int amount) - sk_memory_allocated_sub(sk, amount); - sk->sk_forward_alloc -= amount << SK_MEM_QUANTUM_SHIFT; - -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -+ mem_cgroup_uncharge_skmem(sk->sk_cgrp, amount); -+ - if (sk_under_memory_pressure(sk) && - (sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0))) - sk_leave_memory_pressure(sk); -diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c -index cb7ca56..7aa168a 100644 ---- a/net/ipv4/tcp_output.c -+++ b/net/ipv4/tcp_output.c -@@ -2813,13 +2813,16 @@ begin_fwd: - */ - void sk_forced_mem_schedule(struct sock *sk, int size) - { -- int amt, status; -+ int amt; - - if (size <= sk->sk_forward_alloc) - return; - amt = sk_mem_pages(size); - sk->sk_forward_alloc += amt * SK_MEM_QUANTUM; -- sk_memory_allocated_add(sk, amt, &status); -+ sk_memory_allocated_add(sk, amt); -+ -+ if (mem_cgroup_sockets_enabled && sk->sk_cgrp) -+ mem_cgroup_charge_skmem(sk->sk_cgrp, amt); - } - - /* Send a FIN. The caller locks the socket for us. --- -2.6.2 diff --git a/a/content_digest b/N1/content_digest index 44199fc..e044f28 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,21 +1,20 @@ "ref\01447371693-25143-1-git-send-email-hannes@cmpxchg.org\0" "ref\01447371693-25143-9-git-send-email-hannes@cmpxchg.org\0" "ref\01447390418.22599.34.camel@edumazet-glaptop2.roam.corp.google.com\0" - "ref\01447390418.22599.34.camel-XN9IlZ5yJG9HTL0Zs8A6p/gx64E7kk8eUsxypvmhUTTZJqsBc5GL+g@public.gmane.org\0" - "From\0Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\0" + "From\0Johannes Weiner <hannes@cmpxchg.org>\0" "Subject\0Re: [PATCH 08/14] net: tcp_memcontrol: sanitize tcp memory accounting callbacks\0" "Date\0Fri, 13 Nov 2015 00:44:08 -0500\0" - "To\0Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>\0" - "Cc\0David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>" - Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> - Vladimir Davydov <vdavydov-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> - Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> - Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org> - netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org - cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - " kernel-team-b10kYP2dOMg@public.gmane.org\0" + "To\0Eric Dumazet <eric.dumazet@gmail.com>\0" + "Cc\0David Miller <davem@davemloft.net>" + Andrew Morton <akpm@linux-foundation.org> + Vladimir Davydov <vdavydov@virtuozzo.com> + Tejun Heo <tj@kernel.org> + Michal Hocko <mhocko@suse.cz> + netdev@vger.kernel.org + linux-mm@kvack.org + cgroups@vger.kernel.org + linux-kernel@vger.kernel.org + " kernel-team@fb.com\0" "\00:1\0" "b\0" "On Thu, Nov 12, 2015 at 08:53:38PM -0800, Eric Dumazet wrote:\n" @@ -86,335 +85,6 @@ " \treturn !!*sk->sk_prot->memory_pressure;\n" " }\n" "\n" - "---\n" - "From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001\n" - "From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\n" - "Date: Tue, 10 Nov 2015 17:14:41 -0500\n" - "Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks\n" - "\n" - "There won't be a tcp control soft limit, so integrating the memcg code\n" - "into the global skmem limiting scheme complicates things\n" - "unnecessarily. Replace this with simple and clear charge and uncharge\n" - "calls--hidden behind a jump label--to account skb memory.\n" - "\n" - "Note that this is not purely aesthetic: as a result of shoehorning the\n" - "per-memcg code into the same memory accounting functions that handle\n" - "the global level, the old code would compare the per-memcg consumption\n" - "against the smaller of the per-memcg limit and the global limit. This\n" - "allowed the total consumption of multiple sockets to exceed the global\n" - "limit, as long as the individual sockets stayed within bounds. After\n" - "this change, the code will always compare the per-memcg consumption to\n" - "the per-memcg limit, and the global consumption to the global limit,\n" - "and thus close this loophole.\n" - "\n" - "Without a soft limit, the per-memcg memory pressure state in sockets\n" - "is generally questionable. However, we did it until now, so we\n" - "continue to enter it when the hard limit is hit, and packets are\n" - "dropped, to let other sockets in the cgroup know that they shouldn't\n" - "grow their transmit windows, either. However, keep it simple in the\n" - "new callback model and leave memory pressure lazily when the next\n" - "packet is accepted (as opposed to doing it synchroneously when packets\n" - "are processed). When packets are dropped, network performance will\n" - "already be in the toilet, so that should be a reasonable trade-off.\n" - "\n" - "As described above, consumption is now checked on the per-memcg level\n" - "and the global level separately. Likewise, memory pressure states are\n" - "maintained on both the per-memcg level and the global level, and a\n" - "socket is considered under pressure when either level asserts as much.\n" - "\n" - "Signed-off-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\n" - "---\n" - " include/linux/memcontrol.h | 12 ++++-----\n" - " include/net/sock.h | 64 ++++++----------------------------------------\n" - " include/net/tcp.h | 5 ++--\n" - " mm/memcontrol.c | 32 +++++++++++++++++++++++\n" - " net/core/sock.c | 26 +++++++++++--------\n" - " net/ipv4/tcp_output.c | 7 +++--\n" - " 6 files changed, 70 insertions(+), 76 deletions(-)\n" - "\n" - "diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h\n" - "index 96ca3d3..906dfff 100644\n" - "--- a/include/linux/memcontrol.h\n" - "+++ b/include/linux/memcontrol.h\n" - "@@ -676,12 +676,6 @@ void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx)\n" - " }\n" - " #endif /* CONFIG_MEMCG */\n" - " \n" - "-enum {\n" - "-\tUNDER_LIMIT,\n" - "-\tSOFT_LIMIT,\n" - "-\tOVER_LIMIT,\n" - "-};\n" - "-\n" - " #ifdef CONFIG_CGROUP_WRITEBACK\n" - " \n" - " struct list_head *mem_cgroup_cgwb_list(struct mem_cgroup *memcg);\n" - "@@ -711,6 +705,12 @@ static inline void mem_cgroup_wb_stats(struct bdi_writeback *wb,\n" - " struct sock;\n" - " void sock_update_memcg(struct sock *sk);\n" - " void sock_release_memcg(struct sock *sk);\n" - "+bool mem_cgroup_charge_skmem(struct cg_proto *proto, unsigned int nr_pages);\n" - "+void mem_cgroup_uncharge_skmem(struct cg_proto *proto, unsigned int nr_pages);\n" - "+static inline bool mem_cgroup_under_socket_pressure(struct cg_proto *proto)\n" - "+{\n" - "+\treturn proto->memory_pressure;\n" - "+}\n" - " #endif /* CONFIG_INET && CONFIG_MEMCG_KMEM */\n" - " \n" - " #ifdef CONFIG_MEMCG_KMEM\n" - "diff --git a/include/net/sock.h b/include/net/sock.h\n" - "index 2eefc99..f954e2a 100644\n" - "--- a/include/net/sock.h\n" - "+++ b/include/net/sock.h\n" - "@@ -1126,8 +1126,9 @@ static inline bool sk_under_memory_pressure(const struct sock *sk)\n" - " \tif (!sk->sk_prot->memory_pressure)\n" - " \t\treturn false;\n" - " \n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\treturn !!sk->sk_cgrp->memory_pressure;\n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp &&\n" - "+\t mem_cgroup_under_socket_pressure(sk->sk_cgrp))\n" - "+\t\treturn true;\n" - " \n" - " \treturn !!*sk->sk_prot->memory_pressure;\n" - " }\n" - "@@ -1141,9 +1142,6 @@ static inline void sk_leave_memory_pressure(struct sock *sk)\n" - " \n" - " \tif (*memory_pressure)\n" - " \t\t*memory_pressure = 0;\n" - "-\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\tsk->sk_cgrp->memory_pressure = 0;\n" - " }\n" - " \n" - " static inline void sk_enter_memory_pressure(struct sock *sk)\n" - "@@ -1151,76 +1149,30 @@ static inline void sk_enter_memory_pressure(struct sock *sk)\n" - " \tif (!sk->sk_prot->enter_memory_pressure)\n" - " \t\treturn;\n" - " \n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\tsk->sk_cgrp->memory_pressure = 1;\n" - "-\n" - " \tsk->sk_prot->enter_memory_pressure(sk);\n" - " }\n" - " \n" - " static inline long sk_prot_mem_limits(const struct sock *sk, int index)\n" - " {\n" - "-\tlong limit = sk->sk_prot->sysctl_mem[index];\n" - "-\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\tlimit = min_t(long, limit, sk->sk_cgrp->memory_allocated.limit);\n" - "-\n" - "-\treturn limit;\n" - "-}\n" - "-\n" - "-static inline void memcg_memory_allocated_add(struct cg_proto *prot,\n" - "-\t\t\t\t\t unsigned long amt,\n" - "-\t\t\t\t\t int *parent_status)\n" - "-{\n" - "-\tstruct page_counter *counter;\n" - "-\n" - "-\tif (page_counter_try_charge(&prot->memory_allocated, amt, &counter))\n" - "-\t\treturn;\n" - "-\n" - "-\tpage_counter_charge(&prot->memory_allocated, amt);\n" - "-\t*parent_status = OVER_LIMIT;\n" - "-}\n" - "-\n" - "-static inline void memcg_memory_allocated_sub(struct cg_proto *prot,\n" - "-\t\t\t\t\t unsigned long amt)\n" - "-{\n" - "-\tpage_counter_uncharge(&prot->memory_allocated, amt);\n" - "+\treturn sk->sk_prot->sysctl_mem[index];\n" - " }\n" - " \n" - " static inline long\n" - " sk_memory_allocated(const struct sock *sk)\n" - " {\n" - "-\tstruct proto *prot = sk->sk_prot;\n" - "-\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\treturn page_counter_read(&sk->sk_cgrp->memory_allocated);\n" - "-\n" - "-\treturn atomic_long_read(prot->memory_allocated);\n" - "+\treturn atomic_long_read(sk->sk_prot->memory_allocated);\n" - " }\n" - " \n" - " static inline long\n" - "-sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status)\n" - "+sk_memory_allocated_add(struct sock *sk, int amt)\n" - " {\n" - "-\tstruct proto *prot = sk->sk_prot;\n" - "-\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp) {\n" - "-\t\tmemcg_memory_allocated_add(sk->sk_cgrp, amt, parent_status);\n" - "-\t\t/* update the root cgroup regardless */\n" - "-\t\tatomic_long_add_return(amt, prot->memory_allocated);\n" - "-\t\treturn page_counter_read(&sk->sk_cgrp->memory_allocated);\n" - "-\t}\n" - "-\n" - "-\treturn atomic_long_add_return(amt, prot->memory_allocated);\n" - "+\treturn atomic_long_add_return(amt, sk->sk_prot->memory_allocated);\n" - " }\n" - " \n" - " static inline void\n" - " sk_memory_allocated_sub(struct sock *sk, int amt)\n" - " {\n" - "-\tstruct proto *prot = sk->sk_prot;\n" - "-\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\tmemcg_memory_allocated_sub(sk->sk_cgrp, amt);\n" - "-\n" - "-\tatomic_long_sub(amt, prot->memory_allocated);\n" - "+\tatomic_long_sub(amt, sk->sk_prot->memory_allocated);\n" - " }\n" - " \n" - " static inline void sk_sockets_allocated_dec(struct sock *sk)\n" - "diff --git a/include/net/tcp.h b/include/net/tcp.h\n" - "index f80e74c..04517d6 100644\n" - "--- a/include/net/tcp.h\n" - "+++ b/include/net/tcp.h\n" - "@@ -292,8 +292,9 @@ extern int tcp_memory_pressure;\n" - " /* optimized version of sk_under_memory_pressure() for TCP sockets */\n" - " static inline bool tcp_under_memory_pressure(const struct sock *sk)\n" - " {\n" - "-\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "-\t\treturn !!sk->sk_cgrp->memory_pressure;\n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp &&\n" - "+\t mem_cgroup_under_socket_pressure(sk->sk_cgrp))\n" - "+\t\treturn true;\n" - " \n" - " \treturn tcp_memory_pressure;\n" - " }\n" - "diff --git a/mm/memcontrol.c b/mm/memcontrol.c\n" - "index 57f4539..3462a52 100644\n" - "--- a/mm/memcontrol.c\n" - "+++ b/mm/memcontrol.c\n" - "@@ -338,6 +338,38 @@ struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg)\n" - " }\n" - " EXPORT_SYMBOL(tcp_proto_cgroup);\n" - " \n" - "+/**\n" - "+ * mem_cgroup_charge_skmem - charge socket memory\n" - "+ * @proto: proto to charge\n" - "+ * @nr_pages: number of pages to charge\n" - "+ *\n" - "+ * Charges @nr_pages to @proto. Returns %true if the charge fit within\n" - "+ * @proto's configured limit, %false if the charge had to be forced.\n" - "+ */\n" - "+bool mem_cgroup_charge_skmem(struct cg_proto *proto, unsigned int nr_pages)\n" - "+{\n" - "+\tstruct page_counter *counter;\n" - "+\n" - "+\tif (page_counter_try_charge(&proto->memory_allocated,\n" - "+\t\t\t\t nr_pages, &counter)) {\n" - "+\t\tproto->memory_pressure = 0;\n" - "+\t\treturn true;\n" - "+\t}\n" - "+\tpage_counter_charge(&proto->memory_allocated, nr_pages);\n" - "+\tproto->memory_pressure = 1;\n" - "+\treturn false;\n" - "+}\n" - "+\n" - "+/**\n" - "+ * mem_cgroup_uncharge_skmem - uncharge socket memory\n" - "+ * @proto - proto to uncharge\n" - "+ * @nr_pages - number of pages to uncharge\n" - "+ */\n" - "+void mem_cgroup_uncharge_skmem(struct cg_proto *proto, unsigned int nr_pages)\n" - "+{\n" - "+\tpage_counter_uncharge(&proto->memory_allocated, nr_pages);\n" - "+}\n" - "+\n" - " #endif\n" - " \n" - " #ifdef CONFIG_MEMCG_KMEM\n" - "diff --git a/net/core/sock.c b/net/core/sock.c\n" - "index 04e54bc..5b1b96f 100644\n" - "--- a/net/core/sock.c\n" - "+++ b/net/core/sock.c\n" - "@@ -2066,27 +2066,27 @@ int __sk_mem_schedule(struct sock *sk, int size, int kind)\n" - " \tstruct proto *prot = sk->sk_prot;\n" - " \tint amt = sk_mem_pages(size);\n" - " \tlong allocated;\n" - "-\tint parent_status = UNDER_LIMIT;\n" - " \n" - " \tsk->sk_forward_alloc += amt * SK_MEM_QUANTUM;\n" - " \n" - "-\tallocated = sk_memory_allocated_add(sk, amt, &parent_status);\n" - "+\tallocated = sk_memory_allocated_add(sk, amt);\n" - "+\n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp &&\n" - "+\t !mem_cgroup_charge_skmem(sk->sk_cgrp, amt))\n" - "+\t\tgoto suppress_allocation;\n" - " \n" - " \t/* Under limit. */\n" - "-\tif (parent_status == UNDER_LIMIT &&\n" - "-\t\t\tallocated <= sk_prot_mem_limits(sk, 0)) {\n" - "+\tif (allocated <= sk_prot_mem_limits(sk, 0)) {\n" - " \t\tsk_leave_memory_pressure(sk);\n" - " \t\treturn 1;\n" - " \t}\n" - " \n" - "-\t/* Under pressure. (we or our parents) */\n" - "-\tif ((parent_status > SOFT_LIMIT) ||\n" - "-\t\t\tallocated > sk_prot_mem_limits(sk, 1))\n" - "+\t/* Under pressure. */\n" - "+\tif (allocated > sk_prot_mem_limits(sk, 1))\n" - " \t\tsk_enter_memory_pressure(sk);\n" - " \n" - "-\t/* Over hard limit (we or our parents) */\n" - "-\tif ((parent_status == OVER_LIMIT) ||\n" - "-\t\t\t(allocated > sk_prot_mem_limits(sk, 2)))\n" - "+\t/* Over hard limit. */\n" - "+\tif (allocated > sk_prot_mem_limits(sk, 2))\n" - " \t\tgoto suppress_allocation;\n" - " \n" - " \t/* guarantee minimum buffer size under pressure */\n" - "@@ -2135,6 +2135,9 @@ suppress_allocation:\n" - " \n" - " \tsk_memory_allocated_sub(sk, amt);\n" - " \n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "+\t\tmem_cgroup_uncharge_skmem(sk->sk_cgrp, amt);\n" - "+\n" - " \treturn 0;\n" - " }\n" - " EXPORT_SYMBOL(__sk_mem_schedule);\n" - "@@ -2150,6 +2153,9 @@ void __sk_mem_reclaim(struct sock *sk, int amount)\n" - " \tsk_memory_allocated_sub(sk, amount);\n" - " \tsk->sk_forward_alloc -= amount << SK_MEM_QUANTUM_SHIFT;\n" - " \n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "+\t\tmem_cgroup_uncharge_skmem(sk->sk_cgrp, amount);\n" - "+\n" - " \tif (sk_under_memory_pressure(sk) &&\n" - " \t (sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0)))\n" - " \t\tsk_leave_memory_pressure(sk);\n" - "diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c\n" - "index cb7ca56..7aa168a 100644\n" - "--- a/net/ipv4/tcp_output.c\n" - "+++ b/net/ipv4/tcp_output.c\n" - "@@ -2813,13 +2813,16 @@ begin_fwd:\n" - " */\n" - " void sk_forced_mem_schedule(struct sock *sk, int size)\n" - " {\n" - "-\tint amt, status;\n" - "+\tint amt;\n" - " \n" - " \tif (size <= sk->sk_forward_alloc)\n" - " \t\treturn;\n" - " \tamt = sk_mem_pages(size);\n" - " \tsk->sk_forward_alloc += amt * SK_MEM_QUANTUM;\n" - "-\tsk_memory_allocated_add(sk, amt, &status);\n" - "+\tsk_memory_allocated_add(sk, amt);\n" - "+\n" - "+\tif (mem_cgroup_sockets_enabled && sk->sk_cgrp)\n" - "+\t\tmem_cgroup_charge_skmem(sk->sk_cgrp, amt);\n" - " }\n" - " \n" - " /* Send a FIN. The caller locks the socket for us.\n" - "-- \n" - 2.6.2 + --- -c0c60d6fcbb1ef9a3b66b256db6a2447c03e7e76987156f5e900807ce17de422 +bd5e70758ecfebfb80716457d692e7992712beb8b7b9bcafba2b1a92124e931e
diff --git a/a/1.txt b/N2/1.txt index 2b6bdaf..005778d 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -67,8 +67,8 @@ index 8cc7613..f954e2a 100644 } --- -From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001 -From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org> +>From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001 +From: Johannes Weiner <hannes@cmpxchg.org> Date: Tue, 10 Nov 2015 17:14:41 -0500 Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks @@ -102,7 +102,7 @@ and the global level separately. Likewise, memory pressure states are maintained on both the per-memcg level and the global level, and a socket is considered under pressure when either level asserts as much. -Signed-off-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org> +Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> --- include/linux/memcontrol.h | 12 ++++----- include/net/sock.h | 64 ++++++---------------------------------------- diff --git a/a/content_digest b/N2/content_digest index 44199fc..6b4584e 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -1,21 +1,20 @@ "ref\01447371693-25143-1-git-send-email-hannes@cmpxchg.org\0" "ref\01447371693-25143-9-git-send-email-hannes@cmpxchg.org\0" "ref\01447390418.22599.34.camel@edumazet-glaptop2.roam.corp.google.com\0" - "ref\01447390418.22599.34.camel-XN9IlZ5yJG9HTL0Zs8A6p/gx64E7kk8eUsxypvmhUTTZJqsBc5GL+g@public.gmane.org\0" - "From\0Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\0" + "From\0Johannes Weiner <hannes@cmpxchg.org>\0" "Subject\0Re: [PATCH 08/14] net: tcp_memcontrol: sanitize tcp memory accounting callbacks\0" "Date\0Fri, 13 Nov 2015 00:44:08 -0500\0" - "To\0Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>\0" - "Cc\0David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>" - Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> - Vladimir Davydov <vdavydov-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> - Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> - Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org> - netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org - cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org - " kernel-team-b10kYP2dOMg@public.gmane.org\0" + "To\0Eric Dumazet <eric.dumazet@gmail.com>\0" + "Cc\0David Miller <davem@davemloft.net>" + Andrew Morton <akpm@linux-foundation.org> + Vladimir Davydov <vdavydov@virtuozzo.com> + Tejun Heo <tj@kernel.org> + Michal Hocko <mhocko@suse.cz> + netdev@vger.kernel.org + linux-mm@kvack.org + cgroups@vger.kernel.org + linux-kernel@vger.kernel.org + " kernel-team@fb.com\0" "\00:1\0" "b\0" "On Thu, Nov 12, 2015 at 08:53:38PM -0800, Eric Dumazet wrote:\n" @@ -87,8 +86,8 @@ " }\n" "\n" "---\n" - "From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001\n" - "From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\n" + ">From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001\n" + "From: Johannes Weiner <hannes@cmpxchg.org>\n" "Date: Tue, 10 Nov 2015 17:14:41 -0500\n" "Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks\n" "\n" @@ -122,7 +121,7 @@ "maintained on both the per-memcg level and the global level, and a\n" "socket is considered under pressure when either level asserts as much.\n" "\n" - "Signed-off-by: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\n" + "Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>\n" "---\n" " include/linux/memcontrol.h | 12 ++++-----\n" " include/net/sock.h | 64 ++++++----------------------------------------\n" @@ -417,4 +416,4 @@ "-- \n" 2.6.2 -c0c60d6fcbb1ef9a3b66b256db6a2447c03e7e76987156f5e900807ce17de422 +bc2684fdc4997e606cf9a3a6b0300042ba7743dcb4e9fccb73f5c6a93c06d718
diff --git a/a/1.txt b/N3/1.txt index 2b6bdaf..35d42c2 100644 --- a/a/1.txt +++ b/N3/1.txt @@ -67,7 +67,7 @@ index 8cc7613..f954e2a 100644 } --- -From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001 +>From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001 From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org> Date: Tue, 10 Nov 2015 17:14:41 -0500 Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks diff --git a/a/content_digest b/N3/content_digest index 44199fc..53bc12f 100644 --- a/a/content_digest +++ b/N3/content_digest @@ -87,7 +87,7 @@ " }\n" "\n" "---\n" - "From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001\n" + ">From 4a24ca67e5b0f651a68807ee99f714437ffd6109 Mon Sep 17 00:00:00 2001\n" "From: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>\n" "Date: Tue, 10 Nov 2015 17:14:41 -0500\n" "Subject: [PATCH v2] net: tcp_memcontrol: sanitize tcp memory accounting callbacks\n" @@ -417,4 +417,4 @@ "-- \n" 2.6.2 -c0c60d6fcbb1ef9a3b66b256db6a2447c03e7e76987156f5e900807ce17de422 +37717684d24986f911305492564218a65fc6a1cae7541f1fbad4efb37b403a07
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.