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=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FSL_HELO_FAKE,INCLUDES_PATCH,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 4272ACA9EC6 for ; Wed, 30 Oct 2019 18:39:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 055DA20856 for ; Wed, 30 Oct 2019 18:39:29 +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="PR0kQ0ex" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 055DA20856 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 96CAE6B0005; Wed, 30 Oct 2019 14:39:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9209C6B0007; Wed, 30 Oct 2019 14:39:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80B3B6B0008; Wed, 30 Oct 2019 14:39:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 5A2AE6B0005 for ; Wed, 30 Oct 2019 14:39:29 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 06CBE4DAB for ; Wed, 30 Oct 2019 18:39:29 +0000 (UTC) X-FDA: 76101314058.02.goat51_6fd5b01ad2b1d X-HE-Tag: goat51_6fd5b01ad2b1d X-Filterd-Recvd-Size: 5701 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 18:39:28 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id p1so2054707pgi.4 for ; Wed, 30 Oct 2019 11:39:28 -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=VmzHhe1HvCAmqvP0CHLhxtq1q/ejvQeAUwxN342CwKs=; b=PR0kQ0ex8F6kWJAc+3dF+ygGjFwjMcAwYkXUe1oLCCUqpZBRTq2/xNVWtG+OufFiCJ zUIlNhG0/Hn68jGx0FfyOdwQRQTh+6Eq1CENDFC8xqLVrHLM/i2VmMDV/40vtcrcmjET 5F4q52+d+luAFhGBfOiqEM8r6z4sto2JbTB33TsyKnNArk0CvE0II1OGajapuqUjSKsO MabsR4zsOTVJxusd2TxH3kzkIOfH2Y9My/kz/M/6z63LbaF9KQnYqO4Uj4DdwMTGon1n 8TW6/mq3uE45xR9NKnviMXS9y0lWU0FfFiJNh9qDznyuWylWMIk/E8DpiZkb9aC03LnD AxSQ== 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=VmzHhe1HvCAmqvP0CHLhxtq1q/ejvQeAUwxN342CwKs=; b=oRT5yTyz9MXGG4tbMyojQgHni77YelYVB0SY3tSyrJoduxDXNA8PHo5/MK9fGnQDhM 7xcRS1uZ7HbUPsCqoVyT9Q2lacI/nm5+I/+BigKRZFavyDzNd64XF2K6jwjmUdxf6Pcz ROuqjHwU2p3dGjA3d7ebEUuExshA75V3TroLk7Fe7SfOYMU1Fzfi9T4mt+CrVhKXDfOv k8IzNSrVoeNHJpabRn3C6rOAx554SM7ktLhF1TUTmMuTBWwvjtB7NMiwiaRtResW/3hh ikVpgF3dMD/nCWyeaxKFczoTpVJgc+s3l56DYtBEsPQn0xxgtwQD3tWNogI1qhqCKA3T xT1Q== X-Gm-Message-State: APjAAAV36ODKEmTdlxBmvk18cXAYob9ZEfmVNs5v1h6/2590jFozPxib aoUKOSWnyl6AlUl08YH6ty4= X-Google-Smtp-Source: APXvYqzF0EnoSUw8na9AR05x5aGVV7fWF9Hi5WqZV2aNI8HCXurP49HnrLWbSDvWfzankF2nmdzkPg== X-Received: by 2002:a63:af13:: with SMTP id w19mr878521pge.189.1572460767284; Wed, 30 Oct 2019 11:39:27 -0700 (PDT) Received: from google.com ([2620:15c:211:1:3e01:2939:5992:52da]) by smtp.gmail.com with ESMTPSA id l93sm4070937pjb.6.2019.10.30.11.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2019 11:39:26 -0700 (PDT) Date: Wed, 30 Oct 2019 11:39:24 -0700 From: Minchan Kim To: Johannes Weiner 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: <20191030183924.GA57267@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> <20191030172241.GA43851@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191030172241.GA43851@cmpxchg.org> 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 Wed, Oct 30, 2019 at 01:22:41PM -0400, Johannes Weiner wrote: > 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. Totally, agree. > > 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); > } >