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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 A14A4C433E0 for ; Wed, 13 Jan 2021 03:12:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 92A7C23123 for ; Wed, 13 Jan 2021 03:12:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92A7C23123 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 CC3966B013E; Tue, 12 Jan 2021 22:12:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C744A6B0140; Tue, 12 Jan 2021 22:12:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B89A76B0141; Tue, 12 Jan 2021 22:12:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id A0A4A6B013E for ; Tue, 12 Jan 2021 22:12:11 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 62F668245571 for ; Wed, 13 Jan 2021 03:12:11 +0000 (UTC) X-FDA: 77699278062.27.fold15_4607f502751a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 47C143D663 for ; Wed, 13 Jan 2021 03:12:11 +0000 (UTC) X-HE-Tag: fold15_4607f502751a X-Filterd-Recvd-Size: 3298 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 03:12:10 +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=PYhcFKwwl0qxGd2eQaH6HOLWjqEIHN+Z3aPsFEpq6Q0=; b=ZJYaRnvu9JQb8emm9CbCbaQEL+ prn8E19JIq/+NxNLM1ivFdQzHZleH6HBFaq7/LNEy9EmQq26Crka71IevTkkYev66Pe94H5BZ2u4s SffB4QJSn2EkHyN6WeYPPxWP+uWJsj24717am0PrYZP2StcdtGYUdvuThlE8eQa36+2k3ljbRWKnh M8vfQIiqO4ltnOQAR228GlUewfPKa171pq9yIzIHbc8DD9NWbpeXsg1SGknK0INCmnpnx+lRy1SrM ATlRevnatzFrkoF034uRrtF1SaQlSZjQHNQMygEYVmF3gtE/URASAv32oQSjAMc9wjJl2grVq7w/b 64uGyV9Q==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1kzWZS-005j83-8K; Wed, 13 Jan 2021 03:11:50 +0000 Date: Wed, 13 Jan 2021 03:11:42 +0000 From: Matthew Wilcox To: huang ying Cc: Linus Torvalds , Huang Ying , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Peter Xu , Hugh Dickins , Johannes Weiner , Mel Gorman , Rik van Riel , Andrea Arcangeli , Michal Hocko , Dave Hansen , Tim Chen Subject: Re: [PATCH] mm: Free unused swap cache page in write protection fault handler Message-ID: <20210113031142.GM35215@casper.infradead.org> References: <20210113024241.179113-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Jan 13, 2021 at 11:08:56AM +0800, huang ying wrote: > On Wed, Jan 13, 2021 at 10:47 AM Linus Torvalds > wrote: > > > > On Tue, Jan 12, 2021 at 6:43 PM Huang Ying wrote: > > > > > > So in this patch, at the end of wp_page_copy(), the old unused swap > > > cache page will be tried to be freed. > > > > I'd much rather free it later when needed, rather than when you're in > > a COW section. > > Unused swap cache isn't unused file cache. Nobody can reuse them > directly before freeing them firstly. It will make COW a little > faster via keeping them. But I think the overhead to free them isn't > high. While keeping them in system will confuse users (users will > expect file cache to use free memory, but not expect unused swap cache > to use much free memory), make the swap space more fragmented, and add > system overall overhead (scanning LRU list, etc.). Couldn't we just move it to the tail of the LRU list so it's reclaimed first? Or is locking going to be a problem here?