Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3663883pxv; Tue, 13 Jul 2021 00:27:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMjo40RxlrOeRtq9HFxODZUK67iI2Z52G8h8rJ+bMSUjR73X5cHaqYw1J456JS3LxA+BAi X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr3922691edd.206.1626161237367; Tue, 13 Jul 2021 00:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626161237; cv=none; d=google.com; s=arc-20160816; b=DqvGPagrstDoO/OYZePYFW3whEOuCFyBbzEWN7bJIkGlIYmchx84zmJM0xkSk95mb/ QVvfFSn6IknwJT4NRELEUBAWd1S+0hfQOohsLYpfctxpQpYcINpohSvcBYHq/hFJVkm7 bwJmdBz3q4QTzlzbTA8WH7td0+IeKrsx7NYJEVA1KLaiOO6ctJsBew7mjG5KjDxKsZh+ 8z2faq58GoWdZdnXWAHnuoQuSq+2+k7SzoUWbuH9qjFTQKJCRwrdXaXtZ8Xk2wqF7YYj qr7CjgrUrG1tPHj+N0XdUptd/YcbqEmslXT9a/2DIId8pMyGuL6fowRAfG+obOfqQRaZ I45w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kLualirFuyhQUpkaVrxmK4ztlGCjktHhBFIVEYAPxQA=; b=ymKWcCRD0cNaBKnnhj6IzuDlyQKApy1rIlcJHpfQT59AQuuKLyaTZdNtZ2FNgJb0Ep cgheK45iumqltlt6R3pLQJEWtZockoV8b3oTreX+muZDDmDfNEBSPid9K5EQI/Q5JWo7 fpOzKPHxBYOoIjpbbGb8emAlMr9RNzL4gmsH3mQGwmEAdFCX2NwWdufeQGrqbO32ux3/ LQil/ygjQLeorrA2arJoUkZcV1o31GfjBRss2ZSEqTwP0OH40ZzL9PrDAvEqxjWu8iD8 dp10h+g9203qGh19avJfJDtL0EffJAFgVYn0328JeTmRB0byd0/ADMxrlPoopo2V/xdq jtgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B6JoVQ10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw6si16091098ejb.493.2021.07.13.00.26.53; Tue, 13 Jul 2021 00:27:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=B6JoVQ10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbhGMH2m (ORCPT + 99 others); Tue, 13 Jul 2021 03:28:42 -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-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 > >> > >> > > . > > >