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=-5.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 CD7BFCA9EC5 for ; Wed, 30 Oct 2019 17:22:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 826382173E for ; Wed, 30 Oct 2019 17:22:46 +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="L8B6+98X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 826382173E 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 005966B0003; Wed, 30 Oct 2019 13:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF80D6B0007; Wed, 30 Oct 2019 13:22:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE67B6B0008; Wed, 30 Oct 2019 13:22:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id BC7CB6B0003 for ; Wed, 30 Oct 2019 13:22:45 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 5E1DB181AEF3E for ; Wed, 30 Oct 2019 17:22:45 +0000 (UTC) X-FDA: 76101120690.09.rings40_17fc76993b453 X-HE-Tag: rings40_17fc76993b453 X-Filterd-Recvd-Size: 5441 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 17:22:44 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id o3so4268584qtj.8 for ; Wed, 30 Oct 2019 10:22:44 -0700 (PDT) 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=6HPqGITpxjMWkJnKmaAmybBy11QrfTGB7c8FBCQpYjM=; b=L8B6+98X0lGcytZHA97llfBOs0mToK36vTMRkBnCr7uvCb3NF+5kpd0XcVpNbQ6Qdf W5Vk/wYDv8EmqIRPsuVW8ytFufsVUbQvZWgEb6QwLMotNU9H0Bx6ABxENlCrPZ+12HCV ltklDt49LBHw3HW5HHuCYUh+5+ied7Jv+6Z83f6ywGZImuwnhi7ldG75jZil3cCa+SBo OeMgt7JuK38hIequ5rlLEWzrfB4grmzKY7zRiacqeCEGKB4j2snPNZvmhpj4yrvmAhP7 ywaMaZYU0xkeXgNM4HGXRVmrFNA0MOvRIAaakz4xdnYiO4y2PeG6Wg9YiZrWUvKzkPKO AIAA== 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=6HPqGITpxjMWkJnKmaAmybBy11QrfTGB7c8FBCQpYjM=; b=NIhzracnUzi2S+P+mS/p/PgmXHr+doODqLe+TT73N/rRwAsSTsFD8x92rxwx8erK/7 dhjMldfUJHAjZRBemde6nPxh6E8WOXGopJRFtv+SEcW9qKmZy+HnRGeJvksH0yzJfLZx VJaFyt4J0iPjnNBM36OS5efsxotiIxTOqUyqFIORLADdl+O1fbfLvHUI1ynMiCNyqT02 9t1qjeZ+EhcB/MrEZfKEYKfLYKFhT5ET56sagXtHGqhaHfyvJULrU4fricXdgEevIDDq kdDn/g74fphiPYGwgOl8479Q7OsMt0a0ubN8Sog4sIHQPAVrvWY6oCYmeRheBfhat/KN jOMw== X-Gm-Message-State: APjAAAVZf/p5QnAx6sEbSnagFVQKllq6nTJAnmkXHaROokeFk3RSpi1+ lOs1cKmOv3FZQcUfVkPQFnSCNg== X-Google-Smtp-Source: APXvYqzKTt9wPAR50Z7MKP1rdzLHUfm6Ykl1mZ0PCQt+CObWjXrNwrU+d+qPLPozPItw9jm3uRMLww== X-Received: by 2002:ac8:7188:: with SMTP id w8mr1188805qto.211.1572456163575; Wed, 30 Oct 2019 10:22:43 -0700 (PDT) Received: from localhost (pool-108-27-252-85.nycmny.fios.verizon.net. [108.27.252.85]) by smtp.gmail.com with ESMTPSA id x10sm624396qtj.25.2019.10.30.10.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2019 10:22:42 -0700 (PDT) Date: Wed, 30 Oct 2019 13:22:41 -0400 From: Johannes Weiner To: Minchan Kim Cc: zhong jiang , Michal Hocko , 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: <20191030172241.GA43851@cmpxchg.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191030165239.GA167773@google.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 Wed, Oct 30, 2019 at 09:52:39AM -0700, Minchan Kim wrote: > @@ -1468,7 +1468,7 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, > drain_allow = false; > } > > - if (!isolate_lru_page(head)) { > + if (!isolate_lru_page(head, false)) { > list_add_tail(&head->lru, &cma_page_list); > mod_node_page_state(page_pgdat(head), > NR_ISOLATED_ANON + It's not clear what that argument means at the callsite, and every caller needs to pass it to support one niche usecase. Let's not do that. I think there are better options. Personally, I think it's a good idea to keep the sanity check in shrink_page_list() because the mlock LRU handling is quite tricky. madvise() is really the odd one out here because it isolates LRU pages through page tables and then sends them through the regular reclaim path, so IMO it should be the madvise proper that handles the exceptional situation. Why not just this? Maybe with a comment that points out that we're coming from the page tables instead of a specific LRU list, and so need to filter out the unevictable lru pages from our end. diff --git a/mm/madvise.c b/mm/madvise.c index 99dd06fecfa9..63e130800570 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -363,8 +363,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) { - if (!isolate_lru_page(page)) - list_add(&page->lru, &page_list); + if (!isolate_lru_page(page)) { + if (PageUnevictable(page)) + putback_lru_page(page); + else + list_add(&page->lru, &page_list); + } } else deactivate_page(page); huge_unlock: @@ -441,8 +445,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) { - if (!isolate_lru_page(page)) - list_add(&page->lru, &page_list); + if (!isolate_lru_page(page)) { + if (PageUnevictable(page)) + putback_lru_page(page); + else + list_add(&page->lru, &page_list); + } } else deactivate_page(page); }