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=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 1D42CC00A89 for ; Tue, 3 Nov 2020 03:04:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A3CF92076E for ; Tue, 3 Nov 2020 03:04:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3CF92076E 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 EFAC66B005C; Mon, 2 Nov 2020 22:04:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E843B6B005D; Mon, 2 Nov 2020 22:04:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4CE16B0068; Mon, 2 Nov 2020 22:04:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id A50EE6B005C for ; Mon, 2 Nov 2020 22:04:56 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2E5F33632 for ; Tue, 3 Nov 2020 03:04:56 +0000 (UTC) X-FDA: 77441614992.24.fact00_3012111272b5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 0A5751A4A0 for ; Tue, 3 Nov 2020 03:04:56 +0000 (UTC) X-HE-Tag: fact00_3012111272b5 X-Filterd-Recvd-Size: 5043 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Nov 2020 03:04:54 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0UE2aS-g_1604372689; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UE2aS-g_1604372689) by smtp.aliyun-inc.com(127.0.0.1); Tue, 03 Nov 2020 11:04:49 +0800 Subject: Re: [PATCH v20 15/20] mm/lru: introduce TestClearPageLRU To: Johannes Weiner Cc: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com, Michal Hocko References: <1603968305-8026-1-git-send-email-alex.shi@linux.alibaba.com> <1603968305-8026-16-git-send-email-alex.shi@linux.alibaba.com> <20201102151008.GH724984@cmpxchg.org> From: Alex Shi Message-ID: Date: Tue, 3 Nov 2020 11:02:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201102151008.GH724984@cmpxchg.org> Content-Type: text/plain; charset=gbk 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: =D4=DA 2020/11/2 =CF=C2=CE=E711:10, Johannes Weiner =D0=B4=B5=C0: > On Thu, Oct 29, 2020 at 06:45:00PM +0800, Alex Shi wrote: >> Currently lru_lock still guards both lru list and page's lru bit, that= 's >> ok. but if we want to use specific lruvec lock on the page, we need to >> pin down the page's lruvec/memcg during locking. Just taking lruvec >> lock first may be undermined by the page's memcg charge/migration. To >> fix this problem, we could clear the lru bit out of locking and use >> it as pin down action to block the page isolation in memcg changing. >=20 > Small nit, but the use of "could" in this sentence sounds like you're > describing one possible solution that isn't being taken, when in fact > you are describing the chosen locking mechanism. >=20 > Replacing "could" with "will" would make things a bit clearer IMO. >=20 Yes, 'will' is better here. Thanks! >> So now a standard steps of page isolation is following: >> 1, get_page(); #pin the page avoid to be free >> 2, TestClearPageLRU(); #block other isolation like memcg change >> 3, spin_lock on lru_lock; #serialize lru list access >> 4, delete page from lru list; >> The step 2 could be optimzed/replaced in scenarios which page is >> unlikely be accessed or be moved between memcgs. >=20 > This is a bit ominous. I'd either elaborate / provide an example / > clarify why some sites can deal with races - or just remove that > sentence altogether from this part of the changelog. >=20 A few scenarios here, so examples looks verbose or cann't describe whole. Maybe removing above 2 lines "The step 2 could be optimzed/replaced in=20 scenarios which page is unlikely be accessed or be moved between memcgs." is better.=20 Thanks! >> This patch start with the first part: TestClearPageLRU, which combines >> PageLRU check and ClearPageLRU into a macro func TestClearPageLRU. Thi= s >> function will be used as page isolation precondition to prevent other >> isolations some where else. Then there are may !PageLRU page on lru >> list, need to remove BUG() checking accordingly. >> >> There 2 rules for lru bit now: >> 1, the lru bit still indicate if a page on lru list, just in some >> temporary moment(isolating), the page may have no lru bit when >> it's on lru list. but the page still must be on lru list when the >> lru bit set. >> 2, have to remove lru bit before delete it from lru list. >> >> As Andrew Morton mentioned this change would dirty cacheline for page >> isn't on LRU. But the lost would be acceptable in Rong Chen >> report: >> https://lore.kernel.org/lkml/20200304090301.GB5972@shao2-debian/ >> >> Suggested-by: Johannes Weiner >> Signed-off-by: Alex Shi >> Acked-by: Hugh Dickins >> Cc: Hugh Dickins >> Cc: Johannes Weiner >> Cc: Michal Hocko >> Cc: Vladimir Davydov >> Cc: Andrew Morton >> Cc: linux-kernel@vger.kernel.org >> Cc: cgroups@vger.kernel.org >> Cc: linux-mm@kvack.org >=20 > Acked-by: Johannes Weiner >=20 Thanks! Alex