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.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 416D4CA9ECF for ; Fri, 1 Nov 2019 12:56:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D1E5208E3 for ; Fri, 1 Nov 2019 12:56:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D1E5208E3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A7ED86B0005; Fri, 1 Nov 2019 08:56:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A30696B0006; Fri, 1 Nov 2019 08:56:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 945DC6B0007; Fri, 1 Nov 2019 08:56:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 6D27E6B0005 for ; Fri, 1 Nov 2019 08:56:42 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 0393F181AEF1D for ; Fri, 1 Nov 2019 12:56:42 +0000 (UTC) X-FDA: 76107707802.13.cough41_27ff2272145 X-HE-Tag: cough41_27ff2272145 X-Filterd-Recvd-Size: 3818 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 Nov 2019 12:56:40 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 13DDC28D5EE3225D3617; Fri, 1 Nov 2019 20:56:36 +0800 (CST) Received: from [127.0.0.1] (10.133.219.218) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Fri, 1 Nov 2019 20:56:31 +0800 Message-ID: <5DBC2B7F.4090504@huawei.com> Date: Fri, 1 Nov 2019 20:56:31 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Michal Hocko CC: Johannes Weiner , Minchan Kim , , , Subject: Re: [PATCH] mm: fix unevictable page reclaim when calling madvise_pageout References: <1572275317-63910-1-git-send-email-zhongjiang@huawei.com> <20191029081102.GB31513@dhcp22.suse.cz> <5DB806D1.8020503@huawei.com> <20191029094039.GH31513@dhcp22.suse.cz> <5DB81838.6020208@huawei.com> <20191030165239.GA167773@google.com> <20191030174533.GL31513@dhcp22.suse.cz> <20191030193307.GA48128@cmpxchg.org> <20191031091601.GE13102@dhcp22.suse.cz> In-Reply-To: <20191031091601.GE13102@dhcp22.suse.cz> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.219.218] X-CFilter-Loop: Reflected 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: On 2019/10/31 17:16, Michal Hocko wrote: > On Wed 30-10-19 15:33:07, Johannes Weiner wrote: >> On Wed, Oct 30, 2019 at 06:45:33PM +0100, Michal Hocko wrote: >>> On Wed 30-10-19 09:52:39, Minchan Kim wrote: > [...] >>>> madvise_pageout could work with a shared page and one of the vmas among processes >>>> could do mlock so it could pass Unevictable LRU pages into shrink_page_list. >>>> It's pointless to try reclaim unevictable pages from the beginning so I want to fix >>>> madvise_pageout via introducing only_evictable flag into the API so that >>>> madvise_pageout uses it as "true". >>>> >>>> If we want to remove the PageUnevictable VM_BUG_ON_PAGE in shrink_page_list, >>>> I want to see more strong reason why it happens and why caller couldn't >>>> filter them out from the beginning. >>> Why is this preferable over removing the VM_BUG_ON condition? In other >>> words why should we keep PageUnevictable check there? >> The mlock LRU shuffling is a bit tricky and can race with page reclaim >> or others isolating the page from the LRU list. If another isolator >> wins, it has to move the page during putback on behalf of mlock. >> >> See the implementation and comments in __pagevec_lru_add_fn(). >> >> That's why page reclaim can see !page_evictable(), but it must not see >> pages that have the PageUnevictable lru bit already set. Because that >> would mean the isolation/putback machinery messed up somewhere and the >> page LRU state is corrupt. >> >> As that machinery is non-trivial, it's useful to have that sanity >> check in page reclaim. > Thanks for the clarification! This sounds reasonable (as much as the > mlock juggling does) to me. This is probably worth a comment right above > the bug_on. Could you write a comment down on VM_BUG_ON() ? :-) Thanks, zhong jiang > I have to confess that I am still not clear on all the details here, > though. E.g. migrate_misplaced_transhuge_page sets the flag without > lru_lock and relies only on page lock IIUC and the bug on is done right > after the lock is released. Maybe I am just confused or maybe the race > window is too small to matter but isn't this race possible at least > theoretically? >