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 2699DC5DF60 for ; Thu, 7 Nov 2019 13:31:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E33DD2178F for ; Thu, 7 Nov 2019 13:31:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E33DD2178F 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 424D26B0007; Thu, 7 Nov 2019 08:31:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D5BB6B0008; Thu, 7 Nov 2019 08:31:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EC286B000A; Thu, 7 Nov 2019 08:31:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 17B2D6B0007 for ; Thu, 7 Nov 2019 08:31:21 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id C28204DC9 for ; Thu, 7 Nov 2019 13:31:20 +0000 (UTC) X-FDA: 76129567920.30.dress58_459bcfbcd8719 X-HE-Tag: dress58_459bcfbcd8719 X-Filterd-Recvd-Size: 3864 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 13:31:18 +0000 (UTC) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C1DDF623035D7CB2497B; Thu, 7 Nov 2019 21:31:08 +0800 (CST) Received: from [127.0.0.1] (10.133.219.218) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Thu, 7 Nov 2019 21:31:04 +0800 Message-ID: <5DC41C98.7000400@huawei.com> Date: Thu, 7 Nov 2019 21:31:04 +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: Johannes Weiner CC: Michal Hocko , , , Subject: Re: [PATCH v3] mm: fix trying to reclaim unevictable lru page when calling madvise_pageout References: <1572616245-18946-1-git-send-email-zhongjiang@huawei.com> <20191101183220.GC29196@dhcp22.suse.cz> <5DBD3217.4070403@huawei.com> <20191105063353.GE22672@dhcp22.suse.cz> <5DC16B0A.6070605@huawei.com> <20191105124549.GN22672@dhcp22.suse.cz> <5DC182DD.5010304@huawei.com> <20191105184811.GA44848@cmpxchg.org> In-Reply-To: <20191105184811.GA44848@cmpxchg.org> 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/11/6 2:48, Johannes Weiner wrote: > On Tue, Nov 05, 2019 at 10:10:37PM +0800, zhong jiang wrote: >> On 2019/11/5 20:45, Michal Hocko wrote: >>> On Tue 05-11-19 20:28:58, zhong jiang wrote: >>>> On 2019/11/5 14:33, Michal Hocko wrote: >>>>> On Sat 02-11-19 15:36:55, zhong jiang wrote: >>>>>> On 2019/11/2 2:32, Michal Hocko wrote: >>>>> [...] >>>>>>> But I would really appreciate to add a comment for the BUG_ON and >>>>>>> explain why do we care about PageUnevictable so much when there is an >>>>>>> explicit page_evictable check in the reclaim path. In other words a >>>>>>> short summary of what Johannes explained in >>>>>>> http://lkml.kernel.org/r/20191030193307.GA48128@cmpxchg.org. Maybe in a >>>>>>> separate patch. Care to send one or should I send it? >>>>>> Hi, Michal >>>>>> >>>>>> Actually, I am not very clear about the words Johannes had said. How the race to >>>>>> tirgger, it will result in an PgeMlocked page can be visible in shrink_page_list. >>>>>> >>>>>> Could you elaborate the race in detail further ? >>>>> I would go with the following comment >>>>> >>>>> /* >>>>> * Page reclaim can see !page_evictable(), but it must not see pages that >>>>> * have the PageUnevictable lru bit already set. See __pagevec_lru_add_fn() >>>>> * for more details. >>>>> */ >>>> But the detail still confuses me in __pagevec_lru_add_fn() to see PageMlocked in vmscan :-\ . >>> Which part does confuse you exactly? >> page reclaim can see !page_evictable() means some race still exist in the kernel. Is there any race window . > Yes. mlock does this: > > lock_page() > SetPageMlocked() > if (isolate_lru_page()) > putback_lru_page() // move to unevictable list > unlock_page() > > and vmscan does this: > > isolate_lru_pages() > for_each_page() > if (!try_lock_page()) > continue > if (!page_evictable()) > continue > putback_lru_pages() > > It's possible that mlock locks the page and sets PG_mlocked, but > vmscan has the page already isolated and mlock cannot move it to the > unevictable list itself. In that case, vmscan will either fail to lock > the page or see !page_unevictable() and move the page on the > unevictable list on behalf of mlock. Thanks for you kindly clarification. Sincerely, zhong jiang > . >