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=-20.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 993BEC636C9 for ; Sun, 18 Jul 2021 00:58:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 20A3861026 for ; Sun, 18 Jul 2021 00:58:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20A3861026 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8A8BB8D00F4; Sat, 17 Jul 2021 20:58:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 831E88D00EC; Sat, 17 Jul 2021 20:58:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 684068D00F4; Sat, 17 Jul 2021 20:58:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 3AC048D00EC for ; Sat, 17 Jul 2021 20:58:44 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C9AC98249980 for ; Sun, 18 Jul 2021 00:58:42 +0000 (UTC) X-FDA: 78373898484.24.ADD2D3B Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf09.hostedemail.com (Postfix) with ESMTP id 7F9223000101 for ; Sun, 18 Jul 2021 00:58:42 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id g16so16688944wrw.5 for ; Sat, 17 Jul 2021 17:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IA0iZ0YYbuCRj3GBzM3NX6nkYFwGN36XHJ5e0gOj12U=; b=ZZcDpOJ3Ztr2fyM+F61/AotgaxjLBhxL6tTLwGdlzrp8Mu5avhQB2ZGervleIX1Ig2 yXSQz7bc3n2DFPQ7cRRCQZ7Jqpa392yBl6nO77iE1s1jxZEsUSyOLvQC+BgWSDRxAObN K8kIg8cp0ctNOS10rvs+b7NtQeFzVKQp8m94VLnciVg9tPdHrT0zlJDsQmf4CDlfPHpi Dudc9XYZNqPpNdxh3qNv5ev/94a7VuyRmaHkpjVt+A79vFuUVqq3S+5rWsO+6CXdxUWX dz/Tar4kuxxByT5SxRdbuzqr/kDGsU8IRxCxHeqKkDTsTwxn0EW/L2azcTzX/uD1aXdE P55g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IA0iZ0YYbuCRj3GBzM3NX6nkYFwGN36XHJ5e0gOj12U=; b=coLaoKi16RBHz81GdKbDCIz4RaHjIuuOS5W9mysHyVQLJfCWOJVVYJG4jKmavsk/jS m9mOy+u8C/BaZUAPxP9U8FvyT7DMohIuoh/CcGhsW3h87iU8+uVBfgKVHTvpXKnsqEK4 SBR2Zh5qJUgXNGoCv7CsGkewXw4dn3uzgYJ9LMm2Q5LmXbOY0DDJgnh311mHFL2VW7Ji otmjQ+wpVyE6lCHGBjo/5IQ32Q14fjtxzc2yi3BjUEGk0Ahyj5kGIG64zzeGxagf6Mo9 r2ZS4AyyN0GMPA/wJu0TxRdK5PrJVoPgGkpj6ZNoQBHwPZErqQTmztl0fubGRxTnZYub yRzg== X-Gm-Message-State: AOAM530x8YJzyh9RfpabC/9/H6E8mo4xFM6q9EHBTTQdajq8f6wVO+O7 Gv4uLj9wfx4nCm0zTS8DZ9Tvqlfz8c9sbPssqgedpQ== X-Google-Smtp-Source: ABdhPJxUJaVdD3k6z8/qMTL7awGKwF5hwoqY8eBPYLeTzdHcVI5Jh/K/+1xIINl4Nx1K4D7wJ5llE/zYcvdsvf6kfCg= X-Received: by 2002:adf:f710:: with SMTP id r16mr21650431wrp.124.1626569921012; Sat, 17 Jul 2021 17:58:41 -0700 (PDT) MIME-Version: 1.0 References: <20210717065911.61497-1-linmiaohe@huawei.com> <20210717065911.61497-2-linmiaohe@huawei.com> In-Reply-To: <20210717065911.61497-2-linmiaohe@huawei.com> From: Yu Zhao Date: Sat, 17 Jul 2021 18:58:29 -0600 Message-ID: Subject: Re: [PATCH v2 1/4] mm/vmscan: remove the PageDirty check after MADV_FREE pages are page_ref_freezed To: Miaohe Lin Cc: Andrew Morton , Johannes Weiner , Vlastimil Babka , Michal Hocko , Jens Axboe , Joonsoo Kim , Alex Shi , apopple@nvidia.com, Matthew Wilcox , Minchan Kim , David Hildenbrand , shli@fb.com, hillf.zj@alibaba-inc.com, John Hubbard , Linux-MM , linux-kernel Content-Type: multipart/alternative; boundary="000000000000591db605c75b52d2" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7F9223000101 X-Stat-Signature: pwpnd6bowy3h6ua9uqamqfhs5t9zubjo Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=ZZcDpOJ3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of yuzhao@google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=yuzhao@google.com X-HE-Tag: 1626569922-419018 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: --000000000000591db605c75b52d2 Content-Type: text/plain; charset="UTF-8" On Sat, Jul 17, 2021 at 12:59 AM Miaohe Lin wrote: > If the MADV_FREE pages are redirtied before they could be reclaimed, > put the pages back to anonymous LRU list by setting SwapBacked flag > and the pages will be reclaimed in normal swapout way. But as Yu Zhao > pointed out, "The page has only one reference left, which is from the > isolation. After the caller puts the page back on lru and drops the > reference, the page will be freed anyway. It doesn't matter which lru > it goes." So we don't bother checking PageDirty here. > > [Yu Zhao's comment is also quoted in the code.] > > Signed-off-by: Miaohe Lin > Reviewed-by: Yu Zhao > --- > mm/vmscan.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index a7602f71ec04..92a515e82b1b 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1627,11 +1627,14 @@ static unsigned int shrink_page_list(struct > list_head *page_list, > /* follow __remove_mapping for reference */ > if (!page_ref_freeze(page, 1)) > goto keep_locked; > - if (PageDirty(page)) { > - page_ref_unfreeze(page, 1); > - goto keep_locked; > - } > - > + /* > + * The page has only one reference left, which is > + * from the isolation. After the caller puts the > + * page back on lru and drops the reference, the > + * page will be freed anyway. It doesn't matter > + * which lru it goes. So we don't bother checking > + * PageDirty here. > + */ > count_vm_event(PGLAZYFREED); > count_memcg_page_event(page, PGLAZYFREED); > } else if (!mapping || !__remove_mapping(mapping, page, > true, > -- > 2.23.0 > > --000000000000591db605c75b52d2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Jul 17, 2021 at 12:59 AM Miao= he Lin <linmiaohe@huawei.com= > wrote:
If t= he MADV_FREE pages are redirtied before they could be reclaimed,
put the pages back to anonymous LRU list by setting SwapBacked flag
and the pages will be reclaimed in normal swapout way. But as Yu Zhao
pointed out, "The page has only one reference left, which is from the<= br> isolation. After the caller puts the page back on lru and drops the
reference, the page will be freed anyway. It doesn't matter which lru it goes." So we don't bother checking PageDirty here.

[Yu Zhao's comment is also quoted in the code.]

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Yu Zhao <yuzhao@goo= gle.com>
=C2=A0
---
=C2=A0mm/vmscan.c | 13 ++++++++-----
=C2=A01 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a7602f71ec04..92a515e82b1b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1627,11 +1627,14 @@ static unsigned int shrink_page_list(struct list_he= ad *page_list,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 /* follow __remove_mapping for reference */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if (!page_ref_freeze(page, 1))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto keep_locked;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (PageDirty(page)) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0page_ref_unfreeze(page, 1);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto keep_locked;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0}
-
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0/*
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * The page has only one reference left, which is
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * from the isolation. After the caller puts the
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * page back on lru and drops the reference, the
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * page will be freed anyway. It doesn't matter
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * which lru it goes. So we don't bother checking
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 * PageDirty here.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 count_vm_event(PGLAZYFREED);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 count_memcg_page_event(page, PGLAZYFREED);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else if (!mapping= || !__remove_mapping(mapping, page, true,
--
2.23.0

--000000000000591db605c75b52d2--