linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@parallels.com>
To: Ying Han <yinghan@google.com>
Cc: Suleiman Souhlal <suleiman@google.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	balbir@linux.vnet.ibm.com, David Rientjes <rientjes@google.com>,
	linux-mm@kvack.org
Subject: Re: memcg: slab control
Date: Fri, 27 Nov 2009 12:45:02 +0300	[thread overview]
Message-ID: <4B0F9F9E.3060604@parallels.com> (raw)
In-Reply-To: <604427e00911262315n5d520cf4p447f68e7053adc11@mail.gmail.com>

Ying Han wrote:
> On Thu, Nov 26, 2009 at 4:31 AM, Pavel Emelyanov <xemul@parallels.com> wrote:
>>> Aren't there patches to make the kernel track which cgroup caused
>>> which disk I/O? If so, it should be possible to charge the bios to the
>>> right cgroup.
>>>
>>> Maybe one way to decide which kernel allocations should be accounted
>>> would be to look at the calling context: If the allocation is done in
>>> user context (syscall), then it could be counted towards that user,
>>> while if the allocation is done in interrupt or kthread context, it
>>> shouldn't be accounted.
>>>
>>> Of course, this wouldn't be perfect, but it might be a good enough
>>> approximation.
>> I disagree. Bio-s are allocated in user context for all typical reads
>> (unless we requested aio) and are allocated either in pdflush context
>> or (!) in arbitrary task context for writes (e.g. via try_to_free_pages)
>> and thus such bio/buffer_head accounting will be completely random.
>>
>> One of the way to achieve the goal I can propose the following (it's
>> not perfect, but just smth to start discussion from).
>>
>> We implement support for accounting based on a bit on a kmem_cache
>> structure and mark all kmalloc caches as not-accountable. Then we grep
>> the kernel to find all kmalloc-s and think - if a kmalloc is to be
>> accounted we turn this into kmem_cache_alloc() with dedicated
>> kmem_cache and mark it as accountable.
> 
> Well it would be nice to count all kernel memory allocations
> trigger-able by user programs, the kernel
> memory includes kernel slabs as well as the pages directly allocated
> by get_free_pages(). However some
> of the allocations happen asynchronously like in kernel thread or
> interrupt context. We can not charge them
> on the random process happen to run at the time.
> 
> We can either not count those allocations, or do some special
> treatment to remember who owns those allocations.
> In our networking intensive workload, it causes us lots of trouble of
> miscounting the networking slabs for incoming
> packets. So we make changes in the networking stack which records the
> owner of the socket and then charge the
> slab later using that recorded information.

That's the same as what we do, but note, that simple accounting
is not enough for socket buffers (a.k.a. skb-s). In a perfect world
we should implement a memory management similar to what already
exists in the networking.

In particular - sockets should not report errors in case of kmem
shortage, but instead goto waiting state. Besides, TCP sockets should
adjust the TCP window according to the current kmem controller state
and this task is quite complex.

> --Ying
> 
>>> -- Suleiman
>>>
>>
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-11-27  9:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 23:08 David Rientjes
2009-11-26  1:14 ` KAMEZAWA Hiroyuki
2009-11-26  8:50   ` Balbir Singh
2009-11-26  8:56     ` KAMEZAWA Hiroyuki
2009-11-26  9:10       ` Pavel Emelyanov
2009-11-26  9:33         ` KAMEZAWA Hiroyuki
2009-11-26  9:56           ` Pavel Emelyanov
2009-11-26 10:24             ` Suleiman Souhlal
2009-11-26 12:31               ` Pavel Emelyanov
2009-11-26 12:52                 ` Suleiman Souhlal
2009-12-01  7:40                   ` Balbir Singh
2009-11-27  7:15                 ` Ying Han
2009-11-27  9:45                   ` Pavel Emelyanov [this message]
2009-12-01  5:14                   ` KOSAKI Motohiro
2009-11-30 22:57                 ` David Rientjes
2009-12-01 10:31                   ` Pavel Emelyanov
2009-12-01 22:29                     ` David Rientjes
2009-12-01  7:36             ` Balbir Singh
2009-12-01 10:40               ` Pavel Emelyanov
2009-12-01 15:14                 ` Balbir Singh
2009-12-02 10:14                   ` Pavel Emelyanov
2009-12-02 10:19                     ` Balbir Singh
2009-12-02 10:51                       ` Pavel Emelyanov
2009-11-30 22:55         ` David Rientjes
2009-12-01 10:39           ` Pavel Emelyanov
2009-11-26 10:13     ` Suleiman Souhlal
2009-11-30  9:17       ` Balbir Singh
2009-11-30 22:45   ` David Rientjes
2009-11-26  1:17 ` KAMEZAWA Hiroyuki
2009-11-26 10:01   ` Suleiman Souhlal
2009-11-26  2:35 ` KOSAKI Motohiro
2009-11-27  7:01   ` Ying Han
2009-11-27  9:48     ` Pavel Emelyanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B0F9F9E.3060604@parallels.com \
    --to=xemul@parallels.com \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=suleiman@google.com \
    --cc=yinghan@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox