Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp50352pxb; Tue, 12 Jan 2021 19:44:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrw2RvWaMq9vZYDl38YP8T8ytDt4XLtefzGEZhfOImElZPt0h1eJXbo4wM09qMpVefHaaq X-Received: by 2002:a17:906:810:: with SMTP id e16mr125761ejd.34.1610509457376; Tue, 12 Jan 2021 19:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610509457; cv=none; d=google.com; s=arc-20160816; b=PweXb02aLsYcKQjLxYH7PCs05oUx+0X/A0HF2qATuTNLMtZ111kKaVxq6xNydNCI9B EEpzTw5jIyt5KIwBXslvYLklq4jv6Z/Gk+6A4UfBaqrae9oeY90HokokZ2xl09MN1RrT l5bXnNeHAmecn3gUCfJQo/DCCRp1eqa4JX1lwspGcCPS0mIf8DB8EPX4otUTVR/70B7b 83+7fvd5n1RfDsAhxka7MpXfd6LWLs/FjfXs1yd7IqLvfL6YAAXRIGWAUhX2P2kL9mt6 l5jtPKBkirz/EeOprKrlnTOFPi0NbgC7dj2DSFJZKy9oTMHAyuW0XAzeFsKrPO3gS3OP Ln5A== 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=PYhcFKwwl0qxGd2eQaH6HOLWjqEIHN+Z3aPsFEpq6Q0=; b=Io45LDFFbsjubbkeKL43Rj75g6PPiHr7VYW4H2mcs9p0FElyhlW2LZbVHFNwyNYYdL djghUjibsyKIICYjf5QWBpdNlRk53mh0Hm47vM8ZV4OwJoG83NvTqcyAR0Ib1s4IFRAq cw+CciYjmxifO/dbsZr4v3bf3B2uhwSCf3RZic3cdfwVdr4lTTXDDo+o7tnatEwnohb+ 2ygRDisu5JDjWKDESPcNMccWAv1NkrUsd2TqqJHqh7Qk+O9tX7BvPJehsRvrPhcxQVPM zwG6fCoNZrF3k/XLKt1v+rpeHb0T7ItwtlgqhAkTWhk9wy1vQgpEJZKvTkf1KpqbaUbM FMNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZJYaRnvu; 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 bo24si314728edb.495.2021.01.12.19.43.54; Tue, 12 Jan 2021 19:44:17 -0800 (PST) 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=ZJYaRnvu; 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 S1728590AbhAMDM4 (ORCPT + 99 others); Tue, 12 Jan 2021 22:12:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbhAMDM4 (ORCPT ); Tue, 12 Jan 2021 22:12:56 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D2B4C061575 for ; Tue, 12 Jan 2021 19:12:16 -0800 (PST) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?