From: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-mm <linux-mm@kvack.org>, Michal Hocko <mhocko@suse.cz>,
David Rientjes <rientjes@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>
Subject: Re: [RFC][PATCH 1/2] add res_counter_usage_safe
Date: Fri, 29 Jun 2012 11:35:12 +0900 [thread overview]
Message-ID: <4FED1460.9080700@jp.fujitsu.com> (raw)
In-Reply-To: <4FEC3891.2000702@parallels.com>
(2012/06/28 19:57), Glauber Costa wrote:
> On 06/28/2012 02:20 PM, Kamezawa Hiroyuki wrote:
>> I think usage > limit means a sign of BUG. But, sometimes,
>> res_counter_charge_nofail() is very convenient. tcp_memcg uses it.
>> And I'd like to use it for helping page migration.
>>
>> This patch adds res_counter_usage_safe() which returns min(usage,limit).
>> By this we can use res_counter_charge_nofail() without breaking
>> user experience.
>>
>> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> I totally agree.
>
> It would be very nice to never go over limit, but truth is, sometimes
> we're forced too - for a limited time. In those circumstances, it is
> better to actually charge memcg, so the charges won't unbalance and
> disappear. Every work around proposed so far for those has been to
> basically add some form of "extra_charge" to the memcg, that would
> effectively charge to it, but not display it.
>
> The good fix is in the display side.
>
> We should just be careful to always have good justification for no_fail
> usage. It should be reserved to those situations where we really need
> it, but that's on us on future reviews.
>
> For the idea:
>
> Acked-by: Glauber Costa <glommer@parallels.com>
>
> For the patch itself: I believe we can take the lock once in
> res_counter_usage_safe, and then read the value and the limit under it.
>
> Calling res_counter_read_u64 two times seems not only wasteful but
> potentially wrong, since they can change under our nose.
>
Thank you for comments.
I'll update the patch using that way.
Thanks,
-Kame
--
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>
next prev parent reply other threads:[~2012-06-29 2:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-28 10:20 [RFC][PATCH 1/2] add res_counter_usage_safe Kamezawa Hiroyuki
2012-06-28 10:23 ` [RFC][PATCH 2/2] memcg : remove -ENOMEM at page migration Kamezawa Hiroyuki
2012-06-29 21:41 ` David Rientjes
2012-07-02 16:48 ` Michal Hocko
2012-06-28 10:57 ` [RFC][PATCH 1/2] add res_counter_usage_safe Glauber Costa
2012-06-29 2:35 ` Kamezawa Hiroyuki [this message]
2012-06-29 21:34 ` David Rientjes
2012-07-02 16:52 ` Michal Hocko
2012-07-04 13:19 ` Wanpeng Li
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=4FED1460.9080700@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=glommer@parallels.com \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=rientjes@google.com \
--cc=tj@kernel.org \
/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 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.