Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1942122pxj; Wed, 19 May 2021 18:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjcZzHSWbALkzD3cwO0Rgvuk+b8eRy2fpDNySdyo+QzauNP0PIzWNE5IrYdy8IWzN0J+wK X-Received: by 2002:a5e:a619:: with SMTP id q25mr2571138ioi.95.1621473951962; Wed, 19 May 2021 18:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621473951; cv=none; d=google.com; s=arc-20160816; b=L/IB91eWXAhhVEArAGpDHgNYE5rbPI20n2Xqn9nH0HijlpWBg+Mv7+IC1gkC9QMYos XamSiRqVcmabpozqFfrbB0KjbEp6ZOxC8zhI9jQhrK/E5VpCXJfjikQ4bRCWftEp9i2y 938HZQ4VTLzIUlDUhZb/m4Lszry/kk3kiRFh8KA+tbFDIw8RIBrATDD5gzVAPaVHH4B+ S3BiQ7DmBoYfHIMM5wIOiVizlrV+s9R3pGkQLTAqlsf4TE7FtTYIVFzrKUjBSPgGPU7s Xa7F193Qk+Jp9pZttmYdua6513CmYyqYx/arnOzD2+0imdyfGprXJweW7Jp6Y9UezxcL Tsuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=ndqUuykdSSsHIowOg+wnE3AI1p1f03eHebhLo7P4CeE=; b=DBuMTMBPvn2ZepiCixgZzKROXYtY9aPZJBxQX2HMKuJMluWiXjUz+tu60FUKmRD3XF yNsdcNSmt5TWP3I61y6GmY84Pu1QDSCcNGBySTDD2jUa6/UMXQz81gJXBZdV11GZGZ+C T6Ixys0/ThJYxYUilWRl86rpND5F3QDd39oC8QNTEGO37LdaJmimf1Xei1xvVNC0PKwA MTEhuO/Ldo4qRthk+UEOZ8F+vI4yzrSifD1C3A7a1+NfbOhJKifp7uy3fqZaTyOrvHMf y3i+cNAd/p22k07mZXcJFA9qbWS6Ygf4wGopAjGcCFAgftSNKcq1YNlE9enyJU7Dzumr EL+A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si1083942jan.4.2021.05.19.18.25.37; Wed, 19 May 2021 18:25:51 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbhETBYM (ORCPT + 99 others); Wed, 19 May 2021 21:24:12 -0400 Received: from mga02.intel.com ([134.134.136.20]:64728 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhETBYM (ORCPT ); Wed, 19 May 2021 21:24:12 -0400 IronPort-SDR: dpDEAwo4cosxh7djoclagD3YJO9nrb0cDd/CyRKx7tsdRMijD5cpUt2WxqMY+DOx5KqSjDSgKZ mtruFU8Hf+ZQ== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="188246568" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="188246568" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2021 18:22:51 -0700 IronPort-SDR: PWfdGOb06qVDM6X27/4KBStD4pv/kuC00A1YSX6+Oy8t8xQP6JPZsr49wEn13KAimSly57HxQM je1fZtKIKKVg== X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="440222333" Received: from yhuang6-desk1.sh.intel.com (HELO yhuang6-desk1.ccr.corp.intel.com) ([10.239.13.1]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2021 18:22:47 -0700 From: "Huang, Ying" To: Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Linus Torvalds , Peter Xu , Hugh Dickins , Mel Gorman , Rik van Riel , Andrea Arcangeli , Michal Hocko , Dave Hansen , Tim Chen Subject: Re: [PATCH] mm: move idle swap cache pages to the tail of LRU after COW References: <20210519013313.1274454-1-ying.huang@intel.com> Date: Thu, 20 May 2021 09:22:45 +0800 In-Reply-To: (Johannes Weiner's message of "Wed, 19 May 2021 10:49:33 -0400") Message-ID: <87r1i28ahm.fsf@yhuang6-desk1.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Johannes Weiner writes: > On Wed, May 19, 2021 at 09:33:13AM +0800, Huang Ying wrote: >> diff --git a/mm/memory.c b/mm/memory.c >> index b83f734c4e1d..2b6847f4c03e 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -3012,6 +3012,11 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) >> munlock_vma_page(old_page); >> unlock_page(old_page); >> } >> + if (page_copied && PageSwapCache(old_page) && >> + !page_mapped(old_page) && trylock_page(old_page)) { >> + try_to_free_idle_swapcache(old_page); >> + unlock_page(old_page); > > If there are no more swap or pte references, can we just attempt to > free the page right away, like we do during regular unmap? > > if (page_copied) > free_swap_cache(old_page); > put_page(old_page); A previous version of the patch does roughly this. https://lore.kernel.org/lkml/20210113024241.179113-1-ying.huang@intel.com/ But Linus has concerns with the overhead introduced in the hot COW path. Another possibility is to move the idle swap cache page to the tail of the file LRU list. But the question is how to identify the page. Best Regards, Huang, Ying