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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 94710C47089 for ; Fri, 28 May 2021 01:27:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 13BDE613B5 for ; Fri, 28 May 2021 01:27:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 13BDE613B5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 727376B006C; Thu, 27 May 2021 21:27:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D6BE6B006E; Thu, 27 May 2021 21:27:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 529726B0070; Thu, 27 May 2021 21:27:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 226066B006C for ; Thu, 27 May 2021 21:27:48 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AB0771812DCE7 for ; Fri, 28 May 2021 01:27:47 +0000 (UTC) X-FDA: 78188902974.08.8E06C7B Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by imf23.hostedemail.com (Postfix) with ESMTP id 2DD5DA0003AB for ; Fri, 28 May 2021 01:27:40 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id c15so3222977ljr.7 for ; Thu, 27 May 2021 18:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oiL2+jMjytGTOxMvXGwzwUo5vCZt66vYTiHQDgUEKHE=; b=BttFZy0GPIhhl/djFDRh9gv/Yz2WzqdPIHwZvXr+4BWx1KPOte4Hb1m+Mi1zIdnLrs bip3zV2OG4EdjV0YO/KOAp3nhTw2oJoWHS5y1Nrf0wj034n38qtAnqNjGXirOKcjGiqX y8bGEQFPwKJnxQLA3n+m20YGnQOUUbK+jnmFM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oiL2+jMjytGTOxMvXGwzwUo5vCZt66vYTiHQDgUEKHE=; b=l7CUEv2puoRrrvEXe9XZvjkG/PwuvdbB+g1bo6IaTLDPN/xCmnmBXaYDFhZgDI+onJ vEu2iMwM19Ckxc64pe+j4L1UKhF2p6oaZCxLwfY2olIlt5UwuTWM8iQO3iqpEm68llOO mF5ORbyS9kq4JBCH8hBlLZOhbva9rtnWqXVuTfe12xZ3/AO2iioy/l2LiFmtQuzjSosx /yQut1e1zgrd20k5h1v/alrgJAEHnq+CcQ2joss4K0UrN6FTBLB7pTHuVn5Jc2t/T2Z6 QSRip5VJebPyCIab8l/kVIqOdbLoFVcvHC72BYH9h43+BmHmRv6R4Zkj6axGQc3oZJpx dItA== X-Gm-Message-State: AOAM531s9MGGiu3COSErtgweCJlKHfyfJabwH1GWRdufhs6qeO9g2ONJ lNYZygwGpX4lNqfjaFttQm4s3bJJVwmjcNI/ X-Google-Smtp-Source: ABdhPJxtHADYm9i9d3rBnPrp5XxCQxq1cckGO5tYGos3wJS0fWt9oOFikxPzJVQ0lZUpN93fBGu4/Q== X-Received: by 2002:a2e:808a:: with SMTP id i10mr4703122ljg.288.1622165265417; Thu, 27 May 2021 18:27:45 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id a12sm397960ljk.34.2021.05.27.18.27.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 May 2021 18:27:44 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id b12so3256067ljp.1 for ; Thu, 27 May 2021 18:27:44 -0700 (PDT) X-Received: by 2002:a05:651c:8f:: with SMTP id 15mr4882494ljq.220.1622165264266; Thu, 27 May 2021 18:27:44 -0700 (PDT) MIME-Version: 1.0 References: <20210527084953.573788-1-ying.huang@intel.com> In-Reply-To: From: Linus Torvalds Date: Thu, 27 May 2021 15:27:28 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH -V2] mm: move idle swap cache pages to the tail of LRU after COW To: Johannes Weiner Cc: Huang Ying , Andrew Morton , Linux-MM , Linux Kernel Mailing List , Matthew Wilcox , Peter Xu , Hugh Dickins , Mel Gorman , Rik van Riel , Andrea Arcangeli , Michal Hocko , Dave Hansen , Tim Chen Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 2DD5DA0003AB Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=BttFZy0G; dmarc=none; spf=pass (imf23.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.172 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-Rspamd-Server: rspam03 X-Stat-Signature: xqogdqgumnogj9ky9447ozfs6kmuhqpc X-HE-Tag: 1622165260-56517 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 27, 2021 at 6:53 AM Johannes Weiner wrote: > > OTOH, freeing is a two-liner reusing the swap unmap code: > > if (page_copied) > free_swap_cache(old_page); > > Linus, what do you think? I'm ok with that version, the important thing was (a) avoiding the unconditional page lock we used to have (well, it first did "trylock", but if tht failed it would then get a page ref, and do the unconditional lock_page()) (b) avoid the re-use based on "mapcount" that had problems with non-mapped page references (ie GUP) and (c) that I wanted to see some numbers rather than just blindly re-introduce free_swap_cache() But doing the above two-liner in wp_page_copy() doesn't have the (a)/(b) issues, and if we have numbers that it helps, then that takes care of (c) too. Of course, I don't think it's just that two-liner, because you'd actually have to export (or move )that "free_swap_cache()" function that is now private to swapfile.c. But no, I'm not adverse to the above at all, I just had the above reservations. I was worried about non-swap behavior (which the old code had with that whole unconditional page locking whether needed or not), but free_swap_cache() should be basically free for the non-swap behavior since it doesn't even do the trylock until after it has checked that it is now an unmapped swap cache page. Linus