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=DKIM_SIGNED,DKIM_VALID, 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 82D61C5DF60 for ; Tue, 5 Nov 2019 18:48:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C70E21925 for ; Tue, 5 Nov 2019 18:48:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="FpW8wuVR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C70E21925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 87A8D6B0003; Tue, 5 Nov 2019 13:48:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82B1C6B0005; Tue, 5 Nov 2019 13:48:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 719DD6B0006; Tue, 5 Nov 2019 13:48:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 5A9D46B0003 for ; Tue, 5 Nov 2019 13:48:15 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0BE28824999B for ; Tue, 5 Nov 2019 18:48:15 +0000 (UTC) X-FDA: 76123108950.01.coast23_650de1494ed15 X-HE-Tag: coast23_650de1494ed15 X-Filterd-Recvd-Size: 5407 Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Nov 2019 18:48:14 +0000 (UTC) Received: by mail-qv1-f67.google.com with SMTP id cg2so340961qvb.10 for ; Tue, 05 Nov 2019 10:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EK535/X9iVvlqE/GEgY4ysttoeXNNv5V/p9RxihwG34=; b=FpW8wuVRh6SkkNp7lYq0s8agfTDbi5R3asfixKoZwmY8kDw/tTuhEAFhYGFxKLl1Bs teTv1oJovzin9dhGcBxFZU0cN5PzqednmySW0GxEwqJ563RX+Z4RlPnK8n0rfdVibJUp fG+o71SwA8u6MoHqHRiy19Rc0D7bgPjN2+jmj+Y/m3kiGrVJuNZc2XJbWJJD6k/gICK6 ATTrh9rTViXy8DJARujYMQjaFnUrVHt+WwBntI/rc/QJtURKWtOlp0s7tvdhvMr7JRe3 yO2+utTRkVyvxMogl1mkSYSborzi0c6I/9V6RcOKwNGJoA8Gulgc0ib6iARJ8BBict3Z Dv2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EK535/X9iVvlqE/GEgY4ysttoeXNNv5V/p9RxihwG34=; b=oPtW/pFBtHlQ/aqf8m+xKy/+Ou0v8n98sgIKDnmLpA3QSOtByRd6NbpqTzp+6un5/S Dek0leJ+qP21bLSkDMDaGQPY2zoHlkKCcqS9Did2PEH3jqZuHpb853R6GG/NBeOZHHE0 HJLNMY1fmXJVH/1kD7nlY+ix/P5FK4wGnACduLRsrrRXJPUB1A+Uwm6nLFwLaqxD/jPf GAu5jWli/8CwCgktnjTc3IFwxCcYTAj6dY5wGjlUAHGE+FtUDDjRmUlJ+hWN7HSlsw3v nCD+HrXQn4rRZ17CnLxj6YqhEMCe7MPPW7YvDSFxFVqktIcz1LV465ktfB3xdZpKWcGc zz5A== X-Gm-Message-State: APjAAAVyKL1ZjqCXz2Ooblzq2GKyYJItYgEfiNjADhjk8ri3bYZ91oNW NsXpztzm8EzqgIIjnxknRrO+jg== X-Google-Smtp-Source: APXvYqwN1ZlJwKtNhOKcDPxbP5GN4yt9RcEbnudlIYMaLty1o5k4quKPCVqKQeH+WFA4ktUjDHkKIA== X-Received: by 2002:a0c:c58c:: with SMTP id a12mr29010942qvj.235.1572979693256; Tue, 05 Nov 2019 10:48:13 -0800 (PST) Received: from localhost ([2620:10d:c091:500::5685]) by smtp.gmail.com with ESMTPSA id w26sm9944468qkf.59.2019.11.05.10.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 10:48:12 -0800 (PST) Date: Tue, 5 Nov 2019 13:48:11 -0500 From: Johannes Weiner To: zhong jiang Cc: Michal Hocko , akpm@linux-foundation.org, minchan@kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3] mm: fix trying to reclaim unevictable lru page when calling madvise_pageout Message-ID: <20191105184811.GA44848@cmpxchg.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5DC182DD.5010304@huawei.com> User-Agent: Mutt/1.12.2 (2019-09-21) 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 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.