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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 6EEE2C07E96 for ; Tue, 13 Jul 2021 07:25:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EF4F6120A for ; Tue, 13 Jul 2021 07:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234172AbhGMH2n (ORCPT ); Tue, 13 Jul 2021 03:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233762AbhGMH2l (ORCPT ); Tue, 13 Jul 2021 03:28:41 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3259EC0613DD for ; Tue, 13 Jul 2021 00:25:52 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso1110883wmc.1 for ; Tue, 13 Jul 2021 00:25:52 -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=kLualirFuyhQUpkaVrxmK4ztlGCjktHhBFIVEYAPxQA=; b=B6JoVQ10aBH7JgQIPgclYZz/ClgL8rZS6NnNn0MJJx5542fP+YvEhJuBp8gX/OHzYU tAHBSrs6ehVkF3aAzxUi6wpTooE7i8UFm+tQHDs1Zryv9LO03qAxRUmcw/PEYkwhhfdV CPUC4th7fTEU0KrX1cHvPwSPA5HuBPyPTB/2J6P3RhK3Rtbypp1OsSnCYXFFkGZRcmWj /5Ed+1GtccitTvrmqzkYKIkSNCElk90Vtsp/vMdMLAOrlgN9jcWyqixQrXGtK4JkPMuI DfY9I0JvR5DF68cEGRNMakc3C63my1ooWqTEP04pLx52uZr6HRsxbM42Hr0KTmasB7+0 +jRw== 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=kLualirFuyhQUpkaVrxmK4ztlGCjktHhBFIVEYAPxQA=; b=J9x008jtgaeuVItdnzwze5/DTblmA4qqVy/xjg0A83kKAo3t7o1lsA7DplLGJPNV2L XqTQb83dA+p/ncV+/+TrqLnQl7CkilMt/03Ki8wWA5U6hH6q9B9z0004kVi5xXKHFJ3W 3aeH9o8/Q9j5jCCvV3RjoudMQ/spufUbbeka3TJRwRCMJ09BMqlrj9igNfeUNoHy9cl2 keN/6dn+r7j8wm9KkIyEE75cHFy217UsKL+3aX10YhWM91/CKBPe2hBJcdknDtueg6xK +lBjjVIy2j4wxMWKz8ObJLB4biJ54FX2pWSt/RbQQyRLFvudwxV3bXxx0Gvu3mB0a4Fl Ulbg== X-Gm-Message-State: AOAM532/HSTfTGplnTy3R/N3RaqgeMdNx2bt8m7qH4v9NrVaD6bLrBSE VSWESg83c3Q551zGuvKaVadxXh53+mSF9ZHGCvBjTw== X-Google-Smtp-Source: ABdhPJy7wtIfW5cpn6NEXGfuHWRX0BJTvr5N+bXGIcHsnRGt8TIWuqQu2RmlLybXvnHW9/zzVKVV0WmKkaGbrEsQM+E= X-Received: by 2002:a05:600c:2197:: with SMTP id e23mr3397905wme.101.1626161150645; Tue, 13 Jul 2021 00:25:50 -0700 (PDT) MIME-Version: 1.0 References: <20210710100329.49174-1-linmiaohe@huawei.com> <20210710100329.49174-2-linmiaohe@huawei.com> <022f2f7c-fc03-182a-1f8f-4b77c0731d4f@huawei.com> In-Reply-To: <022f2f7c-fc03-182a-1f8f-4b77c0731d4f@huawei.com> From: Yu Zhao Date: Tue, 13 Jul 2021 01:25:39 -0600 Message-ID: Subject: Re: [PATCH 1/5] mm/vmscan: put the redirtied MADV_FREE pages back to anonymous LRU list 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, Linux-MM , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 12, 2021 at 1:12 AM Miaohe Lin wrote: > > On 2021/7/11 7:22, Yu Zhao wrote: > > On Sat, Jul 10, 2021 at 4:03 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. Otherwise MADV_FREE pages > >> won't be reclaimed as expected. > >> > >> Fixes: 802a3a92ad7a ("mm: reclaim MADV_FREE pages") > > > > This is not a bug -- the dirty check isn't needed but it was copied > > from __remove_mapping(). > > Yes, this is not a bug and harmless. When we reach here, page should not be > dirtied because PageDirty is handled above and there is no way to redirty it > again as pagetable references are all gone and it's not in the swap cache. > > > > > 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. > > But it looks buggy as it didn't perform the expected ops from code view. > Should I drop the Fixes tag and send a v2 version? I don't understand the logic here -- it looks pretty obvious to me that, if we want to change anything, we should delete the dirty check, not add another line that would enforce the belief that the dirty check is needed. > > Many thanks for reply! > > > > >> Signed-off-by: Miaohe Lin > >> --- > >> mm/vmscan.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/mm/vmscan.c b/mm/vmscan.c > >> index a7602f71ec04..6483fe0e2065 100644 > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > >> @@ -1628,6 +1628,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, > >> if (!page_ref_freeze(page, 1)) > >> goto keep_locked; > >> if (PageDirty(page)) { > >> + SetPageSwapBacked(page); > >> page_ref_unfreeze(page, 1); > >> goto keep_locked; > >> } > >> -- > >> 2.23.0 > >> > >> > > . > > > 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 DC8FAC07E95 for ; Tue, 13 Jul 2021 07:25:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 847E260E0B for ; Tue, 13 Jul 2021 07:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 847E260E0B 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 B04FD8D0001; Tue, 13 Jul 2021 03:25:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB5696B0096; Tue, 13 Jul 2021 03:25:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 955B88D0001; Tue, 13 Jul 2021 03:25:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 6C4C86B0095 for ; Tue, 13 Jul 2021 03:25:53 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4EACF184D4162 for ; Tue, 13 Jul 2021 07:25:52 +0000 (UTC) X-FDA: 78356730144.21.C7F7D28 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf27.hostedemail.com (Postfix) with ESMTP id 129FD70000A6 for ; Tue, 13 Jul 2021 07:25:51 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id j34so12925077wms.5 for ; Tue, 13 Jul 2021 00:25:51 -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=kLualirFuyhQUpkaVrxmK4ztlGCjktHhBFIVEYAPxQA=; b=B6JoVQ10aBH7JgQIPgclYZz/ClgL8rZS6NnNn0MJJx5542fP+YvEhJuBp8gX/OHzYU tAHBSrs6ehVkF3aAzxUi6wpTooE7i8UFm+tQHDs1Zryv9LO03qAxRUmcw/PEYkwhhfdV CPUC4th7fTEU0KrX1cHvPwSPA5HuBPyPTB/2J6P3RhK3Rtbypp1OsSnCYXFFkGZRcmWj /5Ed+1GtccitTvrmqzkYKIkSNCElk90Vtsp/vMdMLAOrlgN9jcWyqixQrXGtK4JkPMuI DfY9I0JvR5DF68cEGRNMakc3C63my1ooWqTEP04pLx52uZr6HRsxbM42Hr0KTmasB7+0 +jRw== 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=kLualirFuyhQUpkaVrxmK4ztlGCjktHhBFIVEYAPxQA=; b=XAaGjMJsUmJLKC2uZhtopO3XqdtWvtBx3NHgve15vjGvSX+t/WOI9Zf/CkMsxBTb2J 9d8k9i84vtrD5K1Em7pw2Ahz9AULMwLay7CU4aQNyVBN7glOdK9wXUAGy7fQsyqjpjgS Ve7cO14UxwMJCt3+1D31mtr0ysaRvIs3yjWS0+6Lc9VDq+Pms+CYcOT5j1drSxZx8fmH +NNn3y4T36wAq/6FMT44V6lqwogEC6wED5MmIHGYpIway8koUJq1HzLpzxHVj4NQHTMZ o3jFjUgVdjEGkY0R46Uu0Rg6VCQFT7xh949+AjKWklVLyQUF34d+Cxf/TpSD3mpB1wLZ G24w== X-Gm-Message-State: AOAM533DExdNYz0Xyiu4QtqQqlWM5lOs9NMXLKlOAMOnxV3LU0WIh9Io 2jb54KwfgiCmBnxOiolECN5u37H1o1vd7+K1Lmqe2Q== X-Google-Smtp-Source: ABdhPJy7wtIfW5cpn6NEXGfuHWRX0BJTvr5N+bXGIcHsnRGt8TIWuqQu2RmlLybXvnHW9/zzVKVV0WmKkaGbrEsQM+E= X-Received: by 2002:a05:600c:2197:: with SMTP id e23mr3397905wme.101.1626161150645; Tue, 13 Jul 2021 00:25:50 -0700 (PDT) MIME-Version: 1.0 References: <20210710100329.49174-1-linmiaohe@huawei.com> <20210710100329.49174-2-linmiaohe@huawei.com> <022f2f7c-fc03-182a-1f8f-4b77c0731d4f@huawei.com> In-Reply-To: <022f2f7c-fc03-182a-1f8f-4b77c0731d4f@huawei.com> From: Yu Zhao Date: Tue, 13 Jul 2021 01:25:39 -0600 Message-ID: Subject: Re: [PATCH 1/5] mm/vmscan: put the redirtied MADV_FREE pages back to anonymous LRU list 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, Linux-MM , linux-kernel Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=B6JoVQ10; spf=pass (imf27.hostedemail.com: domain of yuzhao@google.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: e5ui8ypmkiw6s5c78sm9o8496p7opw7h X-Rspamd-Queue-Id: 129FD70000A6 X-Rspamd-Server: rspam01 X-HE-Tag: 1626161151-608397 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 Mon, Jul 12, 2021 at 1:12 AM Miaohe Lin wrote: > > On 2021/7/11 7:22, Yu Zhao wrote: > > On Sat, Jul 10, 2021 at 4:03 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. Otherwise MADV_FREE pages > >> won't be reclaimed as expected. > >> > >> Fixes: 802a3a92ad7a ("mm: reclaim MADV_FREE pages") > > > > This is not a bug -- the dirty check isn't needed but it was copied > > from __remove_mapping(). > > Yes, this is not a bug and harmless. When we reach here, page should not be > dirtied because PageDirty is handled above and there is no way to redirty it > again as pagetable references are all gone and it's not in the swap cache. > > > > > 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. > > But it looks buggy as it didn't perform the expected ops from code view. > Should I drop the Fixes tag and send a v2 version? I don't understand the logic here -- it looks pretty obvious to me that, if we want to change anything, we should delete the dirty check, not add another line that would enforce the belief that the dirty check is needed. > > Many thanks for reply! > > > > >> Signed-off-by: Miaohe Lin > >> --- > >> mm/vmscan.c | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/mm/vmscan.c b/mm/vmscan.c > >> index a7602f71ec04..6483fe0e2065 100644 > >> --- a/mm/vmscan.c > >> +++ b/mm/vmscan.c > >> @@ -1628,6 +1628,7 @@ static unsigned int shrink_page_list(struct list_head *page_list, > >> if (!page_ref_freeze(page, 1)) > >> goto keep_locked; > >> if (PageDirty(page)) { > >> + SetPageSwapBacked(page); > >> page_ref_unfreeze(page, 1); > >> goto keep_locked; > >> } > >> -- > >> 2.23.0 > >> > >> > > . > > >