Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1391647pxj; Fri, 21 May 2021 13:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzywfAAIaoMDEdwHno/Jj8lBCPWqBVfTTAevdtu3qq/bNh2PrIceaNl0M2B5aVUlbJA1BDm X-Received: by 2002:a92:c7b3:: with SMTP id f19mr648021ilk.228.1621627570179; Fri, 21 May 2021 13:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621627570; cv=none; d=google.com; s=arc-20160816; b=BwC0fgzCL4ZeU5Q+gIY8vmtscawTvPjfXRlKdrrgJuNNZ9ICDkapC/8o01yccCDOrq CtqW0EpRAtbsYCUyeBsoIMLZbwTrAiSESwsObBFCWlxArf+VQ9J7iYxGjR6vW6kuvNvT GbWnmKESS+hwj/IS6/F3aXwOTMiYV3fYgQeGTpleeDwL/n9ZLLllQymBnN2FEpv3M1Bx hviMtPdeZWK1+xfgQytTB3EajXn7zgJMWuv/OH+DdhLCRpz3zP4otNVadGsAsluNviA0 HIapKt+qPoTfZzvqptzs1XL+hsJBulc4mV6cc3Z+O5mXDjRmV+KmDKVYoSkebjGKGUXV b+Og== 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=gr/O3wPHNsj5iEih8RNFaW1YsxlBKgKkkYwBiazeTBg=; b=Sw+nVhCfq3L9TC9uVNMMK/LdnGgtCrxCRkQ+trO4PNE1orHvCWLmgZKTn6S7+S251X 6m8HzOkx7hpkPulpRdrQMmWgKSrM1jIvtI0S49b8rz9TO6fVAmTxOhDddh8p227IQvLy tKSj99pp8E+pJS1R/Y2Y6r4Mk7EVlPH1MzCBgETSXEUqFMGJ5F+zMIBNGhnwyHZSHs0i jQ4S8Fg+9yqjGr2QTV+nG5HaZsVUWpu5tvXBz+9tftMZtc8sSuxtt75PLYk6dziuwQhd N36k5mp9bfJ3bs7UvX6q/Qg6Cpz81G68BAUViv8Ew2BNANjolY7XT+htLhY39tBBvoq1 Q/IA== 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 y5si7821211ily.21.2021.05.21.13.05.56; Fri, 21 May 2021 13:06:10 -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 S234496AbhEUCGv (ORCPT + 99 others); Thu, 20 May 2021 22:06:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:26558 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbhEUCGu (ORCPT ); Thu, 20 May 2021 22:06:50 -0400 IronPort-SDR: 8kIxRO2jYPh21gpieYo5/EW+DDrG17FDZAkBfKh8G9P7MZb4NGb2y6bEVUEqplIaNn2V0HTCr5 P0AJo4kNJzXw== X-IronPort-AV: E=McAfee;i="6200,9189,9990"; a="201421274" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="201421274" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2021 19:05:28 -0700 IronPort-SDR: ozfDnHgnfmd6Um2s85dibhgvFoBS92YBbMvNTPTJZ74PI7MLraeXnzMmwyh7L8+2+M86u29a6B j8AKOMxTOGpg== X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="440705454" 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; 20 May 2021 19:05:24 -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> <87r1i28ahm.fsf@yhuang6-desk1.ccr.corp.intel.com> <87im3e88ss.fsf@yhuang6-desk1.ccr.corp.intel.com> Date: Fri, 21 May 2021 10:05:21 +0800 In-Reply-To: (Johannes Weiner's message of "Thu, 20 May 2021 13:49:37 -0400") Message-ID: <87wnrs7sf2.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 Thu, May 20, 2021 at 09:59:15AM +0800, Huang, Ying wrote: >> Johannes Weiner writes: >> >> > On Thu, May 20, 2021 at 09:22:45AM +0800, Huang, Ying wrote: >> >> 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. >> > >> > Sorry, I had missed that thread. >> > >> > It sounds like there were the same concerns about the LRU shuffling >> > overhead in the COW page. Now we have numbers for that, but not the >> > free_swap_cache version. Would you be able to run the numbers for that >> > as well? It would be interesting to see how much the additional code >> > complexity buys us. >> >> The number for which workload? The workload that is used to evaluate >> this patch? > > Yeah, the pmbench one from the changelog. Sure. I have rebased the original patch that frees the idle swap cache directly and done the test. The results show that the pmbench score of freeing directly is a little better than that of moving to the tail of LRU. The pmbench score increases about 3.6%. I think this is expected, because we need to free the page finally even if we move the idle swap cache to the tail of LRU. Best Regards, Huang, Ying