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,DKIM_SIGNED, DKIM_VALID,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 72310C433ED for ; Thu, 20 May 2021 01:46:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2039611AD for ; Thu, 20 May 2021 01:46:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2039611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5F5E06B006C; Wed, 19 May 2021 21:46:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A5386B006E; Wed, 19 May 2021 21:46:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F7A26B0070; Wed, 19 May 2021 21:46:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0098.hostedemail.com [216.40.44.98]) by kanga.kvack.org (Postfix) with ESMTP id 0AC786B006C for ; Wed, 19 May 2021 21:46:53 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9EBBC181AEF10 for ; Thu, 20 May 2021 01:46:53 +0000 (UTC) X-FDA: 78159920706.17.FA44362 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf13.hostedemail.com (Postfix) with ESMTP id 70AD9E000105 for ; Thu, 20 May 2021 01:46:51 +0000 (UTC) Received: by mail-qk1-f174.google.com with SMTP id 76so14699276qkn.13 for ; Wed, 19 May 2021 18:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Z5/RTi1IdELulsUQK1tP18vsyEvr0MuQXrwyi68livE=; b=XuIo6OyTgGqSqeFiFhs+TCjPq3TZr2r6LFqHNPmZ6H8wQfpyGQ4BGCAoG3HoD8moOm PuNcqFKBgYLelkK1tuU7LvDhc+OJF0bJyxHBYj5pmcxwZFnHEo5XBwf5bMadjgMXO7u7 OsP8yglY39zCzP8VneQ7j1UcKQHeI4ZKgvDtE62gRlkBDfIqCKVSmQkz0a9D6Y40JwXs IbQVsP3Iir7N0LOmz1S8m87Q1VcoWIwxHsGjnjGyQ2oUAcIUOf3KmP6fBApzrRsHGi+o rxdh97PEIC2c8h47CzQz+5ez9FJbswG/hslJxWjM8pOBkcKp3VnfY6Ak14420ygy/PVI owkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Z5/RTi1IdELulsUQK1tP18vsyEvr0MuQXrwyi68livE=; b=kKGfoas71VfKkTZVYsjiTpHyJKgsnB/1YePEWsCk30Uko3+0B8YXMIui17D/NLNHK+ lIjM8F5gJVZRgr8oiIiKTr+aaaWfeJqHj+Y9FU+tfwWR0af/2xy5LLTi9JtfjagGVnRs d+qaScfHy+OCRBpStDF2zJbGfA2qrD2oyajpZQacybTVdAA05GlE3U5u4PWbwR1ZTuwE mW0WEOWPDw7rW6S4lntitvqb1kIffofN6HS10n/v7zWyTq7/JBMo+/vZRhyzvA1RFvAW OarNufSd1dNEYx4Fu+PV7h+1BPB681MpcYpUAO9ThMCyctYVTj9TdieUiru6Lt7/RtMD 9jrg== X-Gm-Message-State: AOAM532QAK4QW7EuENAWbmegtxIqzKEtXbLVEGufB6bGIKIyJqkEniNu hPOyM9Q4+0TNeA9+orHl5mMRCA== X-Google-Smtp-Source: ABdhPJykrI/hzK2ExP8boMVXmTf2YcpzghBnUv61y/ZLIHwNqzdAocB0zZcHivGXl8S9bGVrsyrW3g== X-Received: by 2002:a37:6514:: with SMTP id z20mr2649165qkb.11.1621475212414; Wed, 19 May 2021 18:46:52 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id d16sm931619qtw.23.2021.05.19.18.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 18:46:51 -0700 (PDT) Date: Wed, 19 May 2021 21:46:51 -0400 From: Johannes Weiner To: "Huang, Ying" 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 Message-ID: References: <20210519013313.1274454-1-ying.huang@intel.com> <87r1i28ahm.fsf@yhuang6-desk1.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r1i28ahm.fsf@yhuang6-desk1.ccr.corp.intel.com> X-Rspamd-Queue-Id: 70AD9E000105 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=XuIo6OyT; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf13.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.174 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam03 X-Stat-Signature: z33ncejmh1uhnbown7pa9o886gyxyz7j X-HE-Tag: 1621475211-601574 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 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. > 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. The LRU type is identified by PG_swapbacked, and we do clear that for anon pages to implement MADV_FREE. It may work here too. But I'm honestly a bit skeptical about the ROI on this...