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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 27857C11F66 for ; Tue, 13 Jul 2021 13:35:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9E97C611C0 for ; Tue, 13 Jul 2021 13:35:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E97C611C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CA81B6B008C; Tue, 13 Jul 2021 09:35:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C640C6B0095; Tue, 13 Jul 2021 09:35:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1FF46B0096; Tue, 13 Jul 2021 09:35:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id 8E5D26B008C for ; Tue, 13 Jul 2021 09:35:04 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 93FA91801E315 for ; Tue, 13 Jul 2021 13:35:03 +0000 (UTC) X-FDA: 78357660486.10.AFCF35F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id E9787E001821 for ; Tue, 13 Jul 2021 13:35:02 +0000 (UTC) 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: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HriJ5bDB; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam02 X-Stat-Signature: 763b9n6zrgaatzoubxmrk4wy8migregb X-Rspamd-Queue-Id: E9787E001821 X-HE-Tag: 1626183302-107431 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 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.