Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3747149ybl; Mon, 13 Jan 2020 01:49:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwrhA0p4g74QzKYP+ExcPCY3JlUB1BESMJ2oDTxgPUh/fWrzx1Apz5Ced8UjNNMdQNMZGZX X-Received: by 2002:a9d:6251:: with SMTP id i17mr12549439otk.14.1578908974424; Mon, 13 Jan 2020 01:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578908974; cv=none; d=google.com; s=arc-20160816; b=bC3fK39Ju9M1JKvSErAJ6G0rHKsy5TDR8L2M0oNq+j91Z1VXgAKfaULeYD97ZTEdwr qHJUjrIXvs0Hel6iyqfMTZB7GcNBEsCZKQR8/y1iz8RyBJbw4OTHjpyvvzGGoA+h2XBD GrVvcA+3Z3yfafgZZyFPWosMEP3+OlDKzOzp5UgCX8weJ9QOnSCkn+T4Ib9wTEwy+/Ok sniB3a7qSvWpyOMSSt7h6NPEqbmewy7d55gHwLG1pnOO55lRW+deiLO0OQTOa4yPY8BZ uEVS3RE+YjewmHdfqh1m7Bsd1YgVCJyUk7+5p9MJhmrkdH49u5Y8u9Qhcp9hXsv5ro/W o1Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=Sot0Cf+Fn7pD6RQ3lMDuGHCmHdXmiSkx5JLuw228YEQ=; b=D5f+E0AUPkAplshcU+PGg4TvoJgu/1ksnKezD0KqT1MGkv/lKjITaIabRO0aDhLfle hp5+vIozgKXpRuTVKkmwmi0IW86TJnNHwFL9Q01IXNcEzCC5CQDslbOeuTSgfFmkojPY pNyYbOHq9XJfAr99pnDI++z+yEk57vRbcGTRUgLFsVqDykFtsMfCLF07vKy8E+fANvyV o4n+RW6ciLf9lnQmaVcekiuYfc9+K0JAw2rgLJ7ov9ISuBeWVnHseFm43158bTmFeo3r agA8y0mbvpP52X2HMOqQYwyEOHtXqtRV4ajhxlm+GoiSTIa8UC7kahQp+lUGRTDs9DI7 lnkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si6250428ota.43.2020.01.13.01.49.22; Mon, 13 Jan 2020 01:49:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728670AbgAMJrZ (ORCPT + 99 others); Mon, 13 Jan 2020 04:47:25 -0500 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:35470 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgAMJrX (ORCPT ); Mon, 13 Jan 2020 04:47:23 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R661e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0TncLfyC_1578908838; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TncLfyC_1578908838) by smtp.aliyun-inc.com(127.0.0.1); Mon, 13 Jan 2020 17:47:19 +0800 Subject: Re: [PATCH v7 02/10] mm/memcg: fold lru_lock in lock_page_lru To: Konstantin Khlebnikov , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, hannes@cmpxchg.org Cc: Michal Hocko , Vladimir Davydov References: <1577264666-246071-1-git-send-email-alex.shi@linux.alibaba.com> <1577264666-246071-3-git-send-email-alex.shi@linux.alibaba.com> <36d7e390-a3d1-908c-d181-4a9e9c8d3d98@yandex-team.ru> From: Alex Shi Message-ID: <952d02c2-8aa5-40bb-88bb-c43dee65c8bc@linux.alibaba.com> Date: Mon, 13 Jan 2020 17:45:51 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <36d7e390-a3d1-908c-d181-4a9e9c8d3d98@yandex-team.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 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 >> Cc: Johannes Weiner >> Cc: Michal Hocko >> Cc: Matthew Wilcox >> Cc: Vladimir Davydov >> Cc: Andrew Morton >> Cc: cgroups@vger.kernel.org >> Cc: linux-mm@kvack.org >> Cc: linux-kernel@vger.kernel.org >> --- >>   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