Re: [PATCH v7 02/10] mm/memcg: fold lru_lock in lock_page_lru
From: Alex Shi
Date: Mon Jan 13 2020 - 04:47:27 EST
å 2020/1/10 äå4:49, Konstantin Khlebnikov åé:
> On 25/12/2019 12.04, Alex Shi wrote:
>> ÂFrom the commit_charge's explanations and mem_cgroup_commit_charge
>> comments, as well as call path when lrucare is ture, The lru_lock is
>> just to guard the task migration(which would be lead to move_account)
>> So it isn't needed when !PageLRU, and better be fold into PageLRU to
>> reduce lock contentions.
>>
>> Signed-off-by: Alex Shi <alex.shi@xxxxxxxxxxxxxxxxx>
>> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
>> Cc: Michal Hocko <mhocko@xxxxxxxxxx>
>> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
>> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
>> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>> Cc: cgroups@xxxxxxxxxxxxxxx
>> Cc: linux-mm@xxxxxxxxx
>> Cc: linux-kernel@xxxxxxxxxxxxxxx
>> ---
>> Â mm/memcontrol.c | 9 ++++-----
>> Â 1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index c5b5f74cfd4d..0ad10caabc3d 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -2572,12 +2572,11 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
>> Â Â static void lock_page_lru(struct page *page, int *isolated)
>> Â {
>> -ÂÂÂ pg_data_t *pgdat = page_pgdat(page);
>> -
>> -ÂÂÂ spin_lock_irq(&pgdat->lru_lock);
>> ÂÂÂÂÂ if (PageLRU(page)) {
>> +ÂÂÂÂÂÂÂ pg_data_t *pgdat = page_pgdat(page);
>> ÂÂÂÂÂÂÂÂÂ struct lruvec *lruvec;
>> Â +ÂÂÂÂÂÂÂ spin_lock_irq(&pgdat->lru_lock);
>
> That's wrong. Here PageLRU must be checked again under lru_lock.
Hi, Konstantin,
For logical remain, we can get the lock and then release for !PageLRU.
but I still can figure out the problem scenario. Would like to give more hints?
>
>
> Also I don't like these functions:
> - called lock/unlock but actually also isolates
> - used just once
> - pgdat evaluated twice
That's right. I will fold these functions into commit_charge.
Thanks
Alex