linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov@parallels.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	cgroups@vger.kernel.org, devel@openvz.org,
	Johannes Weiner <hannes@cmpxchg.org>,
	Balbir Singh <bsingharora@gmail.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH] memcg: fix kmem_account_flags check in memcg_can_account_kmem()
Date: Fri, 29 Nov 2013 14:09:18 +0400	[thread overview]
Message-ID: <529867CE.4040004@parallels.com> (raw)
In-Reply-To: <20131129094502.GD25893@dhcp22.suse.cz>

On 11/29/2013 01:45 PM, Michal Hocko wrote:
> On Wed 27-11-13 19:46:01, Vladimir Davydov wrote:
>> We should start kmem accounting for a memory cgroup only after both its
>> kmem limit is set (KMEM_ACCOUNTED_ACTIVE) and related call sites are
>> patched (KMEM_ACCOUNTED_ACTIVATED).
> This should be vice-versa, no? ACTIVE is set after
> static_key_slow_inc(&memcg_kmem_enabled_key) AFAICS.
>
>> Currently memcg_can_account_kmem() allows kmem accounting even if only
>> one of the conditions is true.
>> Fix it.
> It would be nice to describe, what is the actual problem here. I assume
> this is a charge vs. enable race. Let me try
>
> So we have KMEM_ACCOUNTED_ACTIVATED (set by memcg_update_cache_sizes)
> but the static key is not enabled yet (so KMEM_ACCOUNTED_ACTIVE is not
> set yet). memcg_can_account_kmem is called from 2 contexts during charge
> 	- memcg_kmem_get_cache via __memcg_kmem_get_cache
> 	- memcg_kmem_newpage_charge via __memcg_kmem_newpage_charge
>
> both of them start by checking memcg_kmem_enabled which is our
> static key before memcg_can_account_kmem. This would suggest that
> static_key+ACTIVE check memcg_can_account_kmem is sufficient. No?

Yes, I guess you're perfectly right and we don't need the ACTIVATED bit 
at all. I'll look at this deeper and send a patch removing it if it 
doesn't break something.

Thanks.

--
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:[~2013-11-29 10:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 15:46 Vladimir Davydov
2013-11-27 15:46 ` [PATCH] memcg: make memcg_update_cache_sizes() static Vladimir Davydov
2013-11-29  9:45   ` Michal Hocko
2013-11-29  9:45 ` [PATCH] memcg: fix kmem_account_flags check in memcg_can_account_kmem() Michal Hocko
2013-11-29 10:09   ` Vladimir Davydov [this message]

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=529867CE.4040004@parallels.com \
    --to=vdavydov@parallels.com \
    --cc=bsingharora@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=devel@openvz.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