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=-0.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FSL_HELO_FAKE,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 1B934CA9ECB for ; Thu, 31 Oct 2019 14:48:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D03F62086D for ; Thu, 31 Oct 2019 14:48:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b8XVcfoR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D03F62086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4C7D06B0272; Thu, 31 Oct 2019 10:48:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 478B76B0273; Thu, 31 Oct 2019 10:48:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38E7E6B0274; Thu, 31 Oct 2019 10:48:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id 192AB6B0272 for ; Thu, 31 Oct 2019 10:48:16 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D039663F4 for ; Thu, 31 Oct 2019 14:48:15 +0000 (UTC) X-FDA: 76104360150.18.bone78_2af99fa22224f X-HE-Tag: bone78_2af99fa22224f X-Filterd-Recvd-Size: 5756 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 31 Oct 2019 14:48:15 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id r1so4179379pgj.12 for ; Thu, 31 Oct 2019 07:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=u0039esDx7atF2piPvwuyQYcjVxabdDXLnlzzaXTH/Y=; b=b8XVcfoRIc1MyQhad1vqo4UydQ8DEA5q3kpiwpGyexzVigUsuAeIRMoNhaAnhu84km P6ikfpIN0BRlL9Roq5HEh8chDUzbm+OCvXt6cj7btt/bGzg7rSMKfwKZLG1Ib4KzU7yS XBEuat7SyeAhD7jIG/CEYLRUBrgJcPkypResS/DBDUDb3sIXLOm8U6TSPl/Tp5waJ3bq ipUsLL+Uxd+X7Q9Dwk122DY5UMlmO4Qo5UhrUpZ7a3mEmShMG++IXRvjmwFoWEexuB/v 9MNBaj4o3l0dP+1NzKtrVdlAip8vRaxSwWjqpVrbLIqV5o3haGRbX6N8bjVoiyIv12JQ UtFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=u0039esDx7atF2piPvwuyQYcjVxabdDXLnlzzaXTH/Y=; b=LUxhkYTbzBQXexWTL6vWJDtxc5L0nPqXtMhh4zFfF8jsYQD0QEXtBpXeNXNaHqF5tl wAlfet8K8OdQ/RUl/dKlwJyW7cto8cikdwiQxMtx5BvVfyqTsk3P4/ju9zG0zA2NgcR3 W6j+zaXqx2IUvDW8+8U85PjuoeW84JIPTjdBQkQW7SV9TPrwo35sRlkjgPr7WwmwrDdI cTz8xa3c39g+KJpOLwkfNyKNSDLrdM3JQkyIgCoL/sCl3XeeAZ9KE8yMeDstv6wMXgEO /ACFOS04FNz9Ao4uVrkKnhGNgp/25zpskHu2P9xdgGDnQeI6QVte4YUCmhFe8RDjg69O JOHw== X-Gm-Message-State: APjAAAUYQTBvfghWvkMfdM2B27BpxsHu6HNgNyH2830+P4q0Nky6vyvl 3G7KlpU9GjELO0qiXYk/e98= X-Google-Smtp-Source: APXvYqyB/5qm/lmDVey/OnRql7jWzAvbTWBd7k9MLkHtEcv4lCj+lC3r0Y2aPy5O9HXasaIqjsutxg== X-Received: by 2002:a17:90a:a882:: with SMTP id h2mr8006863pjq.1.1572533294034; Thu, 31 Oct 2019 07:48:14 -0700 (PDT) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id q185sm6964689pfc.153.2019.10.31.07.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 07:48:12 -0700 (PDT) Date: Thu, 31 Oct 2019 07:48:11 -0700 From: Minchan Kim To: Michal Hocko Cc: Johannes Weiner , zhong jiang , akpm@linux-foundation.org, ktkhai@virtuozzo.com, linux-mm@kvack.org Subject: Re: [PATCH] mm: fix unevictable page reclaim when calling madvise_pageout Message-ID: <20191031144811.GB128849@google.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191031091601.GE13102@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Thu, Oct 31, 2019 at 10:16:01AM +0100, 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. > > 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? IIUC, reclaim couldn't see the page from LRU list because it was isolated by numamigrate_isolate_page. Thanks.