[Devel] [PATCH rh7 v2] mm/memcontrol: memcg_move_account() get rid of lock_page dependency.

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Mar 5 11:54:59 MSK 2020


On 3/5/20 8:19 AM, Vasily Averin wrote:
> On 3/4/20 3:56 PM, Andrey Ryabinin wrote:
>> Instead of trylock'ing the page, use the lru_lock to prevent the
>> racing against mem_cgroup_migrate(). So the memcg_move_account() doesn't
>> depend on hung IO.
>>
>> The trylock seems to be needed to prevent mem_cgroup_migrate() to see
>> disbalanced pc->mem_cgroup && pc->flags state. We could achieve the same
>> by using lru_lock instead. memcg_move_account() only works with isolated
>> from LRU pages, so it can race only with mem_cgroup_migrate() called
>> with lrucare=true, otherwise the page is not on LRU so the memcg_move_account()
>> can't see it.
>>
>> Also memcg_move_account() might race against try_get_mem_cgroup_from_page()
>> when mem_cgroup_move_account() called for online cgroup. This happens when
>> task moved between cgroups and memory.move_charge_at_immigrate set at
>> certain value. Keep the trylock_page() to protect us from such race just
>> in case.
> 
> Can we use trylock_page() in all cases and use "if(is_offline) lru_lock" only if lockpage fails?
>  

Seems possible, don't see the benefit of such approach though.


More information about the Devel mailing list