Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3907128pxv; Tue, 13 Jul 2021 06:38:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxfcLqhH2Qpm2xfzLeGhBr2GA75lm7XVGN3u8ZXSEdVED0R/JtV9BTPXWdNu7E3K0ajEor X-Received: by 2002:a17:907:7887:: with SMTP id ku7mr5618045ejc.102.1626183513532; Tue, 13 Jul 2021 06:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626183513; cv=none; d=google.com; s=arc-20160816; b=HnIWdNLQ0eHRMfXR1S8THfl1rEfsapsSLBxBq81vS1+1qsTUBUzDudhj5rQviqiIGg 1vlAykqnfuhrODb1JT4kv9J9fFbTVr4EXR810bog1OZqCrwo0chR+lEHwbtphtZ8C5Gf yYGPlXtPfZEDQLRweaqBXxXJdxstagrH6Jc7LVAyrh/0ElhsrOCtx4qT+zCu9TOVnL0k qdZJWM02ga21baZuYq0kwoOk/fyuq9zlT/GzYJiAv37OBA4FfRrjiQhtXKOccXMZrh6F 1dqTlaEb0o+HUjaxV/i7tvh/SdmI/KMmcqxDiUBQmsC/Pp5NwB2LV4mJKlpRgHxlsRBd t4UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZA1DadVLZD9AXCRqiJYuLnFt7xfm1nC1fZG/MI97rdM=; b=k1g8dwIVlTZZ1R8/XLEKbuGzwi88mrjChXwN3bFKm2Ocnxmpt89jV8lh3ds0qDvQKN og31cejQxdq7qZC6BgxkTNvykvW5gd6xd4jOnICMXlMPwiEse7DcbPQfOaeE+h192GEp wP5U6am3vhOlOWE6sBN+AN8VrEOymU6EH2hZbdlq4RCR702UhHd5z1MgwbC9Nxw0Op2K kHfWrqgf0CTJi+9tGHmt+3OrOue6Apr0U6ur3oA+CyvJjcMV9fpcb/cnqI7psk6cfCaw 3ocOIo2+nNXRsY8iJXJuHIQYgF+3Hz/tyCCxRoG6kjbjxx1VeAm/45E9okiYmTPmbvH3 +N9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HriJ5bDB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si18522873ejr.696.2021.07.13.06.38.10; Tue, 13 Jul 2021 06:38:33 -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=@infradead.org header.s=casper.20170209 header.b=HriJ5bDB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236594AbhGMNh4 (ORCPT + 99 others); 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.