From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98F7CC2BA19 for ; Wed, 15 Apr 2020 13:43:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 657C02076D for ; Wed, 15 Apr 2020 13:43:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 657C02076D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D54DE8E001F; Wed, 15 Apr 2020 09:43:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D04308E0001; Wed, 15 Apr 2020 09:43:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCD2B8E001F; Wed, 15 Apr 2020 09:43:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id A2B4C8E0001 for ; Wed, 15 Apr 2020 09:43:03 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 616B96115 for ; Wed, 15 Apr 2020 13:43:03 +0000 (UTC) X-FDA: 76710205446.28.lake37_1a8eac8e91233 X-HE-Tag: lake37_1a8eac8e91233 X-Filterd-Recvd-Size: 4934 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Apr 2020 13:43:02 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R151e4;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=38;SR=0;TI=SMTPD_---0TvcmpSS_1586958174; Received: from IT-FVFX43SYHV2H.lan(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TvcmpSS_1586958174) by smtp.aliyun-inc.com(127.0.0.1); Wed, 15 Apr 2020 21:42:55 +0800 Subject: Re: [PATCH v8 03/10] mm/lru: replace pgdat lru_lock with lruvec lock To: Johannes Weiner Cc: 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, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, Michal Hocko , Vladimir Davydov , Roman Gushchin , Chris Down , Thomas Gleixner , Vlastimil Babka , Qian Cai , Andrey Ryabinin , "Kirill A. Shutemov" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , David Rientjes , "Aneesh Kumar K.V" , swkhack , "Potyra, Stefan" , Mike Rapoport , Stephen Rothwell , Colin Ian King , Jason Gunthorpe , Mauro Carvalho Chehab , Peng Fan , Nikolay Borisov , Ira Weiny , Kirill Tkhai , Yafang Shao References: <1579143909-156105-1-git-send-email-alex.shi@linux.alibaba.com> <1579143909-156105-4-git-send-email-alex.shi@linux.alibaba.com> <20200116215222.GA64230@cmpxchg.org> <20200413180725.GA99267@cmpxchg.org> <8e7bf170-2bb5-f862-c12b-809f7f7d96cb@linux.alibaba.com> <20200414163114.GA136578@cmpxchg.org> From: Alex Shi Message-ID: <54af0662-cbb4-88c7-7eae-f969684025dd@linux.alibaba.com> Date: Wed, 15 Apr 2020 21:42:26 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200414163114.GA136578@cmpxchg.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: =E5=9C=A8 2020/4/15 =E4=B8=8A=E5=8D=8812:31, Johannes Weiner =E5=86=99=E9= =81=93: > On Tue, Apr 14, 2020 at 12:52:30PM +0800, Alex Shi wrote: >> =E5=9C=A8 2020/4/14 =E4=B8=8A=E5=8D=882:07, Johannes Weiner =E5=86=99=E9= =81=93: >>> Plus, the overhead of tracking is tiny - 512k per G of swap (0.04%). >>> >>> Maybe we should just delete MEMCG_SWAP and unconditionally track swap >>> entry ownership when the memory controller is enabled. I don't see a >>> good reason not to, and it would simplify the entire swapin path, the >>> LRU locking, and the page->mem_cgroup stabilization rules. >>> >> >> Sorry for not follow you up, did you mean just remove the MEMCG_SWAP c= onfiguration >> and keep the feature in default memcg?=20 >=20 > Yes. >=20 >> That does can remove lrucare, but PageLRU lock scheme still fails sinc= e >> we can not isolate the page during commit_charge, is that right? >=20 > No, without lrucare the scheme works. Charges usually do: >=20 > page->mem_cgroup =3D new; > SetPageLRU(page); >=20 > And so if you can TestClearPageLRU(), page->mem_cgroup is stable. >=20 > lrucare charging is the exception: it changes page->mem_cgroup AFTER > PageLRU has already been set, and even when it CANNOT acquire the > PageLRU lock itself. It violates the rules. >=20 > If we make MEMCG_SWAP mandatory, we always have cgroup records for > swapped out pages. That means we can charge all swapin pages > (incl. readahead pages) directly in __read_swap_cache_async(), before > setting PageLRU on the new pages. >=20 > Then we can delete lrucare. >=20 > And then TestClearPageLRU() guarantees page->mem_cgroup is stable. >=20 Hi Johannes, Thanks a lot for point out! Charging in __read_swap_cache_async would ask for 3 layers function argum= ents pass, that would be a bit ugly. Compare to this, could we move out the lru_cache add after commit_charge, like ksm copied pages? That give a bit extra non lru list time, but the page just only be used o= nly after add_anon_rmap setting. Could it cause troubles? I tried to track down the reason of lru_cache_add here, but no explanatio= n till first git kernel commit. Thanks Alex=20