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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 DA5A8C433ED for ; Thu, 20 May 2021 01:22:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCB66611AD for ; Thu, 20 May 2021 01:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbhETBYM (ORCPT ); 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 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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 2CF50C433ED for ; Thu, 20 May 2021 01:22:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AC17D61028 for ; Thu, 20 May 2021 01:22:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC17D61028 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C79DD6B006C; Wed, 19 May 2021 21:22:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C29996B006E; Wed, 19 May 2021 21:22:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACA136B0070; Wed, 19 May 2021 21:22:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 775AA6B006C for ; Wed, 19 May 2021 21:22:55 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 09926181AF5D0 for ; Thu, 20 May 2021 01:22:55 +0000 (UTC) X-FDA: 78159860310.28.C3EBB0A Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf25.hostedemail.com (Postfix) with ESMTP id C79BC6000243 for ; Thu, 20 May 2021 01:22:51 +0000 (UTC) IronPort-SDR: KLK1EbC5gWq0wqQry8PpgYSL+v4xUhI00ZioUnpqvNt1+DSID5JJjxZQrXBpFROfDRzfZ4Hqih 4V+5Rn8sPFOw== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="265032524" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="265032524" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.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 X-Rspamd-Queue-Id: C79BC6000243 Authentication-Results: imf25.hostedemail.com; dkim=none; spf=none (imf25.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=ying.huang@intel.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) X-Rspamd-Server: rspam03 X-Stat-Signature: phz67mbp8bq9915bb6e3fbfand573y9r X-HE-Tag: 1621473771-627847 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: 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