Re: [RFC][PATCH 1/2] add res_counter_usage_safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(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@xxxxxxxxxxxxxx>
> 
> 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@xxxxxxxxxxxxx>
> 
> 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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]