Re: [PATCH 2/3] cgroup: duplicate cgroup reference when cloning sockets

2016-09-19 Thread Vladimir Davydov
s are destroyed later on. > > Fixes: bd1060a1d671 ("sock, cgroup: add sock->sk_cgroup") > Cc: # 4.5+ > Signed-off-by: Johannes Weiner Reviewed-by: Vladimir Davydov

Re: [PATCH 1/3] mm: memcontrol: make per-cpu charge cache IRQ-safe for socket accounting

2016-09-19 Thread Vladimir Davydov
rain operation > will put references of in-use pages, thus causing the imbalance. > > Disable IRQs during all per-cpu charge cache operations. > > Fixes: f7e1cb6ec51b ("mm: memcontrol: account socket memory in unified > hierarchy memory controller") > Cc: # 4.5+ > Signed-off-by: Johannes Weiner Acked-by: Vladimir Davydov

Re: [PATCH RESEND 8/8] af_unix: charge buffers to kmemcg

2016-08-24 Thread Vladimir Davydov
Hello, On Tue, Aug 23, 2016 at 02:48:11PM +0100, Sudeep K N wrote: > On Tue, May 24, 2016 at 5:36 PM, Vladimir Davydov > wrote: > > On Tue, May 24, 2016 at 06:02:06AM -0700, Eric Dumazet wrote: > >> On Tue, 2016-05-24 at 11:49 +0300, Vladimir Davydov wrote: > >>

Re: [PATCH RESEND 7/8] pipe: account to kmemcg

2016-05-27 Thread Vladimir Davydov
On Thu, May 26, 2016 at 07:15:49AM -0700, Eric Dumazet wrote: > On Thu, 2016-05-26 at 16:59 +0300, Vladimir Davydov wrote: > > On Thu, May 26, 2016 at 04:04:55PM +0900, Minchan Kim wrote: > > > On Wed, May 25, 2016 at 01:30:11PM +0300, Vladimir Davydov wrote: > > > >

Re: [PATCH RESEND 7/8] pipe: account to kmemcg

2016-05-26 Thread Vladimir Davydov
On Thu, May 26, 2016 at 04:04:55PM +0900, Minchan Kim wrote: > On Wed, May 25, 2016 at 01:30:11PM +0300, Vladimir Davydov wrote: > > On Tue, May 24, 2016 at 01:04:33PM -0700, Eric Dumazet wrote: > > > On Tue, 2016-05-24 at 19:13 +0300, Vladimir Davydov wrote: > > > >

Re: [PATCH RESEND 7/8] pipe: account to kmemcg

2016-05-25 Thread Vladimir Davydov
On Tue, May 24, 2016 at 01:04:33PM -0700, Eric Dumazet wrote: > On Tue, 2016-05-24 at 19:13 +0300, Vladimir Davydov wrote: > > On Tue, May 24, 2016 at 05:59:02AM -0700, Eric Dumazet wrote: > > ... > > > > +static int anon_pipe_buf_steal(s

Re: [PATCH RESEND 7/8] pipe: account to kmemcg

2016-05-24 Thread Vladimir Davydov
On Tue, May 24, 2016 at 05:59:02AM -0700, Eric Dumazet wrote: ... > > +static int anon_pipe_buf_steal(struct pipe_inode_info *pipe, > > + struct pipe_buffer *buf) > > +{ > > + struct page *page = buf->page; > > + > > + if (page_count(page) == 1) { > > This looks racy :

Re: [PATCH RESEND 8/8] af_unix: charge buffers to kmemcg

2016-05-24 Thread Vladimir Davydov
On Tue, May 24, 2016 at 06:02:06AM -0700, Eric Dumazet wrote: > On Tue, 2016-05-24 at 11:49 +0300, Vladimir Davydov wrote: > > Unix sockets can consume a significant amount of system memory, hence > > they should be accounted to kmemcg. > > > > Since unix socket buffer

[PATCH RESEND 8/8] af_unix: charge buffers to kmemcg

2016-05-24 Thread Vladimir Davydov
Unix sockets can consume a significant amount of system memory, hence they should be accounted to kmemcg. Since unix socket buffers are always allocated from process context, all we need to do to charge them to kmemcg is set __GFP_ACCOUNT in sock->sk_allocation mask. Signed-off-by: Vladi

[PATCH RESEND 6/8] arch: x86: charge page tables to kmemcg

2016-05-24 Thread Vladimir Davydov
can be shared among processes from different cgroups so accounting them to a particular one can pin other cgroups for indefinitely long. So we clear __GFP_ACCOUNT flag if a page table is allocated for the kernel. Signed-off-by: Vladimir Davydov Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H.

[PATCH RESEND 1/8] mm: remove pointless struct in struct page definition

2016-05-24 Thread Vladimir Davydov
... to reduce indentation level thus leaving more space for comments. Signed-off-by: Vladimir Davydov --- include/linux/mm_types.h | 68 +++- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux

Re: [PATCH 8/8] af_unix: charge buffers to kmemcg

2016-05-24 Thread Vladimir Davydov
[adding netdev to Cc] On Mon, May 23, 2016 at 01:20:29PM +0300, Vladimir Davydov wrote: > Unix sockets can consume a significant amount of system memory, hence > they should be accounted to kmemcg. > > Since unix socket buffers are always allocated from process context, > all w

[PATCH RESEND 2/8] mm: clean up non-standard page->_mapcount users

2016-05-24 Thread Vladimir Davydov
- Add a proper comment to page->_mapcount. - Introduce a macro for generating helper functions. - Place all special page->_mapcount values next to each other so that readers can see all possible values and so we don't get duplicates. Signed-off-by: Vladimir Davydov --- in

[PATCH RESEND 0/8] More stuff to charge to kmemcg

2016-05-24 Thread Vladimir Davydov
. Patches 5-7 make x86 page tables, pipe buffers, and unix socket buffers accountable. [1] http://lkml.kernel.org/r/%3ccover.1443262808.git.vdavy...@parallels.com%3E Thanks, Vladimir Davydov (8): mm: remove pointless struct in struct page definition mm: clean up non-standard page->_mapco

[PATCH RESEND 4/8] mm: charge/uncharge kmemcg from generic page allocator paths

2016-05-24 Thread Vladimir Davydov
page->_mapcount check on free, which shouldn't hurt performance, because the data accessed are hot. Signed-off-by: Vladimir Davydov --- include/linux/gfp.h| 10 +-- include/linux/page-flags.h | 7 + kernel/fork.c | 6 ++--- mm

[PATCH RESEND 5/8] mm: memcontrol: teach uncharge_list to deal with kmem pages

2016-05-24 Thread Vladimir Davydov
Page table pages are batched-freed in release_pages on most architectures. If we want to charge them to kmemcg (this is what is done later in this series), we need to teach mem_cgroup_uncharge_list to handle kmem pages. Signed-off-by: Vladimir Davydov --- mm/memcontrol.c | 42

[PATCH RESEND 3/8] mm: memcontrol: cleanup kmem charge functions

2016-05-24 Thread Vladimir Davydov
o the caller as well so that one wouldn't have to dive deep into memcg implementation to see which allocations are charged and which are not. - Refresh comments. Signed-off-by: Vladimir Davydov --- include/linux/memcontrol.h | 103 +++-- mm/me

[PATCH RESEND 7/8] pipe: account to kmemcg

2016-05-24 Thread Vladimir Davydov
get reused for other purposes, including mapping to userspace, we clear PageKmemcg thus resetting page->_mapcount and uncharge it in anon_pipe_buf_steal, which is introduced by this patch. Signed-off-by: Vladimir Davydov Cc: Alexander Viro --- fs/pipe.c | 32 ++-- 1

Re: [PATCH] mm: memcontrol: MEMCG no longer works with SLOB

2015-12-10 Thread Vladimir Davydov
On Wed, Dec 09, 2015 at 03:01:07PM -0500, Johannes Weiner wrote: > On Wed, Dec 09, 2015 at 05:32:39PM +0100, Arnd Bergmann wrote: > > The change to move the kmem accounting into the normal memcg > > code means we can no longer use memcg with slob, which lacks > > the memcg_params member in its stru

Re: [PATCH 12/13] mm: memcontrol: account socket memory in unified hierarchy memory controller

2015-11-30 Thread Vladimir Davydov
On Mon, Nov 30, 2015 at 10:26:38AM -0500, Johannes Weiner wrote: > On Mon, Nov 30, 2015 at 01:54:21PM +0300, Vladimir Davydov wrote: > > On Tue, Nov 24, 2015 at 04:58:44PM -0500, Johannes Weiner wrote: > > ... > > > @@ -5520,15 +5557,30 @@ void sock_relea

Re: [PATCH 13/13] mm: memcontrol: hook up vmpressure to socket pressure

2015-11-30 Thread Vladimir Davydov
On Mon, Nov 30, 2015 at 10:58:38AM -0500, Johannes Weiner wrote: > On Mon, Nov 30, 2015 at 02:36:28PM +0300, Vladimir Davydov wrote: > > Suppose we have the following cgroup configuration. > > > > A __ B > > \_ C > > > > A is empty (which is natural

Re: [PATCH 13/13] mm: memcontrol: hook up vmpressure to socket pressure

2015-11-30 Thread Vladimir Davydov
On Tue, Nov 24, 2015 at 04:59:40PM -0500, Johannes Weiner wrote: ... > @@ -2396,6 +2396,7 @@ static bool shrink_zone(struct zone *zone, struct > scan_control *sc, > memcg = mem_cgroup_iter(root, NULL, &reclaim); > do { > unsigned long lru_pages; >

Re: [PATCH 12/13] mm: memcontrol: account socket memory in unified hierarchy memory controller

2015-11-30 Thread Vladimir Davydov
memory_cgrp_subsys)) { > + page_counter_uncharge(&memcg->tcp_mem.memory_allocated, > + nr_pages); > + return; > + } > +#endif > + page_counter_uncharge(&memcg->memory, nr_pages); > + css_p

Re: [PATCH 09/14] net: tcp_memcontrol: simplify linkage between socket and page counter

2015-11-24 Thread Vladimir Davydov
On Mon, Nov 23, 2015 at 01:20:37PM -0500, Johannes Weiner wrote: > On Mon, Nov 23, 2015 at 12:36:46PM +0300, Vladimir Davydov wrote: > > On Fri, Nov 20, 2015 at 01:56:48PM -0500, Johannes Weiner wrote: > > > I actually had all this at first, but then wondered if it makes more &

Re: [PATCH 13/14] mm: memcontrol: account socket memory in unified hierarchy memory controller

2015-11-23 Thread Vladimir Davydov
On Fri, Nov 20, 2015 at 02:25:06PM -0500, Johannes Weiner wrote: > On Fri, Nov 20, 2015 at 04:10:33PM +0300, Vladimir Davydov wrote: > > On Thu, Nov 12, 2015 at 06:41:32PM -0500, Johannes Weiner wrote: > > ... > > > @@ -5514,16 +5550,43 @@ void sock_relea

Re: [PATCH 09/14] net: tcp_memcontrol: simplify linkage between socket and page counter

2015-11-23 Thread Vladimir Davydov
On Fri, Nov 20, 2015 at 01:56:48PM -0500, Johannes Weiner wrote: > On Fri, Nov 20, 2015 at 03:42:16PM +0300, Vladimir Davydov wrote: > > On Thu, Nov 12, 2015 at 06:41:28PM -0500, Johannes Weiner wrote: > > > There won't be any separate counters for socket memory consumed b

Re: [PATCH 13/14] mm: memcontrol: account socket memory in unified hierarchy memory controller

2015-11-20 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:32PM -0500, Johannes Weiner wrote: ... > @@ -5514,16 +5550,43 @@ void sock_release_memcg(struct sock *sk) > */ > bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) > { > + unsigned int batch = max(CHARGE_BATCH, nr_pages); > stru

Re: [PATCH 12/14] mm: memcontrol: move socket code for unified hierarchy accounting

2015-11-20 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:31PM -0500, Johannes Weiner wrote: > The unified hierarchy memory controller will account socket > memory. Move the infrastructure functions accordingly. > > Signed-off-by: Johannes Weiner > Acked-by: Michal Hocko Reviewed-by: Vladimir Davydov --

Re: [PATCH 09/14] net: tcp_memcontrol: simplify linkage between socket and page counter

2015-11-20 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:28PM -0500, Johannes Weiner wrote: > There won't be any separate counters for socket memory consumed by > protocols other than TCP in the future. Remove the indirection and I really want to believe you're right. And with vmpressure propagation implemented properly you

Re: [PATCH 08/14] net: tcp_memcontrol: sanitize tcp memory accounting callbacks

2015-11-20 Thread Vladimir Davydov
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 It leaves the legacy functionality intact, while making the code look much better. Reviewed-by:

Re: [PATCH 07/14] net: tcp_memcontrol: simplify the per-memcg limit access

2015-11-20 Thread Vladimir Davydov
Johannes Weiner Reviewed-by: Vladimir Davydov -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 06/14] net: tcp_memcontrol: remove dead per-memcg count of allocated sockets

2015-11-20 Thread Vladimir Davydov
s is the last user of parent_cg_proto(), remove that too. > > Signed-off-by: Johannes Weiner Reviewed-by: Vladimir Davydov -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 04/14] net: tcp_memcontrol: remove bogus hierarchy pressure propagation

2015-11-20 Thread Vladimir Davydov
cket arrives for them. Hmm, we still call sk_prot->enter_memory_pressure, which might hurt a workload in the root cgroup AFAICS. Strange. You fix it in patch 8 though. > > So no additional hierarchy code is needed. Remove the bogus stuff. > > Signed-off-by: Johannes Weiner Review

Re: [PATCH 14/14] mm: memcontrol: hook up vmpressure to socket pressure

2015-11-18 Thread Vladimir Davydov
On Tue, Nov 17, 2015 at 05:22:17PM -0500, Johannes Weiner wrote: > On Tue, Nov 17, 2015 at 11:18:50PM +0300, Vladimir Davydov wrote: > > AFAIK vmpressure was designed to allow userspace to tune hard limits of > > cgroups in accordance with their demands, in which case the way how

Re: [PATCH 14/14] mm: memcontrol: hook up vmpressure to socket pressure

2015-11-17 Thread Vladimir Davydov
On Mon, Nov 16, 2015 at 01:53:16PM -0500, Johannes Weiner wrote: > On Sun, Nov 15, 2015 at 04:54:57PM +0300, Vladimir Davydov wrote: > > On Thu, Nov 12, 2015 at 06:41:33PM -0500, Johannes Weiner wrote: > > > Let the networking stack know when a memcg is under reclaim pressure &g

Re: [PATCH 14/14] mm: memcontrol: hook up vmpressure to socket pressure

2015-11-15 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:33PM -0500, Johannes Weiner wrote: > Let the networking stack know when a memcg is under reclaim pressure > so that it can clamp its transmit windows accordingly. > > Whenever the reclaim efficiency of a cgroup's LRU lists drops low > enough for a MEDIUM or HIGH vmpre

Re: [PATCH 05/14] net: tcp_memcontrol: protect all tcp_memcontrol calls by jump-label

2015-11-14 Thread Vladimir Davydov
sary, because these functions aren't hot paths. Neither do I think it makes the code look better. Anyway, it's rather a matter of personal preference, and the patch looks correct to me, so Reviewed-by: Vladimir Davydov > > This also eliminates the need for dummy functions because the ca

Re: [PATCH 10/14] mm: memcontrol: generalize the socket accounting jump label

2015-11-14 Thread Vladimir Davydov
Johannes Weiner Reviewed-by: Vladimir Davydov -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 11/14] mm: memcontrol: do not account memory+swap on unified hierarchy

2015-11-14 Thread Vladimir Davydov
;). > > To avoid adding yet more pointless memory+swap accounting with the > socket memory support in unified hierarchy, disable the counter > altogether when in unified hierarchy mode. > > Signed-off-by: Johannes Weiner Reviewed-by: Vladimir Davydov -- To unsubscribe from th

Re: [PATCH 03/14] net: tcp_memcontrol: properly detect ancestor socket pressure

2015-11-14 Thread Vladimir Davydov
heir limit, and the child should enter socket pressure. > > Signed-off-by: Johannes Weiner Reviewed-by: Vladimir Davydov For the record: it was broken by commit 3e32cb2e0a12 ("mm: memcontrol: lockless page counters"). -- To unsubscribe from this list: send the line "u

Re: [PATCH 02/14] mm: vmscan: simplify memcg vs. global shrinker invocation

2015-11-14 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:21PM -0500, Johannes Weiner wrote: ... > diff --git a/mm/vmscan.c b/mm/vmscan.c > index a4507ec..e4f5b3c 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -411,6 +411,10 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, > struct shrinker *shrinker; >

Re: [PATCH 01/14] mm: memcontrol: export root_mem_cgroup

2015-11-14 Thread Vladimir Davydov
On Thu, Nov 12, 2015 at 06:41:20PM -0500, Johannes Weiner wrote: > A later patch will need this symbol in files other than memcontrol.c, > so export it now and replace mem_cgroup_root_css at the same time. > > Signed-off-by: Johannes Weiner > Acked-by: Michal Hocko Review

Re: [PATCH 5/8] mm: memcontrol: account socket memory on unified hierarchy

2015-11-06 Thread Vladimir Davydov
On Thu, Nov 05, 2015 at 03:55:22PM -0500, Johannes Weiner wrote: > On Thu, Nov 05, 2015 at 03:40:02PM +0100, Michal Hocko wrote: ... > > 3) keep only some (safe) cache types enabled by default with the current > >failing semantic and require an explicit enabling for the complete > >kmem acc

Re: [PATCH 0/8] mm: memcontrol: account socket memory in unified hierarchy

2015-11-02 Thread Vladimir Davydov
On Thu, Oct 29, 2015 at 10:52:28AM -0700, Johannes Weiner wrote: ... > Now, you mentioned that you'd rather see the socket buffers accounted > at the allocator level, but I looked at the different allocation paths > and network protocols and I'm not convinced that this makes sense. We > don't want

Re: [PATCH 0/8] mm: memcontrol: account socket memory in unified hierarchy

2015-10-29 Thread Vladimir Davydov
On Wed, Oct 28, 2015 at 11:58:10AM -0700, Johannes Weiner wrote: > On Wed, Oct 28, 2015 at 11:20:03AM +0300, Vladimir Davydov wrote: > > Then you'd better not touch existing tcp limits at all, because they > > just work, and the logic behind them is very close to that of glob

Re: [PATCH 0/8] mm: memcontrol: account socket memory in unified hierarchy

2015-10-28 Thread Vladimir Davydov
On Tue, Oct 27, 2015 at 09:01:08AM -0700, Johannes Weiner wrote: ... > > > But regardless of tcp window control, we need to account socket memory > > > in the main memory accounting pool where pressure is shared (to the > > > best of our abilities) between all accounted memory consumers. > > > > >

Re: [PATCH 0/8] mm: memcontrol: account socket memory in unified hierarchy

2015-10-27 Thread Vladimir Davydov
On Mon, Oct 26, 2015 at 01:22:16PM -0400, Johannes Weiner wrote: > On Thu, Oct 22, 2015 at 09:45:10PM +0300, Vladimir Davydov wrote: > > Hi Johannes, > > > > On Thu, Oct 22, 2015 at 12:21:28AM -0400, Johannes Weiner wrote: > > ... > > > Patch #5 adds account

Re: [PATCH 3/8] net: consolidate memcg socket buffer tracking and accounting

2015-10-23 Thread Vladimir Davydov
On Thu, Oct 22, 2015 at 03:09:43PM -0400, Johannes Weiner wrote: > On Thu, Oct 22, 2015 at 09:46:12PM +0300, Vladimir Davydov wrote: > > On Thu, Oct 22, 2015 at 12:21:31AM -0400, Johannes Weiner wrote: > > > The tcp memory controller has extensive provisions for future memor

Re: [PATCH 8/8] mm: memcontrol: hook up vmpressure to socket pressure

2015-10-22 Thread Vladimir Davydov
On Thu, Oct 22, 2015 at 12:21:36AM -0400, Johannes Weiner wrote: ... > @@ -185,8 +183,29 @@ static void vmpressure_work_fn(struct work_struct *work) > vmpr->reclaimed = 0; > spin_unlock(&vmpr->sr_lock); > > + level = vmpressure_calc_level(scanned, reclaimed); > + > + if (level

Re: [PATCH 5/8] mm: memcontrol: account socket memory on unified hierarchy

2015-10-22 Thread Vladimir Davydov
On Thu, Oct 22, 2015 at 12:21:33AM -0400, Johannes Weiner wrote: ... > @@ -5500,13 +5524,38 @@ void sock_release_memcg(struct sock *sk) > */ > bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) > { > + unsigned int batch = max(CHARGE_BATCH, nr_pages); > stru

Re: [PATCH 7/8] mm: vmscan: report vmpressure at the level of reclaim activity

2015-10-22 Thread Vladimir Davydov
On Thu, Oct 22, 2015 at 12:21:35AM -0400, Johannes Weiner wrote: ... > @@ -2437,6 +2439,10 @@ static bool shrink_zone(struct zone *zone, struct > scan_control *sc, > } > } > > + vmpressure(sc->gfp_mask, memcg, > +

Re: [PATCH 3/8] net: consolidate memcg socket buffer tracking and accounting

2015-10-22 Thread Vladimir Davydov
On Thu, Oct 22, 2015 at 12:21:31AM -0400, Johannes Weiner wrote: > The tcp memory controller has extensive provisions for future memory > accounting interfaces that won't materialize after all. Cut the code > base down to what's actually used, now and in the likely future. > > - There won't be any

Re: [PATCH 0/8] mm: memcontrol: account socket memory in unified hierarchy

2015-10-22 Thread Vladimir Davydov
Hi Johannes, On Thu, Oct 22, 2015 at 12:21:28AM -0400, Johannes Weiner wrote: ... > Patch #5 adds accounting and tracking of socket memory to the unified > hierarchy memory controller, as described above. It uses the existing > per-cpu charge caches and triggers high limit reclaim asynchroneously.