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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 CC9CDC07E95 for ; Tue, 13 Jul 2021 13:35:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6ED8611C0 for ; Tue, 13 Jul 2021 13:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236620AbhGMNh4 (ORCPT ); Tue, 13 Jul 2021 09:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236461AbhGMNhz (ORCPT ); Tue, 13 Jul 2021 09:37:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12D4C0613DD for ; Tue, 13 Jul 2021 06:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZA1DadVLZD9AXCRqiJYuLnFt7xfm1nC1fZG/MI97rdM=; b=HriJ5bDBCfYBYTVSac9JD4q1xz 0vElAdekSpQqBF8NY1bpD6ZVjsRGrX6nHyEZhAayovdMJTQg9Eo254iWVQXLyF2vMGxzvQ9GSV3mI j3tpqg3TTvwD1Cy5khcA9YFL5DZlPBEi890JPIC1Myi0cgKioerdCaG2FyPqDu7vrAiLdLbr3zYGb a/EIgnfOzvX/2HoiKnIYuP/Ebq8lGSD+YabVi06wepWRD6Y/dngXef8Y+JTuIJhemSm+Ap+CxRLww RcdjCznkOeDFs1+jpEjTK6clBBSTuGxQC8b3c3jR5nf6AGFP7zpWG0hXy0RDIiUXtanyQf3v9n1dF sDLmLiWw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3IY7-0018fv-GO; Tue, 13 Jul 2021 13:34:16 +0000 Date: Tue, 13 Jul 2021 14:34:11 +0100 From: Matthew Wilcox To: Miaohe Lin Cc: Michal Hocko , akpm@linux-foundation.org, hannes@cmpxchg.org, vbabka@suse.cz, axboe@kernel.dk, iamjoonsoo.kim@lge.com, alexs@kernel.org, apopple@nvidia.com, minchan@kernel.org, david@redhat.com, shli@fb.com, hillf.zj@alibaba-inc.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] mm/vmscan: put the redirtied MADV_FREE pages back to anonymous LRU list Message-ID: References: <20210710100329.49174-1-linmiaohe@huawei.com> <20210710100329.49174-2-linmiaohe@huawei.com> <9409189e-44f7-2608-68af-851629b6d453@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 13, 2021 at 09:13:51PM +0800, Miaohe Lin wrote: > >> When the MADV_FREE pages are redirtied before they could be reclaimed, the pages > >> should be put back to anonymous LRU list by setting SwapBacked flag, thus the > >> pages will be reclaimed in normal swapout way. > > > > Agreed. But the question is why this needs an explicit handling here > > when we already do handle this case when trying to unmap the page. > > This makes me think more. It seems even the page_ref_freeze call is guaranteed to > success as no one can grab the page refcnt after the page is successfully unmapped. NO! This is wrong. Every page can have its refcount speculatively raised (and then lowered). The two prime candidates for this are lockless GUP and page cache lookups, but there can be others too.