linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peng Haitao <penght@cn.fujitsu.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: cgroups@vger.kernel.org, kamezawa.hiroyu@jp.fujitsu.com,
	Johannes Weiner <hannes@cmpxchg.org>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: how to make memory.memsw.failcnt is nonzero
Date: Fri, 06 Jan 2012 17:47:10 +0800	[thread overview]
Message-ID: <4F06C31E.4010904@cn.fujitsu.com> (raw)
In-Reply-To: <20120103160411.GD3891@tiehlicka.suse.cz>


Michal Hocko said the following on 2012-1-4 0:04:
>> # echo 15M > memory.memsw.limit_in_bytes
>> # dd if=/dev/zero of=/tmp/temp_file count=20 bs=1M
>> Killed
>> # grep "failcnt" /var/log/messages | tail -2
>> Dec 28 17:08:45 K-test kernel: memory: usage 10240kB, limit 10240kB, failcnt 86
>> Dec 28 17:08:45 K-test kernel: memory+swap: usage 10240kB, limit 15360kB, failcnt 0
>> # cat memory.memsw.failcnt
>> 0
>>
>> The limit is 15M, but memory+swap usage also is 10M.
>> I think memory+swap usage should be 15M and memsw.failcnt should be nonzero.
>>
> So there is almost 10M of page cache that we can simply reclaim. If we
> use 40M limit then we are OK. So this looks like the small limit somehow
> tricks our math in the reclaim path and we think there is nothing to
> reclaim.
> I will look into this.

Thanks for you reply.
If there is something wrong, I think the bug will be in mem_cgroup_do_charge()
of mm/memcontrol.c

2210         ret = res_counter_charge(&memcg->res, csize, &fail_res);
2211 
2212         if (likely(!ret)) {
2213                 if (!do_swap_account)
2214                         return CHARGE_OK;
2215                 ret = res_counter_charge(&memcg->memsw, csize, &fail_res);
2216                 if (likely(!ret))
2217                         return CHARGE_OK;
2218 
2219                 res_counter_uncharge(&memcg->res, csize);
2220                 mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw);
2221                 flags |= MEM_CGROUP_RECLAIM_NOSWAP;
2222         } else
2223                 mem_over_limit = mem_cgroup_from_res_counter(fail_res, res);

When hit memory.limit_in_bytes, res_counter_charge() will return -ENOMEM,
this will execute line 2222: } else.
But I think when hit memory.limit_in_bytes, the function should determine further
to memory.memsw.limit_in_bytes.
This think is OK?

-- 
Best Regards,
Peng


  reply	other threads:[~2012-01-06  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4EFADFF8.5020703@cn.fujitsu.com>
2012-01-03 16:04 ` how to make memory.memsw.failcnt is nonzero Michal Hocko
2012-01-06  9:47   ` Peng Haitao [this message]
2012-01-06 10:12     ` Michal Hocko
2012-01-30  2:47       ` Peng Haitao
2012-01-30  7:24         ` KAMEZAWA Hiroyuki
2012-01-30  2:34   ` Peng Haitao
2012-01-30  8:46     ` Michal Hocko

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=4F06C31E.4010904@cn.fujitsu.com \
    --to=penght@cn.fujitsu.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    /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;
as well as URLs for NNTP newsgroup(s).